<?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.5.0</version>
    </parent>

    <artifactId>appfuse-gwt</artifactId>
    <packaging>war</packaging>
    <name>AppFuse GWT Module</name>

    <description>
        GWT Module for AppFuse: includes GWT, gwt-bootstrap, PhoneGap.
        Include this module in your dependencies if you want to use GWT as your web framework.
    </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/gwt</url>
        <tag>HEAD</tag>
    </scm>

    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>dbunit-maven-plugin</artifactId>
                <configuration>
                    <src>../../data/common/src/test/resources/sample-data.xml</src>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                <configuration>
                    <webApp>
                        <baseResource implementation="org.eclipse.jetty.util.resource.ResourceCollection">
                            <resourcesAsCSV>
                                ${basedir}/src/main/webapp,
                                ${basedir}/../common/src/main/webapp,
                                ${basedir}/target/${project.build.finalName}
                            </resourcesAsCSV>
                        </baseResource>
                    </webApp>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <webResources>
                        <!-- Need to overwrite. Cannot filter original with different values as filter cannot be escaped: MRESOURCES-126 -->
                        <resource>
                            <directory>../common/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>index.jsp</exclude>
                            </excludes>
                        </resource>
                        <resource>
                            <directory>../common/target/classes</directory>
                            <targetPath>WEB-INF/classes</targetPath>
                        </resource>
                    </webResources>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>add-resource</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>add-resource</goal>
                        </goals>
                        <configuration>
                            <resources>
                                <resource>
                                    <directory>../common/src/main/resources</directory>
                                    <excludes>
                                        <exclude>jdbc.properties</exclude>
                                    </excludes>
                                </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>../common/src/test/resources</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>gwt-maven-plugin</artifactId>
            </plugin>
            <!-- Escape single quotes so gwt:i18n MessageFormat can parse the properties file -->
            <!-- FIXME: it should be improved to match only apostrophes alone and not 'two matching' single quotes -->
            <!-- http://docs.oracle.com/javase/6/docs/api/java/text/MessageFormat.html -->
            <plugin>
                <groupId>com.google.code.maven-replacer-plugin</groupId>
                <artifactId>replacer</artifactId>
                <version>1.5.2</version>
                <executions>
                    <execution>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>replace</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <basedir>${project.build.outputDirectory}</basedir>
                    <includes>
                        <include>org/appfuse/webapp/client/application/ApplicationResources*.properties</include>
                    </includes>
                    <replacements>
                        <replacement>
                            <token>'</token>
                            <value>''</value>
                        </replacement>
                        <replacement>
                            <token>javax.faces</token>
                            <value>#javax.faces</value>
                        </replacement>
                        <replacement>
                            <token>null=</token>
                            <value>#null=</value>
                        </replacement>
                    </replacements>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>process-classes</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <id>VerifyRequestFactoryInterfaces</id>
                            <executable>java</executable>
                            <arguments>
                                <argument>-cp</argument>
                                <classpath/>
                                <argument>com.google.web.bindery.requestfactory.apt.ValidationTool</argument>
                                <argument>${project.build.outputDirectory}</argument>
                                <argument>${project.groupId}.webapp.client.requests.ApplicationRequestFactory</argument>
                            </arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
            <resource>
                <directory>../common/src/main/resources</directory>
                <includes>
                    <include>ApplicationResources*.properties</include>
                </includes>
                <targetPath>${project.build.outputDirectory}/org/appfuse/webapp/client/application</targetPath>
                <filtering>true</filtering>
            </resource>
        </resources>
    </build>

    <dependencies>
        <dependency>
            <groupId>org.appfuse</groupId>
            <artifactId>appfuse-web-common</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-frontend-jaxws</artifactId>
            <scope>runtime</scope><!-- asm version is incompatible with gwt-maven-plugin -->
        </dependency>        
        <dependency>
            <groupId>commons-fileupload</groupId>
            <artifactId>commons-fileupload</artifactId>
        </dependency>
        <!-- gwt dependencies -->
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-servlet</artifactId>
        </dependency>
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-user</artifactId>
        </dependency>
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
        </dependency>
        <dependency>
            <groupId>com.google.gwt.inject</groupId>
            <artifactId>gin</artifactId>
        </dependency>
        <dependency>
            <groupId>com.github.gwtbootstrap</groupId>
            <artifactId>gwt-bootstrap</artifactId>
        </dependency>
        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
        </dependency>

        <!-- Selenium web tests -->
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-firefox-driver</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-chrome-driver</artifactId>
            <scope>test</scope>
        </dependency>


    </dependencies>

    <profiles>
        <profile>
            <id>itest</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.cargo</groupId>
                        <artifactId>cargo-maven2-plugin</artifactId>
                    </plugin>
                    <plugin>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>default</id>
                                <goals>
                                    <goal>integration-test</goal>
                                    <goal>verify</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <systemPropertyVariables>
                                <baseUrl>http://${cargo.host}:${cargo.port}/${project.artifactId}/</baseUrl>
                                <mail.port>25250</mail.port>
                                <webdriver.chrome.driver>/usr/bin/chromedriver</webdriver.chrome.driver>
                            </systemPropertyVariables>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <!-- GWT Development/Debug Profile -->
        <profile>
            <id>gwtDebug</id>
            <properties>
                <gwt.draftCompile>true</gwt.draftCompile>
                <gwtModuleName>${project.groupId}.webapp.MainModuleDebug</gwtModuleName>
            </properties>
        </profile>
    </profiles>

    <properties>
        <gwtModuleSuffix></gwtModuleSuffix>
        <gwtModuleName>${project.groupId}.webapp.MainModule</gwtModuleName>
    </properties>
</project>
