<?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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <name>Tycho Distribution</name>

  <parent>
    <artifactId>tycho</artifactId>
    <groupId>org.codehaus.tycho</groupId>
    <version>0.3.0-SNAPSHOT-1271</version>
  </parent>

  <artifactId>tycho-distribution</artifactId>

  <dependencies>
    <dependency>
      <groupId>org.codehaus.tycho</groupId>
      <artifactId>tycho-osgi-components</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.eclipse</groupId>
      <artifactId>org.eclipse.osgi</artifactId>
    </dependency>

    <dependency>
      <groupId>org.codehaus.tycho</groupId>
      <artifactId>maven-osgi-compiler-plugin</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.tycho</groupId>
      <artifactId>maven-osgi-lifecycle-plugin</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.tycho</groupId>
      <artifactId>maven-osgi-packaging-plugin</artifactId>
      <version>${project.version}</version>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>copy</id>
            <configuration>
              <outputAbsoluteArtifactFilename>true</outputAbsoluteArtifactFilename>
              <artifactItems>
                <artifactItem>
                  <groupId>org.apache.maven</groupId>
                  <artifactId>maven-distribution</artifactId>
                  <version>${maven-version}</version>
                  <classifier>bin</classifier>
                  <type>tar.gz</type>
                </artifactItem>
              </artifactItems>
            </configuration>
            <phase>process-sources</phase>
            <goals>
              <goal>unpack</goal>
            </goals>
          </execution>
          <execution>
            <id>copy-wagon</id>
            <configuration>
              <outputAbsoluteArtifactFilename>true</outputAbsoluteArtifactFilename>
              <artifactItems>
                <artifactItem>
                  <groupId>org.apache.maven.wagon</groupId>
                  <artifactId>wagon-provider-api</artifactId>
                  <version>1.0-beta-3-sonatype</version>
                </artifactItem>
                <artifactItem>
                  <groupId>org.apache.maven.wagon</groupId>
                  <artifactId>wagon-file</artifactId>
                  <version>1.0-beta-3-sonatype</version>
                </artifactItem>
                <artifactItem>
                  <groupId>org.apache.maven.wagon</groupId>
                  <artifactId>wagon-http-shared</artifactId>
                  <version>1.0-beta-3-sonatype</version>
                </artifactItem>
                <artifactItem>
                  <groupId>org.apache.maven.wagon</groupId>
                  <artifactId>wagon-http-lightweight</artifactId>
                  <version>1.0-beta-3-sonatype</version>
                </artifactItem>
                <artifactItem>
                  <groupId>org.apache.maven.wagon</groupId>
                  <artifactId>wagon-ssh</artifactId>
                  <version>1.0-beta-3-sonatype</version>
                </artifactItem>
                <artifactItem>
                  <groupId>org.apache.maven.wagon</groupId>
                  <artifactId>wagon-ssh-common</artifactId>
                  <version>1.0-beta-3-sonatype</version>
                </artifactItem>
                <artifactItem>
                  <groupId>org.apache.maven.wagon</groupId>
                  <artifactId>wagon-ssh-external</artifactId>
                  <version>1.0-beta-3-sonatype</version>
                </artifactItem>
              </artifactItems>
            </configuration>
            <phase>process-sources</phase>
            <goals>
              <goal>copy</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <id>default</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <executions>
              <execution>
                <id>create-distro</id>
                <phase>process-sources</phase>
                <goals>
                  <goal>directory-single</goal>
                </goals>
                <configuration>
                  <attach>false</attach>
                  <descriptor>src/main/assembly/bin.xml</descriptor>
                  <outputDirectory>target</outputDirectory>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>       
      </build>
    </profile>
  
    <!-- 
      It is not possible to deploy attached artifacts using maven 3.0 due to 
      MARTIFACT-6. As a workaround, do not assemble anything when running
      under tycho. Instead, run this module alone using maven 2.0.9
      with -Pdeploy profile.
     -->
    <profile>
      <id>osgi</id>
      <activation>
        <property>
          <name>tycho-version</name>
        </property>
      </activation>
    </profile>


    <profile>
      <id>deploy</id>
      <dependencies>
        <dependency>
          <!-- this dependency is built/deployed manually atm -->
          <groupId>org.codehaus.tycho</groupId>
          <artifactId>tycho-p2-runtime</artifactId>
          <version>${tycho-p2-runtime-version}</version>
          <type>zip</type>
        </dependency>
        <dependency>
          <groupId>org.codehaus.tycho</groupId>
          <artifactId>tycho-p2-app</artifactId>
          <version>${project.version}</version>
        </dependency>
      </dependencies>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
              <execution>
                <id>copy-osgi</id>
                <configuration>
                  <outputAbsoluteArtifactFilename>true</outputAbsoluteArtifactFilename>
                  <artifactItems>
                    <artifactItem>
                      <groupId>org.codehaus.tycho</groupId>
                      <artifactId>tycho-p2-runtime</artifactId>
                      <version>${tycho-p2-runtime-version}</version>
                      <type>zip</type>
                    </artifactItem>
                  </artifactItems>
                </configuration>
                <phase>process-sources</phase>
                <goals>
                  <goal>unpack</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <executions>
              <execution>
                <id>create-distro</id>
                <phase>process-sources</phase>
                <goals>
                  <goal>single</goal>
                </goals>
                <configuration>
                  <descriptor>src/main/assembly/osgi-bin.xml</descriptor>
                  <outputDirectory>target</outputDirectory>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
