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

    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.syncope</groupId>
        <artifactId>syncope</artifactId>
        <version>0.7</version>
    </parent>

    <name>Syncope console</name>
    <description>Syncope console</description>
    <groupId>org.syncope</groupId>
    <artifactId>syncope-console</artifactId>
    <packaging>war</packaging>

    <dependencies>

        <dependency>
            <groupId>org.syncope</groupId>
            <artifactId>syncope-client</artifactId>
            <version>${project.version}</version>
        </dependency>
        
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-core</artifactId>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
        </dependency>
        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jcl-over-slf4j</artifactId>
        </dependency>

        <dependency>
            <groupId>org.apache.wicket</groupId>
            <artifactId>wicket</artifactId>
            <type>pom</type>
        </dependency>
        <dependency>
            <groupId>org.apache.wicket</groupId>
            <artifactId>wicket-extensions</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.wicket</groupId>
            <artifactId>wicket-datetime</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.wicket</groupId>
            <artifactId>wicket-spring</artifactId>
            <!-- exclude spring framework that wicket pulls in -->
            <exclusions>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.wicket</groupId>
            <artifactId>wicket-auth-roles</artifactId>
        </dependency>
        
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
        </dependency>

        <dependency>
            <groupId>commons-httpclient</groupId>
            <artifactId>commons-httpclient</artifactId>
        </dependency>
        
        <!-- TEST -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium.client-drivers</groupId>
            <artifactId>selenium-java-client-driver</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.connid.bundles.soap</groupId>
            <artifactId>org.connid.bundles.soap</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.connid.bundles.soap</groupId>
            <artifactId>wssample</artifactId>
            <type>war</type>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.connid.bundles.db</groupId>
            <artifactId>org.connid.bundles.db.table</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.connid.bundles</groupId>
            <artifactId>org.connid.bundles.csvdir</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.connid.bundles</groupId>
            <artifactId>org.connid.bundles.ldap</artifactId>
            <scope>test</scope>
        </dependency>
        <!-- /TEST -->

    </dependencies>

    <build>
        <finalName>${project.artifactId}</finalName>

        <plugins>
            
            <plugin>
                <groupId>org.codehaus.groovy.maven</groupId>
                <artifactId>gmaven-plugin</artifactId>
                <inherited>true</inherited>
                <executions>
                    <execution>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>execute</goal>
                        </goals>
                        <configuration>
                            <source>
                                project.properties['urlencoded.java.io.tmpdir'] = java.net.URLEncoder.encode(System.properties['java.io.tmpdir'])
                            </source>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <inherited>true</inherited>
                <executions>
                    <execution>
                        <id>set-bundles</id>
                        <phase>process-test-resources</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
                                    
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <inherited>true</inherited>
                <executions>
                    <execution>
                        <id>explodeSyncopeWAR</id>
                        <phase>pre-integration-test</phase>
                        <configuration>
                            <target>
                                <unzip src="${basedir}/../core/target/syncope.war" dest="${cargo.run.dir}">
                                    <patternset>
                                        <exclude name="**/content.xml" />
                                        <exclude name="**/ehcache.xml" />
                                        <exclude name="**/persistence.properties" />
                                        <exclude name="**/security.properties" />
                                        <exclude name="**/workflow.properties" />
                                    </patternset>
                                </unzip>
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>setupTomcat</id>
                        <phase>pre-integration-test</phase>
                        <configuration>
                            <target>
                                <get src="http://archive.apache.org/dist/tomcat/tomcat-7/v${tomcat.version}/bin/apache-tomcat-${tomcat.version}.zip" dest="${java.io.tmpdir}" skipexisting="true" />
                                <unzip src="${java.io.tmpdir}/apache-tomcat-${tomcat.version}.zip" dest="${java.io.tmpdir}" overwrite="false" />
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>setupCSV</id>
                        <phase>pre-integration-test</phase>
                        <configuration>
                            <target>
                                <copy file="${project.build.directory}/test-classes/test.csv" todir="${java.io.tmpdir}" overwrite="true" />
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            
            <plugin>
                <groupId>org.codehaus.cargo</groupId>
                <artifactId>cargo-maven2-plugin</artifactId>
                <inherited>true</inherited>
                <configuration>
                    <container>
                        <containerId>tomcat7x</containerId>
                        <home>${java.io.tmpdir}/apache-tomcat-${tomcat.version}</home>
                        <log>${cargo.log}</log>
                        <output>${cargo.output}</output>
                        <dependencies>
                            <dependency>
                                <location>${project.build.directory}/test-classes/</location>
                            </dependency>
                            <dependency>
                                <groupId>com.h2database</groupId>
                                <artifactId>h2</artifactId>
                            </dependency>
                        </dependencies>
                    </container>
                    <configuration>
                        <type>standalone</type>
                        <properties>
                            <cargo.servlet.port>${cargo.servlet.port}</cargo.servlet.port>
                            <cargo.tomcat.ajp.port>8889</cargo.tomcat.ajp.port>
                            <cargo.rmi.port>8805</cargo.rmi.port>
                            
<!--                            <cargo.jvmargs>-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n</cargo.jvmargs>-->
                            <cargo.jvmargs>-noverify ${javaagent} -Xms512m -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=512m</cargo.jvmargs>
                        </properties>
                        <configfiles>
                            <configfile>
                                <file>${project.build.directory}/test-classes/context.xml</file>
                                <todir>conf/</todir>
                                <tofile>context.xml</tofile>
                            </configfile>
                        </configfiles>
                        <deployables>
                            <deployable>
                                <location>${cargo.run.dir}</location>
                                <properties>
                                    <context>syncope</context>
                                </properties>
                            </deployable>
                            <deployable>
                                <location>${project.build.directory}/${project.build.finalName}.war</location>
                                <properties>
                                    <context>syncope-console</context>
                                </properties>
                            </deployable>
                            <deployable>
                                <location>${settings.localRepository}/org/connid/bundles/soap/wssample/${connid.soap.version}/wssample-${connid.soap.version}.war</location>
                                <properties>
                                    <context>wssample</context>
                                </properties>
                            </deployable>
                            <deployable>
                                <location>${basedir}/../build-tools/target/syncope-build-tools-${project.version}.war</location>
                                <properties>
                                    <context>syncope-build-tools</context>
                                </properties>
                            </deployable>
                        </deployables>
                    </configuration>
                </configuration>
            </plugin>
        </plugins>
            
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>

        <testResources>
            <testResource>
                <directory>../core/src/test/resources</directory>
                <filtering>true</filtering>
            </testResource>
            <testResource>
                <directory>src/test/resources</directory>
                <filtering>true</filtering>
            </testResource>
        </testResources>
    </build>
    
    <profiles>
        
        <profile>
            <id>dev</id>
            <properties>
                <maven.test.skip>true</maven.test.skip>
                <javaagent />
            </properties>
            <build>
                <defaultGoal>clean verify cargo:run</defaultGoal>
            </build>
        </profile>
        
        <profile>
            <id>jrebel</id>
            <properties>
                <maven.test.skip>true</maven.test.skip>
                <javaagent>-javaagent:${env.REBEL_HOME}/jrebel.jar</javaagent>
            </properties>
            <build>
                <defaultGoal>clean verify cargo:run</defaultGoal>
                
                <plugins>
                    <plugin>
                        <groupId>org.zeroturnaround</groupId>
                        <artifactId>jrebel-maven-plugin</artifactId>
                        <inherited>true</inherited>
                        <executions>
                            <execution>
                                <id>generate-rebel-xml</id>
                                <phase>process-resources</phase>
                                <goals>
                                    <goal>generate</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        
        <profile>
            <id>selenium</id>
            <properties>
                <javaagent />    
            </properties>
            <build>
                <defaultGoal>clean verify</defaultGoal>
                <plugins>
                    
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>selenium-maven-plugin</artifactId>
                        <inherited>true</inherited>
                        <executions>
                            <execution>
                                <id>start-selenium</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>start-server</goal>
                                </goals>
                                <configuration>
                                    <background>true</background>
                                    <logOutput>true</logOutput>
                                </configuration>
                            </execution>
                            <execution>
                                <id>stop-selenium</id>
                                <phase>post-integration-test</phase>
                                <goals>
                                    <goal>stop-server</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
            
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <inherited>true</inherited>
                        <executions>
                            <execution>
                                <id>verify</id>
                                <goals>
                                    <goal>verify</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    
                    <plugin>
                        <groupId>org.codehaus.cargo</groupId>
                        <artifactId>cargo-maven2-plugin</artifactId>
                        <inherited>true</inherited>
                        <executions>
                            <execution>
                                <id>start-container</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>start</goal>
                                </goals>
                                <configuration>
                                    <wait>false</wait>
                                </configuration>
                            </execution>
                            <execution>
                                <id>stop-container</id>
                                <phase>post-integration-test</phase>
                                <goals>
                                    <goal>stop</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>    
            </build>
        </profile>
    </profiles>

    <reporting>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <version>2.8</version>
                <configuration>
                    <configLocation>org/syncope/checkstyle.xml</configLocation>
                    <targetJdk>${targetJdk}</targetJdk>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-pmd-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <rulesets>
                        <ruleset>org/syncope/pmd.xml</ruleset>
                    </rulesets>
                    <targetJdk>${targetJdk}</targetJdk>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jxr-plugin</artifactId>
                <version>2.3</version>
            </plugin>
        </plugins>
    </reporting>
</project>
