<?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>

    <parent>
        <groupId>net.shibboleth.idp</groupId>
        <artifactId>idp-parent</artifactId>
        <version>3.0.0-alpha2</version>
        <relativePath>../idp-parent</relativePath>
    </parent>

    <name>Shibboleth IdP :: Distribution</name>
    <artifactId>idp-distribution</artifactId>
    <packaging>pom</packaging>

    <properties>
        <assembly-directory>${project.build.directory}/${project.build.finalName}</assembly-directory>
        <jetty9-dta-ssl.version>1.0.0</jetty9-dta-ssl.version>
    </properties>

    <dependencies>
        <!-- Compile Dependencies -->

        <!-- Provided Dependencies -->

        <!-- Runtime Dependencies -->
        <!-- Required if using classes with command line support. -->
        <dependency>
            <groupId>com.beust</groupId>
            <artifactId>jcommander</artifactId>
            <optional>true</optional>
            <scope>runtime</scope>
        </dependency>
        <!-- Required if you're using classes from the security package. -->
        <dependency>
            <!-- Required if you're using classes from the security package. -->
            <groupId>org.bouncycastle</groupId>
            <artifactId>bcpkix-jdk15on</artifactId>
            <optional>true</optional>
            <scope>runtime</scope>
        </dependency>

        <!-- Test Dependencies -->

        <!-- Managed Dependencies -->
    </dependencies>

    <build>
        <plugins>
            <!-- Copy src/main/resources to assembly directory. -->
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-resources</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <includeEmptyDirs>true</includeEmptyDirs>
                             <outputDirectory>${assembly-directory}</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${basedir}/src/main/resources</directory>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <!-- Unpack idp-war to assembly directory. -->
                    <execution>
                        <id>copy-idp-war</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>${project.groupId}</groupId>
                                    <artifactId>idp-war</artifactId>
                                    <version>${project.version}</version>
                                    <type>war</type>
                                    <outputDirectory>${assembly-directory}/war/</outputDirectory>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                    <!-- Unpack idp-conf to assembly directory. -->
                    <execution>
                        <id>unpack-idp-conf</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>${project.groupId}</groupId>
                                    <artifactId>idp-conf</artifactId>
                                    <version>${project.version}</version>
                                    <type>jar</type>
                                    <outputDirectory>${assembly-directory}</outputDirectory>
                                    <excludes>**/META-INF/**,**/logs/*,**/creds/*</excludes>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                    <!-- Copy Jetty DTA plugin to jetty-base/lib/ext directory. -->
                    <execution>
                        <id>copy-jetty-dta-ssl</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>net.shibboleth.utilities.jetty9</groupId>
                                    <artifactId>jetty9-dta-ssl</artifactId>
                                    <version>${jetty9-dta-ssl.version}</version>
                                    <type>jar</type>
                                    <overWrite>false</overWrite>
                                    <outputDirectory>${assembly-directory}/jetty-base/lib/ext</outputDirectory>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                    <!-- Copy runtime dependencies to bin/lib directory. -->
                    <execution>
                        <id>copy-runtime-dependencies</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>com.beust</groupId>
                                    <artifactId>jcommander</artifactId>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>org.bouncycastle</groupId>
                                    <artifactId>bcpkix-jdk15on</artifactId>
                                </artifactItem>
                            </artifactItems>
                            <outputDirectory>${assembly-directory}/bin/lib/</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!-- Replace antrun plugin with something else ? -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.7</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <target>
                                <!-- Make files in bin executable. -->
                                <chmod dir="${assembly-directory}/bin" perm="755" includes="**/*.sh" />
                            </target>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!-- Assemble. -->
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <appendAssemblyId>false</appendAssemblyId>
                    <descriptors>
                        <descriptor>src/main/assembly/idp-assembly.xml</descriptor>
                    </descriptors>
                    <tarLongFileMode>gnu</tarLongFileMode>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>