<?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.plugin.jetty-base</groupId>
        <artifactId>jetty-base-plugin-parent</artifactId>
        <version>1.0.1-SNAPSHOT</version>
    </parent>

    <name>Jettty: Plugin and Module implementation </name>
    <description>
        Project with the code for the Jetty plugin.
        Also constructs a zip and tarball of jetty-base.
    </description>
    <artifactId>jetty-base-plugin-impl</artifactId>
    <packaging>jar</packaging>

    <properties>
        <automatic.module.name>net.shibboleth.idp.plugin.jetty</automatic.module.name>
        <assemblyDirectory>${project.build.directory}/jetty-base</assemblyDirectory>
    </properties>

    <dependencies>
        <!-- Provided Dependencies needed to build the plugin and module -->
        <dependency>
            <groupId>${idp.groupId}</groupId>
            <artifactId>idp-admin-impl</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>${shib-shared.groupId}</groupId>
            <artifactId>shib-security</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>${idp.groupId}</groupId>
            <artifactId>idp-installer</artifactId>
            <version>${idp.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>${shib-profile.groupId}</groupId>
            <artifactId>shib-profile-api</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>${slf4j.groupId}</groupId>
            <artifactId>slf4j-api</artifactId>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <!-- Unpack jetty-base into our classes tree -->
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>unpack-jettybase</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>net.shibboleth.idp</groupId>
                                    <artifactId>idp-jetty-base</artifactId>
                                    <type>jar</type>
                                    <version>${jetty-base.version}</version>
                                    <outputDirectory>${project.build.outputDirectory}/</outputDirectory>
                                    <overWrite>true</overWrite>
                                    <!-- We only want the net/shibboleth/idp/.... bit and NOT META-INF -->
                                    <includes>**/shibboleth/**</includes>
                                    <fileMappers>
                                        <org.codehaus.plexus.components.io.filemappers.RegExpFileMapper>
                                            <pattern>jetty-base</pattern>
                                            <replacement>jetty-base-12</replacement>
                                        </org.codehaus.plexus.components.io.filemappers.RegExpFileMapper>
                                    </fileMappers>
                                </artifactItem>
                                <!-- How to do a different jetty-base version
                                     Also: Add files to n.s.i.module.jetty/module.properties
                                <artifactItem>
                                    <groupId>net.shibboleth.idp</groupId>
                                    <artifactId>idp-jetty-base</artifactId>
                                    <type>jar</type>
                                    <version>11.0.0</version>
                                    <outputDirectory>${project.build.outputDirectory}/</outputDirectory>
                                    <overWrite>true</overWrite>
                                    <includes>**/shibboleth/**</includes>
                                    <fileMappers>
                                        <org.codehaus.plexus.components.io.filemappers.RegExpFileMapper>
                                             <pattern>jetty-base</pattern>
                                             <replacement>jetty-base-11</replacement>
                                         </org.codehaus.plexus.components.io.filemappers.RegExpFileMapper>
                                    </fileMappers>
                                </artifactItem>
                                -->
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>3.1.0</version>
                <executions>
                    <execution>
                        <!-- Copy CLI jar into the target, giving it a non changing name -->
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <target>
                                <copy
                                    file="${project.basedir}/../jetty-cli/target/jetty-base-plugin-cli-${project.version}.jar"
                                    tofile="${project.build.outputDirectory}/net/shibboleth/idp/module/jetty/jetty-cli.jar"/>
                            </target>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>
