<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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>it.geosolutions.geofence</groupId>
        <artifactId>geofence-gui-root</artifactId>
        <version>2.2-SNAPSHOT</version>
    </parent>

    <groupId>it.geosolutions.geofence</groupId>
    <artifactId>geofence-gui-web</artifactId>
    <packaging>war</packaging>

    <name>GeoFence - GUI - Web</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>

        <!-- =============================================================== -->
        <!-- APACHE COMMONS -->
        <!-- =============================================================== -->
        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
        </dependency>
        <dependency>
            <groupId>commons-collections</groupId>
            <artifactId>commons-collections</artifactId>
        </dependency>


        <!-- =============================================================== -->
        <!--
            Next deps are defined in core::dao, but seems not to be transitively
            imported
        -->
        <!-- =============================================================== -->
        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
        </dependency>

        <!-- =============================================================== -->
        <!-- GeoFence -->
        <!-- =============================================================== -->
        <dependency>
            <groupId>it.geosolutions.geofence</groupId>
            <artifactId>geofence-model-internal</artifactId>
        </dependency>

        <dependency>
            <groupId>it.geosolutions.geofence</groupId>
            <artifactId>geofence-services-api</artifactId>
        </dependency>

        <dependency>
            <groupId>it.geosolutions.geofence</groupId>
            <artifactId>geofence-services-impl</artifactId>
        </dependency>

        <dependency>
            <groupId>it.geosolutions.geofence</groupId>
            <artifactId>geofence-login-impl</artifactId>
        </dependency>

        <dependency>
            <groupId>it.geosolutions.geofence</groupId>
            <artifactId>geofence-rest-impl</artifactId>
        </dependency>
		
        <dependency>
            <groupId>it.geosolutions.geofence</groupId>
            <artifactId>geofence-ldap</artifactId>
        </dependency>

        <!-- =============================================================== -->
        <!-- 4J UTILS -->
        <!-- =============================================================== -->
        <dependency>
            <groupId>dom4j</groupId>
            <artifactId>dom4j</artifactId>
        </dependency>

        <!-- =============================================================== -->
        <!-- Logging                                                         -->
        <!-- =============================================================== -->

        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-slf4j-impl</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-jcl</artifactId>
            <version>2.0-beta7</version>
        </dependency>

        <!-- =============================================================== -->
        <!-- HTTP UTILS -->
        <!-- =============================================================== -->
        <dependency>
            <groupId>org.codehaus.jettison</groupId>
            <artifactId>jettison</artifactId>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <scope>provided</scope>
        </dependency>

        <!-- =============================================================== -->
        <!-- CXF -->
        <!-- =============================================================== -->
        <dependency>
            <groupId>javax.xml.ws</groupId>
            <artifactId>jaxws-api</artifactId>
        </dependency>
        <!--		<dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-bindings-http</artifactId>
        </dependency>-->
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-transports-http</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-transports-http-jetty</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-frontend-jaxws</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-frontend-jaxrs</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-bindings-soap</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-databinding-aegis</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-ws-security</artifactId>
        </dependency>

        <!-- =============================================================== -->
        <!-- =============================================================== -->
        <!-- CLIENT -->
        <!-- =============================================================== -->
        <!-- =============================================================== -->

        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-user</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-servlet</artifactId>
            <scope>runtime</scope>
        </dependency>

        <!-- GXT -->
        <dependency>
            <groupId>com.extjs</groupId>
            <artifactId>gxt</artifactId>
        </dependency>
               
        <!--  Resources -->
        <dependency>
            <groupId>it.geosolutions.geofence</groupId>
            <artifactId>geofence-gui-resources</artifactId>
        </dependency>

        <!--  MAPS UI -->
        <dependency>
            <groupId>it.geosolutions.geofence</groupId>
            <artifactId>geofence-gui-mapsui</artifactId>
        </dependency>

        <!--  USER UI -->
        <dependency>
            <groupId>it.geosolutions.geofence</groupId>
            <artifactId>geofence-gui-userui</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>jcl-over-slf4j</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <!-- SPRING -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aop</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
        </dependency>

        <!-- SCOPE TEST -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>commons-collections</groupId>
                    <artifactId>commons-collections</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>xerces</groupId>
                    <artifactId>xercesImpl</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <!-- =============================================================== -->
        <!-- JUnit -->
        <!-- =============================================================== -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.7</version>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <build>
        <outputDirectory>war/WEB-INF/classes</outputDirectory>
        <plugins>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <encoding>utf8</encoding>
                    <source>1.5</source>
                    <target>1.5</target>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>gwt-maven-plugin</artifactId>
                <version>${gwt.version}</version>
                <configuration>
                    <inplace>true</inplace>
                    <module>it.geosolutions.geofence.gui.Application</module>
                    <runTarget>Application.html</runTarget>
                    <warSourceDirectory>war</warSourceDirectory>
                    <disableCastChecking>true</disableCastChecking>
                    <disableClassMetadata>true</disableClassMetadata>
                    <extraJvmArgs>-Xmx1024M -Xss1024k -Dgwt.nowarn.legacy.tools</extraJvmArgs>
                </configuration>
                <executions>
                    <execution>
                        <id>clean</id>
                        <phase>clean</phase>
                        <goals>
                            <goal>clean</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>compile</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>generateAsync</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>generateAsync</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.1.1</version>
                <configuration>
                    <warSourceExcludes>.gwt-tmp/**</warSourceExcludes>
                    <warSourceDirectory>war</warSourceDirectory>
                    <webXml>war/WEB-INF/web.xml</webXml>
                </configuration>
            </plugin>
			
            <!-- Run the application using "mvn jetty:run" -->
            <plugin>
                <groupId>org.mortbay.jetty</groupId>
                <artifactId>maven-jetty-plugin</artifactId>
                <version>6.1.20</version>
                <configuration>
                    <webAppSourceDirectory>${basedir}/war</webAppSourceDirectory>
                    <webAppConfig>
                        <contextPath>/geofence</contextPath>
                    </webAppConfig>
                    <connectors>
                        <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
                            <port>8081</port>
                            <maxIdleTime>60000</maxIdleTime>
                        </connector>
                    </connectors>
                    <reload>manual</reload>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <id>remove-build-files</id>
                        <phase>clean</phase>
                        <configuration>
                            <tasks>
                                <delete dir="war/WEB-INF/lib" />
                                <delete dir="war/geofence" />
                                <delete dir="gwt-unitCache" />
                                <delete dir="war/WEB-INF/deploy" />
                                <delete dir="war/WEB-INF/classes" />
                                <!-- 								 -->
                                <!--
                              these entries are in the gitignore file
                              geofence-gui/fullweb/gwt-unitCache/
                              geofence-gui/fullweb/war/WEB-INF/deploy/
                              geofence-gui/fullweb/war/WEB-INF/classes/
                              geofence-gui/fullweb/war/WEB-INF/lib/
                              geofence-gui/fullweb/war/geofence/
                                -->
                            </tasks>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>copy-patched-openlayers</id>
                        <phase>prepare-package</phase>
                        <configuration>
                            <tasks>
                                <copy todir="war/geofence/lib" flatten="true" overwrite="true" verbose="true" failonerror="true">
                                    <fileset dir="patch" includes="OpenLayers.js"/> 
                                </copy>
                            </tasks>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.8</version>
                <executions>
                    <execution>

                        <id>copy-spatial-dependencies</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <!--<goal>copy-dependencies</goal>-->
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <!-- configure the plugin here -->
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.hibernatespatial</groupId>
                                    <artifactId>hibernate-spatial-postgis</artifactId>                                    
                                </artifactItem>
                                <artifactItem>
                                    <groupId>org.hibernatespatial</groupId>
                                    <artifactId>hibernate-spatial-oracle</artifactId>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>org.hibernatespatial</groupId>
                                    <artifactId>hibernate-spatial-h2-geodb</artifactId>
                                </artifactItem>
                            </artifactItems>
                            <!--<outputDirectory>${project.build.directory}/war/WEB-INF/spatial-lib/</outputDirectory>-->
                            <outputDirectory>war/WEB-INF/spatial-lib/</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

        </plugins>
        <finalName>geofence</finalName>
    </build>
    <!-- =========================================================== -->
    <!--     HIBERNATE-SPATIAL                                       -->
    <!-- =========================================================== -->

    <!-- These deps should be mutually exclusive or hibernate won't know which one to use for
         mapping geometry types:
         http://www.hibernatespatial.org/hibernate-spatial-h2-geodb/usage.html - DEAD URL
         http://web.archive.org/web/20130830010044/http://www.hibernatespatial.org/hibernate-spatial-h2-geodb/usage.html
    -->
    <profiles>
        <profile>
            <id>postgis</id>            
            <dependencies>
                <dependency>
                    <groupId>org.hibernatespatial</groupId>
                    <artifactId>hibernate-spatial-postgis</artifactId>
                </dependency>
            </dependencies>
        </profile>
        <profile>
            <id>h2</id>    
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <dependencies>
                <dependency>
                    <groupId>org.hibernatespatial</groupId>
                    <artifactId>hibernate-spatial-h2-geodb</artifactId>
                </dependency>
            </dependencies>
        </profile>
        <profile>
            <id>oracle</id>            
            <dependencies>
                <dependency>
                    <groupId>org.hibernatespatial</groupId>
                    <artifactId>hibernate-spatial-oracle</artifactId>
                </dependency>
            </dependencies>
        </profile>
    </profiles>
</project>
