<?xml version="1.0" encoding="UTF-8"?>

<!--
    Licensed 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.
-->

<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>org.appfuse</groupId>
        <artifactId>appfuse</artifactId>
        <version>2.0-rc1-SNAPSHOT</version>
        <relativePath>../../pom.xml</relativePath>
    </parent>

    <artifactId>appfuse-jsf</artifactId>
    <packaging>war</packaging>
    <name>AppFuse JSF Module</name>

    <description>
        JSF Module for AppFuse: includes MyFaces, Facelets and Ajax4JSF. Include this module in
        your dependencies if you want to use JSF as your web framework.
    </description>

    <scm>
        <connection>scm:svn:https://appfuse.dev.java.net/svn/appfuse/trunk/web/jsf</connection>
        <developerConnection>scm:svn:https://appfuse.dev.java.net/svn/appfuse/trunk/web/jsf</developerConnection>
        <url>https://appfuse.dev.java.net/source/browse/appfuse/trunk/web/jsf</url>
    </scm>

    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>dbunit-maven-plugin</artifactId>
                <version>1.0-beta-1</version>
                <configuration>
                    <dataTypeFactoryName>${dbunit.dataTypeFactoryName}</dataTypeFactoryName>
                    <driver>${jdbc.driverClassName}</driver>
                    <username>${jdbc.username}</username>
                    <password>${jdbc.password}</password>
                    <url>${jdbc.url}</url>
                    <src>src/test/resources/sample-data.xml</src>
                    <type>${dbunit.operation.type}</type>
                    <schema>${dbunit.schema}</schema>
                    <skip>${maven.test.skip}</skip>
                </configuration>
                <executions>
                    <execution>
                        <id>test-compile</id>
                        <phase>test-compile</phase>
                        <goals>
                            <goal>operation</goal>
                        </goals>
                    </execution>
                    <execution>
                        <!-- Runs before integration tests and jetty:run-war -->
                        <id>test</id>
                        <phase>test</phase>
                        <goals>
                            <goal>operation</goal>
                        </goals>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>${jdbc.groupId}</groupId>
                        <artifactId>${jdbc.artifactId}</artifactId>
                        <version>${jdbc.version}</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <groupId>org.appfuse</groupId>
                <artifactId>maven-warpath-plugin</artifactId>
                <version>1.0-rc1-SNAPSHOT</version>
                <extensions>true</extensions>
                <executions>
                    <execution>
                        <goals>
                            <goal>add-classes</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.0.2</version>
                <executions>
                    <execution>
                        <id>skinny-war</id>
                        <goals>
                            <goal>war</goal>
                        </goals>
                        <phase>post-integration-test</phase>
                        <inherited>false</inherited>
                        <configuration>
                            <warSourceExcludes>WEB-INF/lib/**</warSourceExcludes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <testResources>
            <testResource>
                <directory>src/test/resources</directory>
            </testResource>
            <testResource>
                <directory>src/main/webapp</directory>
                <includes>
                    <include>**/*.xml</include>
                </includes>
            </testResource>
        </testResources>
    </build>

    <repositories>
        <!-- Needed for Facelets -->
        <repository>
            <id>java.net</id>
            <url>http://download.java.net/maven/1/</url>
            <layout>legacy</layout>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>${pom.groupId}</groupId>
            <artifactId>appfuse-web-common</artifactId>
            <version>${pom.version}</version>
            <type>war</type>
        </dependency>
        <dependency>
            <groupId>${pom.groupId}</groupId>
            <artifactId>appfuse-web-common</artifactId>
            <version>${pom.version}</version>
            <type>warpath</type>
        </dependency>
        <dependency>
            <groupId>net.java.dev.ajax4jsf</groupId>
            <artifactId>ajax4jsf</artifactId>
            <version>${ajax4jsf.version}</version>
        </dependency>
        <dependency>
            <groupId>net.sf.jsfcomp</groupId>
            <artifactId>acegijsf</artifactId>
            <version>${acegijsf.version}</version>
        </dependency>
        <dependency>
            <groupId>com.sun.facelets</groupId>
            <artifactId>jsf-facelets</artifactId>
            <version>${facelets.version}</version>
        </dependency>
        <dependency>
            <groupId>com.corejsf</groupId>
            <artifactId>corejsf-validator</artifactId>
            <version>${corejsf.validator.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.myfaces.core</groupId>
            <artifactId>myfaces-api</artifactId>
            <version>${myfaces.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.myfaces.core</groupId>
            <artifactId>myfaces-impl</artifactId>
            <version>${myfaces.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.myfaces.tomahawk</groupId>
            <artifactId>tomahawk</artifactId>
            <version>${myfaces.tomahawk.version}</version>
        </dependency>
        <dependency>
            <groupId>javax.annotation</groupId>
            <artifactId>jsr250-api</artifactId>
            <version>1.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.shale</groupId>
            <artifactId>shale-test</artifactId>
            <version>${shale.version}</version>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.subethamail</groupId>
            <artifactId>subethasmtp-wiser</artifactId>
            <version>${wiser.version}</version>
            <scope>test</scope>
        </dependency>
        <!-- Dependencies with scope=provided aren't picked up from dependent JARs -->
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>jsp-api</artifactId>
            <version>2.1</version> <!-- Special case for JSF only -->
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>${servlet.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>${jdbc.groupId}</groupId>
            <artifactId>${jdbc.artifactId}</artifactId>
            <version>${jdbc.version}</version>
        </dependency>
    </dependencies>

    <profiles>
        <profile>
            <id>integration-test</id>
            <activation>
                <property>
                    <name>!maven.test.skip</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.cargo</groupId>
                        <artifactId>cargo-maven2-plugin</artifactId>
                        <version>0.3</version>
                        <configuration>
                            <wait>${cargo.wait}</wait>
                            <container>
                                <containerId>${cargo.container}</containerId>
                                <!--home>${cargo.container.home}</home-->
                                <zipUrlInstaller>
                                    <url>${cargo.container.url}</url>
                                    <installDir>${installDir}</installDir>
                                </zipUrlInstaller>
                            </container>
                            <configuration>
                                <home>${project.build.directory}/${cargo.container}/container</home>
                                <properties>
                                    <cargo.hostname>${cargo.host}</cargo.hostname>
                                    <cargo.servlet.port>${cargo.port}</cargo.servlet.port>
                                </properties>
                            </configuration>
                        </configuration>
                        <executions>
                            <execution>
                                <id>start-container</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>start</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>stop-container</id>
                                <phase>post-integration-test</phase>
                                <goals>
                                    <goal>stop</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <version>1.1</version>
                        <configuration>
                            <tasks>
                                <taskdef resource="webtest_base_relaxed.taskdef">
                                    <classpath refid="maven.test.classpath"/>
                                </taskdef>
                                <mkdir dir="target/webtest-data"/>
                                <!-- Delete old results file if it exists -->
                                <delete file="target/webtest-data/web-tests-result.xml"/>
                                <!-- This is so the default will be used if no test case is specified -->
                                <property name="test" value="run-all-tests"/>
                                <echo level="info">Testing '${project.build.finalName}' with locale '${user.language}'</echo>
                                <ant antfile="src/test/resources/web-tests.xml" target="${test}">
                                    <property name="user.language" value="${user.language}"/>
                                    <property name="webapp.name" value="${project.build.finalName}"/>
                                    <property name="host" value="${cargo.host}"/>
                                    <property name="port" value="${cargo.port}"/>
                                </ant>
                            </tasks>
                        </configuration>
                        <executions>
                            <execution>
                                <phase>integration-test</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                            </execution>
                        </executions>
                        <dependencies>
                            <dependency>
                                <groupId>com.canoo.webtest</groupId>
                                <artifactId>webtest</artifactId>
                                <version>${webtest.version}</version>
                                <!-- groovy-all doesn't have a pom in central repo -->
                                <!-- exclude groovy to prevent trying to fetch pom -->
                                <exclusions>
                                    <exclusion>
                                        <groupId>groovy</groupId>
                                        <artifactId>groovy-all</artifactId>
                                    </exclusion>
                                </exclusions>
                            </dependency>
                        </dependencies>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
