<?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">
    <parent>
        <artifactId>weld-servlet-parent</artifactId>
        <groupId>org.jboss.weld.servlet</groupId>
        <version>2.3.3.Final</version>
        <relativePath>../../pom.xml</relativePath>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <artifactId>weld-servlet-test-jetty</artifactId>
    <packaging>jar</packaging>
    <name>Weld Servlet Integration Tests (Jetty)</name>

    <dependencies>

        <dependency>
            <groupId>org.jboss.spec.javax.ejb</groupId>
            <artifactId>jboss-ejb-api_3.2_spec</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>commons-httpclient</groupId>
            <artifactId>commons-httpclient</artifactId>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
        </dependency>

        <dependency>
            <groupId>org.jboss.arquillian.junit</groupId>
            <artifactId>arquillian-junit-container</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.jboss.weld.servlet</groupId>
            <artifactId>weld-servlet-test-base</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.jboss.spec.javax.faces</groupId>
            <artifactId>jboss-jsf-api_2.2_spec</artifactId>
        </dependency>

        <dependency>
            <groupId>com.sun.faces</groupId>
            <artifactId>jsf-impl</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <build>
        <defaultGoal>test</defaultGoal>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-report-plugin</artifactId>
                <executions>
                    <execution>
                        <id>generate-test-report</id>
                        <phase>test</phase>
                        <goals>
                            <goal>report-only</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <outputDirectory>${project.build.directory}/surefire-reports</outputDirectory>
                    <outputName>test-report</outputName>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <!--
                       Set parallel none to force a more modern JUnitCore
                       provider that understands Suites,
                       http://old.nabble.com/Maven-Surefire-and-newer-junit-features-td28539796.html
                    -->
                    <parallel>none</parallel>
                    <!-- https://issues.apache.org/jira/browse/SUREFIRE-569 -->
                    <dependenciesToScan>
                        <dependency>org.jboss.weld.servlet:weld-servlet-test-base</dependency>
                    </dependenciesToScan>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>default</id>
            <activation>
                <property>
                    <name>!incontainer</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <!-- Skip the tests by default, they are all "incontainer" -->
                            <skipTests>true</skipTests>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>incontainer</id>
            <activation>
                <property>
                    <name>incontainer</name>
                    <value>true</value>
                </property>
            </activation>
            <dependencies>

                <!-- plus and naming requires for using JNDI -->
                <dependency>
                    <groupId>org.eclipse.jetty</groupId>
                    <artifactId>jetty-plus</artifactId>
                    <scope>test</scope>
                </dependency>

                <dependency>
                    <groupId>org.eclipse.jetty</groupId>
                    <artifactId>jetty-jndi</artifactId>
                    <scope>test</scope>
                </dependency>

                <dependency>
                    <groupId>org.eclipse.jetty</groupId>
                    <artifactId>jetty-webapp</artifactId>
                    <scope>test</scope>
                </dependency>

                <dependency>
                    <groupId>org.eclipse.jetty</groupId>
                    <artifactId>jetty-annotations</artifactId>
                    <scope>test</scope>
                </dependency>

                <!-- Weld servlet, EL and JSP required for testing CDI injections -->
                <dependency>
                    <groupId>org.jboss.weld</groupId>
                    <artifactId>weld-core-impl</artifactId>
                    <scope>test</scope>
                </dependency>

                <dependency>
                    <groupId>org.jboss.weld</groupId>
                    <artifactId>weld-core-jsf</artifactId>
                    <scope>test</scope>
                </dependency>

                <dependency>
                    <groupId>org.jboss.weld.servlet</groupId>
                    <artifactId>weld-servlet-core</artifactId>
                    <scope>test</scope>
                </dependency>

                <dependency>
                    <groupId>org.glassfish.web</groupId>
                    <artifactId>el-impl</artifactId>
                    <scope>test</scope>
                </dependency>

                <dependency>
                    <groupId>javax.servlet.jsp</groupId>
                    <artifactId>jsp-api</artifactId>
                    <scope>test</scope>
                </dependency>

            </dependencies>

        </profile>
        <profile>

            <id>jetty-embedded-7</id>

            <activation>
                <property>
                    <name>jetty-embedded-7</name>
                </property>
            </activation>

            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <excludes>
                                <!-- Listener injection should work on Jetty 9.1.1+ -->
                                <exclude>**/ListenerInjectionTest.java</exclude>
                            </excludes>
                        </configuration>
                    </plugin>
                </plugins>
            </build>

            <dependencies>
                <dependency>
                    <groupId>org.jboss.arquillian.container</groupId>
                    <artifactId>arquillian-jetty-embedded-7</artifactId>
                    <scope>test</scope>
                </dependency>
            </dependencies>

        </profile>
        <profile>

             <id>jetty-embedded-9</id>

            <activation>
                <property>
                    <name>!jetty-embedded-7</name>
                </property>
            </activation>

            <properties>
                <jetty.version>${jetty9.version}</jetty.version>
            </properties>

            <dependencies>
                <dependency>
                    <groupId>org.jboss.arquillian.container</groupId>
                    <artifactId>arquillian-jetty-embedded-9</artifactId>
                    <scope>test</scope>
                </dependency>
            </dependencies>

        </profile>

        <profile>
            <!-- This profile tests weld-se and weld-servlet cooperation -->
            <!-- weld-se bootstraps the container and weld-servlet is reusing the existing BeanManager -->
            <!-- See also WELD-1665 -->
            <id>weld-se-coop</id>

            <activation>
                <activeByDefault>false</activeByDefault>
                <property>
                    <name>incontainer</name>
                    <value>weld-se-coop</value>
                </property>
            </activation>

            <properties>
                <test.src.dir>src/test/weld-se-coop</test.src.dir>
            </properties>

            <dependencies>

                <dependency>
                    <groupId>org.jboss.weld.servlet</groupId>
                    <artifactId>weld-servlet-core</artifactId>
                    <scope>test</scope>
                </dependency>

                <dependency>
                    <groupId>org.jboss.weld.se</groupId>
                    <artifactId>weld-se-core</artifactId>
                    <scope>test</scope>
                </dependency>

                <dependency>
                    <groupId>javax.servlet.jsp</groupId>
                    <artifactId>jsp-api</artifactId>
                    <scope>test</scope>
                </dependency>

            </dependencies>

            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>build-helper-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>add-test-resource</id>
                                <phase>generate-test-resources</phase>
                                <goals>
                                    <goal>add-test-resource</goal>
                                </goals>
                                <configuration>
                                   <resources>
                                        <resource>
                                            <directory>src/test/weld-se-coop-resources</directory>
                                        </resource>
                                   </resources>
                                </configuration>
                            </execution>
                            <execution>
                                <id>add-test-source</id>
                                <phase>generate-test-sources</phase>
                                <goals>
                                    <goal>add-test-source</goal>
                                </goals>
                                <configuration>
                                <sources>
                                  <source>${test.src.dir}</source>
                                </sources>
                              </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <excludes>
                                <exclude>%regex[.*servlet/test/(?!se).*]</exclude>
                            </excludes>
                        </configuration>
                    </plugin>
                </plugins>
            </build>

        </profile>

    </profiles>

</project>
