<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ The MIT License
  ~
  ~ Copyright 2006-2012 The Codehaus.
  ~
  ~ Permission is hereby granted, free of charge, to any person obtaining a copy of
  ~ this software and associated documentation files (the "Software"), to deal in
  ~ the Software without restriction, including without limitation the rights to
  ~ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  ~ of the Software, and to permit persons to whom the Software is furnished to do
  ~ so, subject to the following conditions:
  ~
  ~ The above copyright notice and this permission notice shall be included in all
  ~ copies or substantial portions of the Software.
  ~
  ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  ~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  ~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  ~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  ~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  ~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  ~ SOFTWARE.
  -->

<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>
    <artifactId>appassembler</artifactId>
    <groupId>org.codehaus.mojo.appassembler</groupId>
    <version>1.3</version>
  </parent>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>appassembler-maven-plugin</artifactId>
  <packaging>maven-plugin</packaging>
  <name>Appassembler :: Maven Plug-In</name>
  <description>A Mojo for generating bin scripts for Java applications.</description>

  <properties>
    <its>*</its>
    <threadCount>2</threadCount>
    <maven.version>2.0.10</maven.version>
  </properties>

  <prerequisites>
    <maven>${maven.version}</maven>
  </prerequisites>

  <contributors>
    <contributor>
      <name>Michael Osipov</name>
    </contributor>
    <contributor>
      <name>Philip Oliver-Paull</name>
    </contributor>
    <contributor>
      <name>Mathieu Champlon</name>
    </contributor>
    <contributor>
      <name>Andreas Kohn</name>
    </contributor>
  </contributors>
  <dependencies>
    <dependency>
      <groupId>org.codehaus.mojo.appassembler</groupId>
      <artifactId>appassembler-model</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.plexus</groupId>
      <artifactId>plexus-utils</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.maven</groupId>
      <artifactId>maven-plugin-api</artifactId>
      <version>2.0</version>
    </dependency>
    <dependency>
      <groupId>org.apache.maven</groupId>
      <artifactId>maven-project</artifactId>
      <version>${maven.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.maven</groupId>
      <artifactId>maven-artifact</artifactId>
      <version>${maven.version}</version>
    </dependency>
    <dependency>
      <groupId>stax</groupId>
      <artifactId>stax-api</artifactId>
    </dependency>
    <dependency>
      <groupId>org.codehaus.plexus</groupId>
      <artifactId>plexus-container-default</artifactId>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.maven</groupId>
      <artifactId>maven-settings</artifactId>
      <version>${maven.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.maven</groupId>
      <artifactId>maven-model</artifactId>
      <version>${maven.version}</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.plexus</groupId>
        <artifactId>plexus-maven-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>descriptor</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <!-- Here, we download the wrapper bundle and incorporate into the plugin directly -->
      <!-- TODO: improve by doing this dynamically in the plugin so that non-JSW users aren't burdened by the size of the plugin, and so the user can choose an alternate version -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>2.0</version>
        <executions>
          <execution>
            <phase>generate-resources</phase>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>tanukisoft</groupId>
                  <artifactId>wrapper-delta-pack</artifactId>
                  <version>3.2.3</version>
                  <type>tar.gz</type>
                </artifactItem>
                <artifactItem>
                  <groupId>org.sonatype.jsw-binaries</groupId>
                  <artifactId>jsw-binaries</artifactId>
                  <version>3.2.3.6</version>
                  <type>tar.gz</type>
                  <outputDirectory>${project.build.directory}/dependency/sonatype-jsw-binaries</outputDirectory>
                </artifactItem>
                <artifactItem>
                  <groupId>org.apache.karaf.shell</groupId>
                  <artifactId>org.apache.karaf.shell.wrapper</artifactId>
                  <version>2.2.7</version>
                  <type>jar</type>
                  <outputDirectory>${project.build.directory}/dependency/karaf-jsw-binaries</outputDirectory>
                </artifactItem>
              </artifactItems>
            </configuration>
            <goals>
              <goal>unpack</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <version>1.7</version>
        <executions>
          <execution>
            <phase>generate-resources</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <target>
              
                <copy file="${project.build.directory}/dependency/sonatype-jsw-binaries/windows-x86-64/lib/wrapper.dll" tofile="${project.build.directory}/dependency/wrapper-delta-pack-3.2.3/lib/wrapper-windows-x86-64.dll" />
                <copy file="${project.build.directory}/dependency/sonatype-jsw-binaries/windows-x86-64/wrapper.exe" tofile="${project.build.directory}/dependency/wrapper-delta-pack-3.2.3/bin/wrapper-windows-x86-64.exe" />
                  
                <copy file="${project.build.directory}/dependency/sonatype-jsw-binaries/macosx-universal-64/lib/libwrapper.jnilib" tofile="${project.build.directory}/dependency/wrapper-delta-pack-3.2.3/lib/libwrapper-macosx-universal-64.jnilib" />
                <copy file="${project.build.directory}/dependency/sonatype-jsw-binaries/macosx-universal-64/wrapper" tofile="${project.build.directory}/dependency/wrapper-delta-pack-3.2.3/bin/wrapper-macosx-universal-64" />

                <copy file="${project.build.directory}/dependency/karaf-jsw-binaries/org/apache/karaf/shell/wrapper/aix/ppc32/libwrapper.a" tofile="${project.build.directory}/dependency/wrapper-delta-pack-3.2.3/lib/libwrapper-aix-ppc-32.a" />
                <copy file="${project.build.directory}/dependency/karaf-jsw-binaries/org/apache/karaf/shell/wrapper/aix/ppc32/karaf-wrapper" tofile="${project.build.directory}/dependency/wrapper-delta-pack-3.2.3/bin/wrapper-aix-ppc-32" />

                <copy file="${project.build.directory}/dependency/karaf-jsw-binaries/org/apache/karaf/shell/wrapper/aix/ppc64/libwrapper.a" tofile="${project.build.directory}/dependency/wrapper-delta-pack-3.2.3/lib/libwrapper-aix-ppc-64.a" />
                <copy file="${project.build.directory}/dependency/karaf-jsw-binaries/org/apache/karaf/shell/wrapper/aix/ppc64/karaf-wrapper" tofile="${project.build.directory}/dependency/wrapper-delta-pack-3.2.3/bin/wrapper-aix-ppc-64" />

                <copy file="${project.build.directory}/dependency/karaf-jsw-binaries/org/apache/karaf/shell/wrapper/hpux/parisc64/libwrapper.sl" tofile="${project.build.directory}/dependency/wrapper-delta-pack-3.2.3/lib/libwrapper-hpux-parisc-64.sl" />
                <copy file="${project.build.directory}/dependency/karaf-jsw-binaries/org/apache/karaf/shell/wrapper/hpux/parisc64/karaf-wrapper" tofile="${project.build.directory}/dependency/wrapper-delta-pack-3.2.3/bin/wrapper-hpux-parisc-64" />
                  
              </target>
            </configuration>
          </execution>
        </executions>
      </plugin>
      
    </plugins>
    <resources>
      <resource>
        <directory>target/dependency/wrapper-delta-pack-3.2.3/src/conf</directory>
        <targetPath>org/codehaus/mojo/appassembler/daemon/jsw/conf</targetPath>
      </resource>
      <resource>
        <directory>src/main/patches</directory>
        <targetPath>org/codehaus/mojo/appassembler/daemon/jsw/bin</targetPath>
        <includes>
          <include>sh.script.in</include>
          <include>AppCommand.bat.in</include>
        </includes>
      </resource>
      <!-- TODO: Have the plugin copy these in (depending on platforms) -->
      <resource>
        <directory>target/dependency/wrapper-delta-pack-3.2.3/lib</directory>
        <targetPath>org/codehaus/mojo/appassembler/daemon/jsw/lib</targetPath>
        <includes>
          <include>wrapper.jar</include>
          <include>wrapper-*.dll</include>
          <include>libwrapper-*</include>
        </includes>
      </resource>
      <!-- TODO: Have the plugin copy these in (depending on platforms) -->
      <resource>
        <directory>target/dependency/wrapper-delta-pack-3.2.3/bin</directory>
        <targetPath>org/codehaus/mojo/appassembler/daemon/jsw/bin</targetPath>
        <includes>
          <include>wrapper-*</include>
        </includes>
      </resource>
      <resource>
        <directory>src/main/resources</directory>
      </resource>
    </resources>
  </build>
  <profiles>
    <profile>
      <id>run-its</id>
      <dependencies>
        <!--
             This is given as dependencies, cause some integration tests use this artifact. But i don't want
             to add this as an default dependencies, cause all users will download it with the appassembler-maven-plugin
             independent if they use it or not.
        -->
        <dependency>
          <groupId>org.codehaus.mojo.appassembler</groupId>
          <artifactId>appassembler-booter</artifactId>
          <version>${project.version}</version>
        </dependency>
      </dependencies>
      <build>
        <plugins>
          <plugin>
            <groupId>org.codehaus.gmaven</groupId>
            <artifactId>gmaven-plugin</artifactId>
            <version>1.3</version>
            <dependencies>
              <dependency>
                <groupId>org.codehaus.groovy</groupId>
                <artifactId>groovy</artifactId>
                <version>1.8.4</version>
              </dependency>
              <dependency>
                <groupId>org.codehaus.gmaven.runtime</groupId>
                <artifactId>gmaven-runtime-1.8</artifactId>
                <version>1.4</version>
              </dependency>
            </dependencies>
            <configuration>
              <debug>false</debug>
              <verbose>true</verbose>
              <stacktrace>true</stacktrace>
              <defaultScriptExtension>.groovy</defaultScriptExtension>
            </configuration>
            <executions>
              <execution>
                <goals>
                  <goal>testCompile</goal>
                </goals>
              </execution>
            </executions>
          </plugin>

          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-invoker-plugin</artifactId>
            <version>1.6</version>
            <dependencies>
              <dependency>
                <groupId>org.codehaus.groovy</groupId>
                <artifactId>groovy</artifactId>
                <version>1.8.4</version>
              </dependency>
              <dependency>
                <groupId>org.codehaus.gmaven.runtime</groupId>
                <artifactId>gmaven-runtime-1.8</artifactId>
                <version>1.4</version>
              </dependency>
            </dependencies>
            <configuration>
              <parallelThreads>1</parallelThreads>
              <addTestClassPath>true</addTestClassPath>
              <debug>false</debug>
              <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
              <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
              <projectsDirectory>src/it</projectsDirectory>
              <showVersion>true</showVersion>
              <pomIncludes>
                <pomInclude>*/pom.xml</pomInclude>
              </pomIncludes>
              <pomExcludes>
                <!--  Currently not correctly working. -->
                <pomExclude>daemonWrapperManagerTest/pom.xml</pomExclude>
                <pomExclude>daemonRepositoryLayoutTest/pom.xml</pomExclude>
                <!-- this test, use snapshot artifact and therefore requires manual inspection -->
                <pomExclude>useTimestampInSnapshotFileNameTest/pom.xml</pomExclude>
              </pomExcludes>
              <preBuildHookScript>setup</preBuildHookScript>
              <postBuildHookScript>verify</postBuildHookScript>
              <settingsFile>src/it/settings.xml</settingsFile>
            </configuration>
            <executions>
              <execution>
                <id>integration-tests</id>
                <goals>
                  <goal>install</goal>
                  <goal>run</goal>
                </goals>
                <configuration>
                  <goals>
                    <goal>clean</goal>
                    <goal>test</goal>
                  </goals>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
      <reporting>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-invoker-plugin</artifactId>
            <version>1.6</version>
          </plugin>
        </plugins>
      </reporting>
    </profile>

    <profile>
      <id>grid</id>
      <properties>
        <invokerPluginVersion>1.6-SNAPSHOT</invokerPluginVersion>
        <itParallelThreads>1</itParallelThreads>
      </properties>
      <pluginRepositories>
        <pluginRepository>
          <id>apache.snapshots</id>
          <name>Apache Snapshots</name>
          <url>https://repository.apache.org/content/repositories/snapshots/</url>
          <releases>
            <enabled>false</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
        </pluginRepository>
      </pluginRepositories>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-invoker-plugin</artifactId>
            <version>${invokerPluginVersion}</version>
            <configuration>
              <parallelThreads>${itParallelThreads}</parallelThreads>
            </configuration>
          </plugin>
          <plugin>
            <artifactId>maven-enforcer-plugin</artifactId>
            <version>1.0</version>
            <executions>
              <execution>
                <id>mojo-enforcer-rules</id>
                <phase>verify</phase>
                <goals>
                  <goal>enforce</goal>
                </goals>
                <configuration>
                  <rules>
                    <requirePluginVersions>
                       <banSnapshots>false</banSnapshots>
                       <!--
                       oups documentation sucks !!
                       http://maven.apache.org/enforcer/enforcer-rules/requirePluginVersions.html
                       log says
                       Cause: Cannot find setter nor field in org.apache.maven.plugins.enforcer.RequirePluginVersions for 'unCheckedPluginsList'

                       <unCheckedPluginsList>org.apache.maven.plugins:maven-invoker-plugin</unCheckedPluginsList>
                        -->
                    </requirePluginVersions>
                  </rules>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

  </profiles>

</project>
