<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>org.switchyard.tools</groupId>
    <artifactId>switchyard-tools-eclipse</artifactId>
    <version>2.1.0-SNAPSHOT</version>
    <relativePath>../pom.xml</relativePath>
  </parent>
  <groupId>org.switchyard.tools</groupId>
  <artifactId>switchyard-tools-eclipse-site</artifactId>
  <packaging>eclipse-repository</packaging>
  <name>SwitchYard: Eclipse Tools Update Site</name>
  <description>Eclipse update site for SwitchYard tooling.</description>

  <properties>
    <BUILD_TYPE>snapshots</BUILD_TYPE>
    <BUILD_ALIAS>${buildQualifier}</BUILD_ALIAS>
    <qualifiedVersion>${unqualifiedVersion}.${BUILD_ALIAS}</qualifiedVersion>
    <update.site.name>SwitchYard</update.site.name>
    <update.site.version>${qualifiedVersion}</update.site.version>
    <update.site.description>Continuous Integration</update.site.description>
    <target.eclipse.version>4.5 (Mars)</target.eclipse.version>
  </properties>

  <profiles>  

    <!-- integration build profile -->
    <profile>
      <id>integration</id>
      <activation>
        <property>
          <name>BUILD_TYPE</name>
          <value>staging</value>
        </property>
      </activation>
      <properties>
        <update.site.description>Integration Build</update.site.description>
      </properties>
    </profile>

    <!-- development build profile -->
    <profile>
      <id>development</id>
      <activation>
        <property>
          <name>BUILD_TYPE</name>
          <value>development</value>
        </property>
      </activation>
      <properties>
        <update.site.description>Development Milestone</update.site.description>
      </properties>
    </profile>

    <profile>
      <id>stable</id>
      <activation>
        <property>
          <name>BUILD_TYPE</name>
          <value>stable</value>
        </property>
      </activation>
      <properties>
        <update.site.description>Stable Release</update.site.description>
      </properties>
    </profile>

    <profile>
      <id>earlyaccess</id>
      <activation>
        <property>
          <name>BUILD_TYPE</name>
          <value>earlyaccess</value>
        </property>
      </activation>
      <properties>
        <update.site.description>Early Access Release</update.site.description>
      </properties>
    </profile>

    <profile>
      <id>deploy-to-jboss.org</id>
      <properties>
        <jbosstoolsRelengPublishVersion>4.3.0.CR1-SNAPSHOT</jbosstoolsRelengPublishVersion>

        <deployScriptDir>${project.build.directory}/releng-scripts</deployScriptDir>
        <deployScript>${deployScriptDir}/publish/rsync.sh</deployScript>
        <deploySourceFolder>${project.build.directory}/repository</deploySourceFolder>
        <deployDestination>tools@filemgmt.jboss.org:downloads_htdocs/jbosstools</deployDestination>
        <deployTargetFolder>mars/snapshots/builds/switchyard-tools/${BUILD_ID}-B${BUILD_NUMBER}/all/repo/</deployTargetFolder>
        <maven.deploy.skip>false</maven.deploy.skip>
      </properties>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
              <execution>
                <id>deploy-releng-scripts</id>
                <goals>
                  <goal>unpack</goal>
                </goals>
                <phase>deploy</phase>
                <configuration>
                  <artifactItems>
                    <artifactItem>
                      <groupId>org.jboss.tools.releng</groupId>
                      <artifactId>jbosstools-releng-publish</artifactId>
                      <version>${jbosstoolsRelengPublishVersion}</version>
                      <type>tar.gz</type>
                      <outputDirectory>${deployScriptDir}</outputDirectory>
                    </artifactItem>
                  </artifactItems>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>1.3.2</version>
            <configuration>
              <executable>${deployScript}</executable>
            </configuration>
            <executions>
              <execution>
                <id>deploy-snapshot-build</id>
                <goals>
                  <goal>exec</goal>
                </goals>
                <phase>deploy</phase>
                <configuration>
                  <arguments>
                    <arg>-DESTINATION</arg>
                    <arg>${deployDestination}</arg>
                    <arg>-s</arg>
                    <arg>${deploySourceFolder}</arg>
                    <arg>-t</arg>
                    <arg>${deployTargetFolder}</arg>
                  </arguments>
                </configuration>
              </execution>
              <execution>
                <id>deploy-snapshot-updatesite</id>
                <goals>
                  <goal>exec</goal>
                </goals>
                <phase>deploy</phase>
                <configuration>
                  <arguments>
                    <arg>--del</arg>
                    <arg>-DESTINATION</arg>
                    <arg>${deployDestination}</arg>
                    <arg>-s</arg>
                    <arg>${project.build.directory}/repository</arg>
                    <arg>-t</arg>
                    <arg>mars/${BUILD_TYPE}/updates/integration-stack/switchyard-tools/${jbosstools_site_stream}/</arg>
                  </arguments>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
  
  <build>
    <finalName>${project.artifactId}-${qualifiedVersion}</finalName>
    <plugins>
      <plugin>
        <groupId>org.jboss.tools.tycho-plugins</groupId>
        <artifactId>repository-utils</artifactId>
        <version>${jbossTychoPluginsVersion}</version>
        <executions>
          <execution>
            <id>generate-facade</id>
            <phase>package</phase>
            <goals>
              <goal>generate-repository-facade</goal>
            </goals>
            <configuration>
              <siteTemplateFolder>siteTemplateFolder</siteTemplateFolder>
              <symbols>
                <update.site.name>${update.site.name}</update.site.name>
                <update.site.version>${update.site.version}</update.site.version>
                <update.site.description>${update.site.description}</update.site.description>
                <target.eclipse.version>${target.eclipse.version}</target.eclipse.version>
              </symbols>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <target>
                <!-- create site_assembly.zip for publish.sh scriptgenerate-repository-facade v0.21 does not use finalName so do the work ourselves.-->
                <copy file="${project.build.directory}/${project.artifactId}-${project.version}.zip" toFile="${project.build.directory}/site_assembly.zip"/>
                <!-- generate-repository-facade v0.21 does not use finalName so do the work ourselves. -->
                <move file="${project.build.directory}/${project.artifactId}-${project.version}.zip" toFile="${project.build.directory}/${project.build.finalName}.zip"/>
              </target>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

</project>
