<?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>
        <groupId>org.apache.myfaces</groupId>
        <artifactId>myfaces</artifactId>
        <version>9</version>
    </parent>

    <modelVersion>4.0.0</modelVersion>
    <groupId>org.apache.myfaces</groupId>
    <artifactId>test-webapp</artifactId>
    <packaging>war</packaging>
    <version>2.0.0-SNAPSHOT</version>
    <name>Example test webapp to test myfaces 2.0</name>
    <description>
        Example test webapp to test myfaces 2.0. This pom allows to run 
        integrational tests using cargo(tomcat) or jetty and htmlunit,
        and run the demo with trace logging enabled using profile -PjettyConfig.
    </description>
    <url>http://myfaces.apache.org</url>

    <!-- Project dependencies -->
    <dependencies>
        <dependency>
            <groupId>org.apache.myfaces</groupId>
            <artifactId>test-res-jar</artifactId>
            <version>2.0.0-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>jsp-api</artifactId>
            <version>2.1</version>
            <scope>provided</scope>
        </dependency>        
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>javax.annotation</groupId>
            <artifactId>jsr250-api</artifactId>
            <version>1.0</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.7</version>
            <scope>test</scope>
        </dependency>
  
        <dependency>
            <groupId>net.sourceforge.htmlunit</groupId>
            <artifactId>htmlunit</artifactId>
            <version>${htmlunit.version}</version>
            <scope>test</scope>
        </dependency>
        
        <dependency>
            <groupId>net.sourceforge.htmlunit</groupId>
            <artifactId>htmlunit-core-js</artifactId>
            <version>${htmlunit.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
    
        <finalName>test-webapp</finalName>
        <plugins>
            <plugin>
              <artifactId>maven-compiler-plugin</artifactId>
              <configuration>
                <source>1.5</source>
                <target>1.5</target>
              </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.5</version>
                <configuration>
                    <!-- Exclude all integration tests so that they are not executed during the test phase.
                        This is because of a limitation in Maven 2.0.x which only supports compiling a
                        single test source tree. The recommendation is to create a separate module for
                        functional tests as is done in the cargo-archetype-webapp-functional-test-module -->
                    <excludes>
                        <exclude>**/it/**</exclude>
                    </excludes>
                </configuration>
                <executions>
                    <execution>
                        <phase>integration-test</phase>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <configuration>
                            <!-- Do not fork, otherwise, we can't put a breakpoint on the it test class 
                                 Only works for junit 3 test style -->
                            <forkMode>never</forkMode>
                            <!-- Include only integration tests so that they are executed during the
                                integration-test phase. Again this this is because of a limitation in
                                Maven 2.0.x which only supports compiling a single test source tree. The
                                recommendation is to create a separate module for functional tests as is done
                                in the cargo-archetype-webapp-functional-test-module -->
                            <excludes>
                                <exclude>none</exclude>
                            </excludes>
                            <includes>
                                <include>**/it/**</include>
                            </includes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.cargo</groupId>
                <artifactId>cargo-maven2-plugin</artifactId>
                <version>${cargo.version}</version>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <!-- Debug profile for myfaces and jetty.
                It allows to see debug messages using -PjettyConfig -->
            <id>jettyConfig</id>
            <build>
                <resources>
                    <resource>
                        <directory>src/main/resources</directory>
                    </resource>
                    <resource>
                        <directory>src/main/log4j</directory>
                    </resource>
                </resources>
                <plugins>
                    <plugin>
                        <!--This plugin allows to run the example using mvn jetty:run -->
                        <groupId>org.mortbay.jetty</groupId>
                        <artifactId>maven-jetty-plugin</artifactId>
                        <version>${maven.jetty.plugin.version}</version>
                        <configuration>
                            <scanIntervalSeconds>10</scanIntervalSeconds>
                            <systemProperties>
                                <systemProperty>
                                    <name>org.apache.commons.logging.Log</name>
                                    <value>org.apache.commons.logging.impl.Log4JLogger</value>
                                </systemProperty>
                            </systemProperties>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
            <dependencies>
                <dependency>
                    <groupId>log4j</groupId>
                    <artifactId>log4j</artifactId>
                    <version>${log4j.version}</version>
                    <type>jar</type>
                </dependency>
            </dependencies>
        </profile>

        <profile>
            <id>myfaces</id>
            <activation>
                <property>
                    <name>!jsf</name>
                </property>
            </activation>
            <properties>
                <jsfImpl>MyFaces ${jsf-myfaces.version}</jsfImpl>
            </properties>
            <dependencies>
                <dependency>
                    <groupId>org.apache.myfaces.core</groupId>
                    <artifactId>myfaces-api</artifactId>
                    <version>${jsf-myfaces.version}</version>
                    <scope>compile</scope>
                </dependency>
                <dependency>
                    <groupId>org.apache.myfaces.core</groupId>
                    <artifactId>myfaces-impl</artifactId>
                    <version>${jsf-myfaces.version}</version>
                    <scope>compile</scope>
                </dependency>
            </dependencies>
        </profile>
        <profile>
            <id>jsf-ri</id>
            <activation>
                <property>
                    <name>jsf</name>
                    <value>ri</value>
                </property>
            </activation>
            <properties>
                <jsfImpl>Mojarra ${jsf-ri.version}</jsfImpl>
            </properties>
            <dependencies>
                <dependency>
                    <groupId>com.sun.faces</groupId>
                    <artifactId>jsf-api</artifactId>
                    <version>${jsf-ri.version}</version>
                    <scope>compile</scope>
                </dependency>
                <dependency>
                    <groupId>com.sun.faces</groupId>
                    <artifactId>jsf-impl</artifactId>
                    <version>${jsf-ri.version}</version>
                </dependency>
                <dependency>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                    <version>1.1.1</version>
                </dependency>
            </dependencies>
        </profile>
        <!-- Profiles for run automated integration tests -->
        <profile>
            <id>jetty6x</id>
            <activation>
                <property>
                    <name>!it</name>
                </property>            
            </activation>
            <build>
                <plugins>
                    <!-- Unfortunately if we use this profile we can't control
                    which jetty version we use and the version cargo use has
                    a problem with EL libraries. Instead we call directly jetty.                
                    <plugin>
                        <groupId>org.codehaus.cargo</groupId>
                        <artifactId>cargo-maven2-plugin</artifactId>
                        <version>${cargo.version}</version>
                        <configuration>
                            <container>
                                <containerId>jetty6x</containerId>
                                <type>embedded</type>
                            </container>
                        </configuration>
                    </plugin> -->
                    <plugin>
                        <!--This plugin allows to run the example using mvn jetty:run -->
                        <groupId>org.mortbay.jetty</groupId>
                        <artifactId>maven-jetty-plugin</artifactId>
                        <version>${maven.jetty.plugin.version}</version>
                        <configuration>
                            <scanIntervalSeconds>10</scanIntervalSeconds>
                            <stopPort>9966</stopPort>
                            <stopKey>foo</stopKey>
                        </configuration>
                        <executions>
                            <execution>
                                <id>start-jetty</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <!-- run-exploded allow run annotation
                                    code correctly.
                                    <goal>run</goal> -->
                                    <goal>run-exploded</goal>
                                </goals>
                                <configuration>
                                    <daemon>true</daemon>
                                </configuration>
                            </execution>
                            <execution>
                                <id>stop-jetty</id>
                                <phase>post-integration-test</phase>
                                <goals>
                                    <goal>stop</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>tomcat6x</id>
            <activation>
                <property>
                    <name>it</name>
                    <value>tomcat6x</value>
                </property>            
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.cargo</groupId>
                        <artifactId>cargo-maven2-plugin</artifactId>
                        <version>${cargo.version}</version>
                        <configuration>
                            <wait>false</wait>
                            <container>
                                <containerId>tomcat6x</containerId>
                                <zipUrlInstaller>
                                    <url>
                                        http://archive.apache.org/dist/tomcat/tomcat-6/v6.0.20/bin/apache-tomcat-6.0.20.zip
                                    </url>
                                </zipUrlInstaller>
                            </container>
                        </configuration>
                        <executions>
                            <execution>
                                <id>start</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>start</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>stop</id>
                                <phase>post-integration-test</phase>
                                <goals>
                                    <goal>stop</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <repositories>
        <repository>
            <releases>
                <enabled>false</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
            <id>apache-maven-snapshots</id>
            <url>http://people.apache.org/repo/m2-snapshot-repository</url>
        </repository>
        <repository>
            <id>java.net.2</id>
            <url>http://download.java.net/maven/2</url>
        </repository>
        <repository>
            <id>apache.staging</id>
            <url>https://repository.apache.org/content/repositories/staging</url>
        </repository>
    </repositories>

    <properties>
        <!-- 2.0.3-20100630 -->
        <jsf-ri.version>2.0.6</jsf-ri.version>
        <jsf-myfaces.version>2.1.13-SNAPSHOT</jsf-myfaces.version>
        <maven.jetty.plugin.version>6.1.16</maven.jetty.plugin.version>
        <log4j.version>1.2.13</log4j.version>
        <cargo.version>1.0</cargo.version>
        <htmlunit.version>2.8</htmlunit.version>
    </properties>
</project>
