<?xml version="1.0" encoding="UTF-8"?>
<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>

  <groupId>org.jboss.tools.integration-stack</groupId>
  <artifactId>target-platform</artifactId>
  <version>4.1.7.Final</version>

  <name>JBoss Tools Integration Stack Target Platform</name>
  <description>
    JBoss Tools integration stack component target dependencies + JBoss Tools core target dependencies +
    JBoss Tools unified core target dependencies forming an 'aggregate-base.target' combined target.

    Then add any leftover community dependencies to the aggregate forming an aggregate-full.target.
  </description>

  <packaging>pom</packaging>

  <!-- JBoss parent POM required for nexus deployment. -->
  <parent>
    <groupId>org.jboss</groupId>
    <artifactId>jboss-parent</artifactId>
    <version>10</version>
  </parent>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <tychoVersion>0.18.1</tychoVersion>
    <tychoExtrasVersion>0.18.1</tychoExtrasVersion>
    <JBTCoreUnifiedTPVersion>4.31.1.Final</JBTCoreUnifiedTPVersion>
  </properties>

  <repositories>

    <repository>
      <id>jboss-snapshots-repository</id>
      <name>JBoss Snapshots Repository</name>
      <url>https://repository.jboss.org/nexus/content/repositories/snapshots/</url>
      <snapshots>
	<enabled>true</enabled>
      </snapshots>
    </repository>

    <repository>
      <id>jboss-releases</id>
      <name>JBoss Releases Maven Repository</name>
      <url>https://repository.jboss.org/nexus/content/repositories/releases/</url>
      <releases>
	<enabled>true</enabled>
      </releases>
    </repository>

    <repository>
      <id>jboss-public-repository-group</id>
      <name>JBoss Public Maven Repository Group</name>
      <url>https://repository.jboss.org/nexus/content/groups/public/</url>
      <layout>default</layout>
      <releases>
        <enabled>true</enabled>
        <updatePolicy>never</updatePolicy>
      </releases>
      <snapshots>
        <enabled>true</enabled>
        <updatePolicy>never</updatePolicy>
      </snapshots>
    </repository>

  </repositories>

  <pluginRepositories>

    <pluginRepository>
      <id>jboss-public-repository-group</id>
      <name>JBoss Public Repository Group</name>
      <url>http://repository.jboss.org/nexus/content/groups/public/</url>
      <releases>
        <enabled>true</enabled>
      </releases>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </pluginRepository>

  </pluginRepositories>

  <reporting>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-plugin-plugin</artifactId>
        <version>2.5.1</version><!-- same version as build plugin -->
        <reportSets>
          <reportSet>
            <reports>
              <report>report</report>
            </reports>
          </reportSet>
        </reportSets>
      </plugin>
    </plugins>
  </reporting>

  <build>

    <plugins>

      <plugin>
	<groupId>org.eclipse.tycho</groupId>
	<artifactId>tycho-maven-plugin</artifactId>
	<version>${tychoVersion}</version>
	<extensions>true</extensions>
      </plugin>

      <plugin>
	<groupId>org.jboss.tools.tycho-plugins</groupId>
	<artifactId>target-platform-utils</artifactId>
	<version>0.16.0.CR2</version>

	<executions>

	  <!-- Merge:

	       1. the integration-stack specific target dependencies:   integration-stack-base.target
	       2. the JBoss Tools core target dependencies:           + core-base.target
	       3. the JBoss Tools unified core target dependencies:   + jbosstools-unified....target
                                                                        _____________________________
	       to generate an aggregate base target dependencies file:  aggregate-base.target
            -->
	  <execution>

	    <id>merge-base</id>
	    <phase>generate-resources</phase>
	    <goals>
	      <goal>merge-targets</goal>
	    </goals>

	    <configuration>

	      <sourceTargetArtifacts>
		<item>
		  <groupId>org.jboss.tools.targetplatforms</groupId>
		  <artifactId>jbosstools-unified</artifactId>
		  <version>${JBTCoreUnifiedTPVersion}</version>
		  <classifier>jbosstools-unified</classifier>
		</item>
	      </sourceTargetArtifacts>

	      <sourceTargetFiles>
		<item>${basedir}/integration-stack-base.target</item>
		<item>${basedir}/core-base.target</item>
	      </sourceTargetFiles>

	      <outputFile>${project.build.directory}/aggregate-base.target</outputFile>

	    </configuration>
	  </execution>

	  <!-- Merge:
	       1. the previously generated aggregate base target file:    aggregate-base.target
	       2. the community-specific target dependencies:           + community.target
                                                                          _____________________
	       to generate the full community target dependencies file:   aggregate-full.target
	    -->
	  <execution>

	    <id>merge-community</id>
	    <phase>generate-resources</phase>
	    <goals>
	      <goal>merge-targets</goal>
	    </goals>

	    <configuration>

	      <sourceTargetFiles>
		<item>${basedir}/community.target</item>
		<item>${project.build.directory}/aggregate-base.target</item>
	      </sourceTargetFiles>

	      <outputFile>${project.build.directory}/aggregate-full.target</outputFile>

	    </configuration>
	  </execution>

	</executions>
      </plugin>

      <plugin>
	<groupId>org.eclipse.tycho.extras</groupId>
	<artifactId>target-platform-validation-plugin</artifactId>
	<version>${tychoExtrasVersion}</version>

	<executions>
	  <execution>

	    <!--Validate the aggregated target dependencies. -->
	    <phase>verify</phase>
	    <goals>
	      <goal>validate-target-platform</goal>
	    </goals>

	    <configuration>

	      <targetFiles>
		<param>${project.build.directory}/aggregate-base.target</param>
		<param>${project.build.directory}/aggregate-full.target</param>
	      </targetFiles>
	      <failOnError>true</failOnError>

	    </configuration>
	  </execution>
	</executions>
      </plugin>

      <!-- Use the codehaus mojo to package the aggegated target dependencies (base and community). -->
      <plugin>
	<groupId>org.codehaus.mojo</groupId>
	<artifactId>build-helper-maven-plugin</artifactId>
	<version>1.3</version>

	<executions>
	  <execution>
	    <id>attach-artifacts-base</id>
	    <phase>package</phase>
	    <goals>
	      <goal>attach-artifact</goal>
	    </goals>

	    <configuration>

	      <tasks>
		<echo>Packaging the aggregated base target dependencies.</echo>
	      </tasks>

	      <artifacts>
		<artifact>
		  <file>${project.build.directory}/aggregate-base.target</file>
		  <type>target</type>
		  <classifier>base</classifier>
		</artifact>
	      </artifacts>

	    </configuration>
	  </execution>

	  <execution>
	    <id>attach-artifacts-full</id>
	    <phase>package</phase>
	    <goals>
	      <goal>attach-artifact</goal>
	    </goals>

	    <configuration>

	      <tasks>
		<echo>Packaging the aggregated full target dependencies (base + community).</echo>
	      </tasks>

	      <artifacts>
		<artifact>
		  <file>${project.build.directory}/aggregate-full.target</file>
		  <type>target</type>
		  <classifier>full</classifier>
		</artifact>
	      </artifacts>

	    </configuration>
	  </execution>

	  <execution>
	    <id>attach-artifacts-target-platform-base</id>
	    <phase>package</phase>
	    <goals>
	      <goal>attach-artifact</goal>
	    </goals>
	    <configuration>
	      <artifacts>
		<artifact>
		  <file>integration-stack-base.target</file>
		  <type>target</type>
		  <classifier>integration-stack-base</classifier>
		</artifact>
	      </artifacts>
	    </configuration>
	  </execution>

	</executions>
      </plugin>

    </plugins>
  </build>

  <!-- Mirror just the integration stack target dependencies.  This will be used by the production
       build as an extra repo.  -->
  <profiles>
    <profile>
      <id>isbtp2repo</id>
      <activation>
	<activeByDefault>false</activeByDefault>
      </activation>

      <build>
	<plugins>

	  <plugin>
	    <groupId>org.jboss.tools.tycho-plugins</groupId>
	    <artifactId>target-platform-utils</artifactId>
	    <version>0.16.0.CR2</version>

	    <executions>
	      <execution>
		<phase>package</phase>
		<goals>
		  <goal>mirror-target-to-repo</goal>
		</goals>
		<configuration>
		  <sourceTargetFile>integration-stack-base.target</sourceTargetFile>
		</configuration>
	      </execution>
	    </executions>
	  </plugin>

	  <plugin>
	    <groupId>org.apache.maven.plugins</groupId>
	    <artifactId>maven-antrun-plugin</artifactId>
	    <version>1.7</version>

	    <executions>
	      <execution>
		<phase>package</phase>

		<configuration>
		  <quiet>true</quiet>
		  <target>
		    <!-- ANT script to remove the <references> section from the mirror repo content.xml. -->
		    <ant antfile="../scripts/remove.references.xml" dir=".">
		      <property name="workDir" value="./target/target-platform.target.repo" />
		    </ant>
		  </target>
		</configuration>
		<goals>
		  <goal>run</goal>
		</goals>
	      </execution>
	    </executions>

	    <dependencies>
	      <dependency>
		<groupId>commons-net</groupId>
		<artifactId>commons-net</artifactId>
		<version>1.4.1</version>
	      </dependency>
	      <dependency>
		<groupId>org.apache.ant</groupId>
		<artifactId>ant</artifactId>
		<version>1.8.2</version>
	      </dependency>
	      <dependency>
		<groupId>org.apache.ant</groupId>
		<artifactId>ant-nodeps</artifactId>
		<version>1.8.1</version>
	      </dependency>
	      <dependency>
		<groupId>org.apache.ant</groupId>
		<artifactId>ant-trax</artifactId>
		<version>1.8.0</version>
	      </dependency>
	      <dependency>
		<groupId>org.apache.ant</groupId>
		<artifactId>ant-commons-net</artifactId>
		<version>1.8.2</version>
	      </dependency>
	      <dependency>
		<groupId>org.apache.ant</groupId>
		<artifactId>ant-apache-regexp</artifactId>
		<version>1.8.2</version>
	      </dependency>
	      <dependency>
		<groupId>ant-contrib</groupId>
		<artifactId>ant-contrib</artifactId>
		<version>1.0b3</version>
	      </dependency>
	    </dependencies>

	  </plugin>
	</plugins>

      </build>
    </profile>
  </profiles>

</project>
