<?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-struts</artifactId>
    <packaging>war</packaging>
    <name>AppFuse Struts 2 Module</name>

    <description>
        Struts 2 Module for AppFuse: includes Struts 2 and Display Tag.
    </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/struts</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>
            <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>
                        </resource>
                        <resource>
                            <directory>../common/target/classes</directory>
                            <targetPath>WEB-INF/classes</targetPath>
                        </resource>
                    </webResources>
                    <archive>
                        <manifest>
                            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                        </manifest>
                        <manifestEntries>
                            <Implementation-Version>${project.version}</Implementation-Version>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>native2ascii-maven-plugin</artifactId>
                <version>1.0-beta-1</version>
                <executions>
                    <execution>
                        <id>native2ascii-utf8</id>
                        <goals>
                            <goal>native2ascii</goal>
                        </goals>
                        <configuration>
                            <encoding>UTF8</encoding>
                            <includes>
                                <include>errors_el*</include>
                                <include>errors_ko*</include>
                                <include>errors_tr*</include>
                                <include>errors_zh*</include>
                            </includes>
                        </configuration>
                    </execution>
                    <execution>
                        <id>native2ascii-8859_1</id>
                        <goals>
                            <goal>native2ascii</goal>
                        </goals>
                        <configuration>
                            <encoding>8859_1</encoding>
                            <includes>
                                <include>errors_de.properties</include>
                                <include>errors_fr.properties</include>
                                <include>errors_nl.properties</include>
                                <include>errors_pt*.properties</include>
                            </includes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
                <excludes>
                    <exclude>packaged/*.properties</exclude>
                </excludes>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>false</filtering>
                <includes>
                    <include>packaged/*.properties</include>
                </includes>
            </resource>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.xml</include>
                </includes>
            </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>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.appfuse</groupId>
            <artifactId>appfuse-${dao.framework}</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>displaytag</groupId>
            <artifactId>displaytag</artifactId>
            <version>${displaytag.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>jcl104-over-slf4j</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>jsp-api</artifactId>
            <version>${jsp.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.struts</groupId>
            <artifactId>struts2-core</artifactId>
            <version>${struts.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.struts</groupId>
            <artifactId>struts2-convention-plugin</artifactId>
            <version>${struts.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.struts</groupId>
            <artifactId>struts2-dojo-plugin</artifactId>
            <version>${struts.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.struts</groupId>
            <artifactId>struts2-spring-plugin</artifactId>
            <version>${struts.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>*</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>commons-fileupload</groupId>
            <artifactId>commons-fileupload</artifactId>
            <version>${commons.fileupload.version}</version>
        </dependency>
        <!-- Upgrade version of commons-io used -->
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>${commons.io.version}</version>
        </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>

    <reporting>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>webtest-maven-plugin</artifactId>
                <version>1.0.0</version>
            </plugin>
        </plugins>
    </reporting>
</project>

