<?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-web</artifactId>
        <version>3.0.0</version>
    </parent>

    <artifactId>appfuse-tapestry</artifactId>
    <packaging>war</packaging>
    <name>AppFuse Tapestry Module</name>

    <description>
        Tapestry Module for AppFuse: includes Tapestry with Spring and Flash messages support.
    </description>

    <scm>
        <connection>scm:git:git@github.com:appfuse/appfuse.git</connection>
        <developerConnection>scm:git:git@github.com:appfuse/appfuse.git</developerConnection>
        <url>http://source.appfuse.org/browse/appfuse/web/tapestry</url>
      <tag>APPFUSE_3.0.0</tag>
  </scm>

    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>dbunit-maven-plugin</artifactId>
                <version>1.0-beta-3</version>
                <configuration>
                    <dataTypeFactoryName>${dbunit.dataTypeFactoryName}</dataTypeFactoryName>
                    <driver>${jdbc.driverClassName}</driver>
                    <username>${jdbc.username}</username>
                    <password>${jdbc.password}</password>
                    <url>${jdbc.url}</url>
                    <src>../../data/common/src/test/resources/sample-data.xml</src>
                    <type>${dbunit.operation.type}</type>
                    <schema>${dbunit.schema}</schema>
                    <skip>${skipTests}</skip>
                    <transaction>true</transaction>
                </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>
            <!-- clean-up previous hibernate-search indexed from integration tests, as there could be a lock -->
            <plugin>
                <artifactId>maven-clean-plugin</artifactId>
                <version>2.5</version>
                <configuration>
                    <filesets>
                        <fileset>
                            <directory>${user.home}/${project.build.finalName}/index</directory>
                        </fileset>
                    </filesets>
                </configuration>
            </plugin>
            <!-- Override plugin configuration from appfuse-web so can exclude overridden files -->
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <!-- will package a ready-to-run app regarding hibernate-search index location -->
                    <escapeString>\</escapeString>
                    <webResources>
                        <!-- Need to overwrite. Cannot filter original with different values as filter cannot be escaped: MRESOURCES-126 -->
                        <resource>
                            <directory>src/main/resources/packaged</directory>
                            <targetPath>WEB-INF/classes</targetPath>
                            <filtering>true</filtering>
                            <includes>
                                <include>hibernate.properties</include>
                            </includes>
                        </resource>
                        <resource>
                            <directory>../common/src/main/webapp</directory>
                            <excludes>
                                <exclude>*.jsp</exclude>
                                <exclude>decorators/**</exclude>
                                <exclude>WEB-INF/menu-config.xml</exclude>
                            </excludes>
                        </resource>
                        <resource>
                            <directory>../common/target/classes</directory>
                            <excludes>
                                <exclude>ApplicationResources*</exclude>
                            </excludes>
                            <targetPath>WEB-INF/classes</targetPath>
                        </resource>
                        <resource>
                            <directory>src/main/webapp/WEB-INF</directory>
                            <filtering>true</filtering>
                            <targetPath>WEB-INF</targetPath>
                        </resource>
                    </webResources>
                    <archive>
                        <manifest>
                            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                        </manifest>
                        <manifestEntries>
                            <Implementation-Version>${project.version}</Implementation-Version>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.7</version>
                <executions>
                    <execution>
                        <id>default-resources</id>
                        <phase>process-resources</phase>
                        <configuration>
                            <tasks>
                                <echo>Copying i18n files...</echo>
                                <copy todir="src/main/webapp/WEB-INF" overwrite="true">
                                    <globmapper from="ApplicationResources*" to="app*" />
                                    <fileset dir="../common/src/main/resources" includes="ApplicationResources*" />
                                    <!-- Tapestry specific customizations -->
                                    <filterset begintoken="{" endtoken="}">
                                        <!-- Convert {i} to %s -->
                                        <filter token="0" value="%1$s" />
                                        <filter token="1" value="%2$s" />
                                        <filter token="2" value="%3$s" />
                                        <filter token="3" value="%4$s" />
                                        <filter token="4" value="%5$s" />
                                        <filter token="5" value="%6$s" />
                                        <filter token="6" value="%7$s" />
                                    </filterset>
                                    <filterset begintoken="${" endtoken="}">
                                        <!-- Tapestry interpret these as symbols -->
                                        <filter token="pom.version" value="${project.version}" />
                                        <filter token="copyright.year" value="${copyright.year}" />
                                    </filterset>
                                </copy>

                                <echo message="Copying CSS and JavaScript resources..." />
                                <copy todir="src/main/webapp" overwrite="true">
                                    <fileset dir="../common/src/main/webapp">
                                        <include name="styles/style.css" />
                                    </fileset>
                                </copy>
                            </tasks>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.java</include>
                    <include>**/*.tml</include>
                </includes>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
        <testResources>
            <testResource>
                <directory>src/test/resources</directory>
                <excludes>
                    <exclude>hibernate.properties</exclude>
                </excludes>
                <filtering>false</filtering>
            </testResource>
            <testResource>
                <directory>src/test/resources</directory>
                <includes>
                    <include>hibernate.properties</include>
                </includes>
                <filtering>true</filtering>
            </testResource>
            <testResource>
                <directory>src/main/webapp</directory>
                <includes>
                    <include>**/*.xml</include>
                </includes>
            </testResource>
        </testResources>
    </build>

    <dependencies>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>appfuse-web-common</artifactId>
            <version>${project.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.appfuse</groupId>
                    <artifactId>appfuse-hibernate</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>struts-menu</groupId>
                    <artifactId>struts-menu</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>opensymphony</groupId>
                    <artifactId>sitemesh</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.appfuse</groupId>
            <artifactId>appfuse-${dao.framework}</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tapestry</groupId>
            <artifactId>tapestry-core</artifactId>
            <version>${tapestry.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tapestry</groupId>
            <artifactId>tapestry-spring</artifactId>
            <version>${tapestry.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tapestry</groupId>
            <artifactId>tapestry-upload</artifactId>
            <version>${tapestry.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tapestry</groupId>
            <artifactId>tapestry-test</artifactId>
            <version>${tapestry.version}</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.seleniumhq.selenium.client-drivers</groupId>
                    <artifactId>selenium-java-client-driver</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.seleniumhq.selenium.server</groupId>
                    <artifactId>selenium-server</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.seleniumhq.selenium.server</groupId>
                    <artifactId>selenium-server-coreless</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.testng</groupId>
                    <artifactId>testng</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <!-- Add Bootstrap via WebJars -->
        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>bootstrap</artifactId>
        </dependency>
        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>bootstrap-datepicker</artifactId>
            <version>1.2.0</version>
        </dependency>
        <!-- Downgrade jQuery so it works with HtmlUnit -->
        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>jquery</artifactId>
            <version>1.8.3</version>
        </dependency>
    </dependencies>

    <profiles>
        <profile>
            <id>itest</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.cargo</groupId>
                        <artifactId>cargo-maven2-plugin</artifactId>
                        <version>${cargo.version}</version>
                        <configuration>
                            <wait>${cargo.wait}</wait>
                            <container>
                                <containerId>${cargo.container}</containerId>
                                <home>${cargo.container.home}</home>
                                <zipUrlInstaller>
                                    <url>${cargo.container.url}</url>
                                    <extractDir>${installDir}</extractDir>
                                </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>
                                    <!-- To prevent conflicts with already running instances -->
                                    <cargo.tomcat.ajp.port>8123</cargo.tomcat.ajp.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>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>webtest-maven-plugin</artifactId>
                        <version>1.0.0</version>
                        <executions>
                            <execution>
                                <id>webtest-test</id>
                                <phase>integration-test</phase>
                                <goals>
                                    <goal>test</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>webtest-verify</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>verify-result</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>webtest-report-html</id>
                                <phase>post-integration-test</phase>
                                <goals>
                                    <goal>report</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <host>${cargo.host}</host>
                            <port>${cargo.port}</port>
                            <sourcedirectory>src/test/resources</sourcedirectory>
                            <sourcefile>web-tests.xml</sourcefile>
                            <target>run-all-tests</target>
                            <basepath>${project.build.finalName}</basepath>
                            <resultpath>target/webtest/webtest-results</resultpath>
                            <haltonfailure>false</haltonfailure>
                            <haltonerror>false</haltonerror>
                            <loglevel>fatal</loglevel>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>

