<?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>4.2.0</version>
        <relativePath>../idp-parent</relativePath>
    </parent>

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

    <properties>
        <idp.finalName>shibboleth-identity-provider-${project.version}</idp.finalName>
        <idp.assemblyDirectory>${project.build.directory}/${idp.finalName}</idp.assemblyDirectory>
    </properties>

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

        <!-- Provided Dependencies -->

        <!-- Runtime Dependencies -->
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>idp-installer</artifactId>
            <version>${project.version}</version>
        </dependency>

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

        <!--  For the installers -->
        <dependency>
            <groupId>org.bouncycastle</groupId>
            <artifactId>bcpg-jdk15on</artifactId>
            <scope>runtime</scope>
        </dependency>

        <dependency>
          <groupId>org.apache.commons</groupId>
          <artifactId>commons-compress</artifactId>
          <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.ant</groupId>
            <artifactId>ant</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.ant</groupId>
            <artifactId>ant-launcher</artifactId>
            <scope>runtime</scope>
        </dependency>
        <!-- Logging dependencies, per JPAR-57. -->
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-core</artifactId>
            <scope>runtime</scope>
        </dependency>
        
        <!-- Test Dependencies -->

    </dependencies>

    <scm>
        <connection>${shibboleth.scm.connection}java-identity-provider</connection>
        <developerConnection>${shibboleth.scm.developerConnection}java-identity-provider</developerConnection>
        <url>${shibboleth.scm.url}java-identity-provider.git</url>
    </scm>

    <distributionManagement>
        <site>
            <id>site</id>
            <url>scp:${idp-module.site.url}</url>
        </site>
    </distributionManagement>

    <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>${idp.assemblyDirectory}</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-distribution to assembly directory. -->
                    <execution>
                        <id>copy-idp-war-distribution</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>${project.groupId}</groupId>
                                    <artifactId>idp-war-distribution</artifactId>
                                    <version>${project.version}</version>
                                    <type>war</type>
                                    <outputDirectory>${idp.assemblyDirectory}/webapp/</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>${idp.assemblyDirectory}</outputDirectory>
                                    <excludes>**/META-INF/**,**/logs/*,**/credentials/*</excludes>
                                </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>${project.groupId}</groupId>
                                    <artifactId>idp-installer</artifactId>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>com.beust</groupId>
                                    <artifactId>jcommander</artifactId>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>org.bouncycastle</groupId>
                                    <artifactId>bcpg-jdk15on</artifactId>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>org.apache.commons</groupId>
                                    <artifactId>commons-compress</artifactId>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>org.apache.ant</groupId>
                                    <artifactId>ant</artifactId>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>org.apache.ant</groupId>
                                    <artifactId>ant-launcher</artifactId>
                                </artifactItem>
                            </artifactItems>
                            <outputDirectory>${idp.assemblyDirectory}/bin/lib/</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.8</version>
                <executions>
                    <execution>
                        <id>make-files-in-bin-executable</id>
                        <phase>package</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <target>
                                <chmod dir="${idp.assemblyDirectory}/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-tgz.xml</descriptor>
                        <descriptor>src/main/assembly/idp-assembly-zip.xml</descriptor>
                    </descriptors>
                    <finalName>${idp.finalName}</finalName>
                    <tarLongFileMode>gnu</tarLongFileMode>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <dependencies>
                    <dependency>
                        <groupId>net.shibboleth.maven.enforcer.rules</groupId>
                        <artifactId>maven-dist-enforcer</artifactId>
                        <version>${maven-dist-enforcer.version}</version>
                    </dependency>
                </dependencies>
                <executions>
                    <execution>
                        <id>idp-enforce</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <jarEnforcer implementation="net.shibboleth.mvn.enforcer.impl.JarEnforcer">
                                    <dataGroupId>net.shibboleth.maven.enforcer.rules</dataGroupId>
                                    <dataArtifactId>maven-dist-enforcer-data</dataArtifactId>
                                    <dataVersion>${maven-dist-enforcer-data.version}</dataVersion>
                                    <dataKeyRing>${basedir}/../idp-bom/src/main/enforcer/shibbolethKeys.gpg</dataKeyRing>
                                    <parentPomDir>${basedir}/../idp-parent</parentPomDir>
                                    <zipFiles>${project.build.directory}/${idp.finalName}.zip</zipFiles>
                                    <tgzFiles>${project.build.directory}/${idp.finalName}.tar.gz</tgzFiles>
                                    <checkSignatures>true</checkSignatures>
                                    <checkDependencies>true</checkDependencies>
				    <compileRuntimeArtifactFatal>false</compileRuntimeArtifactFatal>
                                    <listJarSources>false</listJarSources>
                                    <checkM2>false</checkM2>
                                </jarEnforcer>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
