<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">
    <!--

        Licensed to the Apache Software Foundation (ASF) under one or more
        contributor license agreements. See the NOTICE file distributed with
        this work for additional information regarding copyright ownership.
        The ASF licenses this file to You under the Apache License, Version
        2.0 (the "License"); you may not use this file except in compliance
        with the License. You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0 Unless required by
        applicable law or agreed to in writing, software distributed under the
        License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
        CONDITIONS OF ANY KIND, either express or implied. See the License for
        the specific language governing permissions and limitations under the
        License.
    -->

    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.apache.openwebbeans</groupId>
        <artifactId>openwebbeans</artifactId>
        <version>@project.version@</version>
    </parent>

    <groupId>org.apache.openwebbeans.it</groupId>
    <artifactId>openwebbeans-jetty9-it-servletinjection</artifactId>
    <version>@project.version@</version>
    <packaging>war</packaging>
    <name>Jetty 9 plugin IT</name>

    <properties>
        <jetty.port.it>9082</jetty.port.it>
        <jstl.version>1.2</jstl.version>
        <projectStage>Development</projectStage>
    </properties>


    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>${httpclient.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>jakarta.enterprise</groupId>
            <artifactId>jakarta.enterprise.cdi-api</artifactId>
        </dependency>

        <dependency>
            <groupId>jakarta.inject</groupId>
            <artifactId>jakarta.inject-api</artifactId>
        </dependency>

        <dependency>
            <groupId>org.apache.geronimo.specs</groupId>
            <artifactId>geronimo-servlet_3.0_spec</artifactId>
            <version>1.0</version>
            <scope>provided</scope>
        </dependency>

    </dependencies>

    <build>
        <finalName>owbjetty9it</finalName>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.eclipse.jetty</groupId>
                    <artifactId>jetty-maven-plugin</artifactId>
                    <version>@jettyVersion@</version>
                </plugin>
            </plugins>
        </pluginManagement>

        <plugins>
            <plugin>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>3.1.1</version>
                <executions>
                    <execution>
                        <id>jetty-distribution</id>
                        <phase>generate-test-resources</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.eclipse.jetty</groupId>
                                    <artifactId>jetty-distribution</artifactId>
                                    <version>@jettyVersion@</version>
                                    <type>zip</type>
                                    <overWrite>false</overWrite>
                                    <outputDirectory>${project.build.directory}</outputDirectory>
                                    <excludes>*/demo-base/**</excludes>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>@project.groupId@</groupId>
                                    <artifactId>@project.artifactId@</artifactId>
                                    <version>@project.version@</version>
                                    <type>jar</type>
                                    <classifier>config</classifier>
                                    <overWrite>true</overWrite>
                                    <outputDirectory>${project.build.directory}/jetty-distribution-@jettyVersion@</outputDirectory>
                                    <excludes>META-INF/**</excludes>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-jetty.base</id>
                        <phase>process-test-resources</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/jetty-template</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${project.build.directory}/jetty-distribution-@jettyVersion@</directory>
                                    <includes>start.jar</includes>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.6.0</version>
                <executions>
                    <execution>
                        <id>enable-module</id>
                        <phase>process-test-resources</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>java</executable>
                            <arguments>
                                <argument>-jar</argument>
                                <argument>${project.build.directory}/jetty-distribution-@jettyVersion@/start.jar</argument>
                                <argument>--create-startd</argument>
                                <argument>--create-files</argument>
                                <argument>--add-to-start=plus</argument>
                                <argument>--add-to-start=apache-jsp</argument>
                                <argument>--add-to-start=apache-jstl</argument>
                                <argument>--add-to-start=apache-owb</argument>
                                <argument>maven.local.repo=@local.repository.path@</argument>
                                <argument>maven.repo.uri=@repository.proxy.url@/</argument>
                                <argument>--approve-all-licenses</argument>
                                <argument>jetty.home=${project.build.directory}/jetty-distribution-@jettyVersion@</argument>
                                <argument>jetty.base=${project.build.directory}/jetty-template</argument>
                            </arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>2.11</version>
                <executions>
                    <execution>
                        <id>integration-test</id>
                        <goals>
                            <goal>integration-test</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>verify</id>
                        <goals>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                <configuration>
                    <webApp>
                        <contextPath>/${project.build.finalName}</contextPath>
                    </webApp>
                    <jvmArgs>-Dorg.apache.myfaces.PROJECT_STAGE=${projectStage} -Dfaces.PROJECT_STAGE=${projectStage}</jvmArgs>
                    <waitForChild>false</waitForChild>
                    <stopKey>foo</stopKey>
                    <stopPort>9999</stopPort>
                    <jettyBase>${project.build.directory}/jetty-template</jettyBase>
                    <jettyHome>${project.build.directory}/jetty-distribution-@jettyVersion@</jettyHome>
                    <jettyProperties>
                        <jettyProperty>jetty.http.port=${jetty.port.it}</jettyProperty>
                        <jettyProperty>maven.repo.uri=@repository.proxy.url@</jettyProperty>
                        <jettyProperty>maven.local.repo=@local.repository.path@</jettyProperty>
                    </jettyProperties>
                    <maxChildChecks>300</maxChildChecks> <!-- allow up to 30 seconds for jetty distro to start -->
                    <maxChildCheckInterval>100</maxChildCheckInterval>
                    <modules>
                        <module>apache-jsp</module>
                        <module>apache-jstl</module>
                        <module>apache-owb</module>
                    </modules>
                </configuration>
                <executions>
                    <execution>
                        <id>start-jetty</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>run-distro</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>stop-jetty</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>stop</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>


</project>
