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

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

    <properties>
        <hsqldb.version>2.0.0</hsqldb.version>

        <jetty.port>8080</jetty.port>

        <logfile>/var/tmp/syncope-console.log</logfile>
        <logfile.test>/var/tmp/syncope-console-test.log</logfile.test>

        <cargo.servlet.port>9080</cargo.servlet.port>
        <cargo.log>/var/tmp/syncope-core-cargo.log</cargo.log>
        <cargo.output>/var/tmp/syncope-core-cargo-output.log</cargo.output>

        <bundles.directory>/var/tmp/bundles</bundles.directory>
    </properties>

    <dependencies>

        <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>
        </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>
            <type>jar</type>
        </dependency>

        <dependency>
            <groupId>org.syncope</groupId>
            <artifactId>syncope-client</artifactId>
            <version>${project.version}</version>
            <type>jar</type>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
        </dependency>

        <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-mapper-lgpl</artifactId>
        </dependency>

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

        <dependency>
            <groupId>commons-httpclient</groupId>
            <artifactId>commons-httpclient</artifactId>
        </dependency>
    </dependencies>

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

        <plugins>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <inherited>true</inherited>
                <configuration>
                    <attachClasses>true</attachClasses>
                </configuration>
            </plugin>

            <!-- Integration test -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <inherited>true</inherited>
                <executions>
                    <execution>
                        <id>explodeSyncopeWAR</id>
                        <phase>package</phase>
                        <configuration>
                            <tasks>
                                <unzip src="${basedir}/../core/target/syncope.war" dest="${project.build.directory}/syncope-core-test">
                                    <patternset>
                                        <exclude name="**/content.xml" />
                                        <exclude name="**/persistence.properties" />
                                    </patternset>
                                </unzip>
                            </tasks>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <inherited>true</inherited>
                <configuration>
                    <redirectTestOutputToFile>true</redirectTestOutputToFile>
                    <encoding>utf-8</encoding>
                </configuration>
                <executions>
                    <execution>
                        <id>verify</id>
                        <goals>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <inherited>true</inherited>
                <executions>
                    <execution>
                        <id>set-bundles</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${bundles.directory}</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${basedir}/../identityconnectors/bundles/staticws/staticwebservice/target</directory>
                                    <includes>
                                        <include>*.jar</include>
                                    </includes>
                                    <excludes>
                                        <exclude>*-javadoc.jar</exclude>
                                        <exclude>*-sources.jar</exclude>
                                    </excludes>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>


            <plugin>
                <groupId>org.mortbay.jetty</groupId>
                <artifactId>maven-jetty-plugin</artifactId>
                <inherited>true</inherited>
                <configuration>
                    <stopKey>foo</stopKey>
                    <stopPort>9999</stopPort>
                    <connectors>
                        <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
                            <port>${jetty.port}</port>
                        </connector>
                    </connectors>
                </configuration>
                <executions>
                    <execution>
                        <id>start-jetty</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>run-war</goal>
                        </goals>
                        <configuration>
                            <scanIntervalSeconds>0</scanIntervalSeconds>
                            <daemon>true</daemon>
                        </configuration>
                    </execution>
                    <execution>
                        <id>stop-jetty</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>stop</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.codehaus.cargo</groupId>
                <artifactId>cargo-maven2-plugin</artifactId>
                <inherited>true</inherited>
                <configuration>
                    <wait>false</wait>
                    <container>
                        <containerId>tomcat6x</containerId>
                        <zipUrlInstaller>
                            <url>http://www.apache.org/dist/tomcat/tomcat-6/v6.0.29/bin/apache-tomcat-6.0.29.zip</url>
                            <installDir>${java.io.tmpdir}/tomcat6x</installDir>
                        </zipUrlInstaller>
                        <log>${cargo.log}</log>
                        <output>${cargo.output}</output>
                        <dependencies>
                            <dependency>
                                <location>${settings.localRepository}/org/hsqldb/hsqldb/${hsqldb.version}/hsqldb-${hsqldb.version}.jar</location>
                            </dependency>
                        </dependencies>
                    </container>
                    <configuration>
                        <type>standalone</type>
                        <home>target/tomcat6x</home>
                        <configfiles>
                            <configfile>
                                <file>${project.build.directory}/test-classes/catalina.properties</file>
                                <todir>conf</todir>
                            </configfile>
                        </configfiles>
                        <properties>
                            <cargo.servlet.port>${cargo.servlet.port}</cargo.servlet.port>
<!--                            <cargo.jvmargs>-Xdebug -Xrunjdwp:transport=dt_socket,address=9009,server=y,suspend=n</cargo.jvmargs>-->
                        </properties>
                        <deployables>
                            <deployable>
                                <location>${project.build.directory}/syncope-core-test</location>
                                <properties>
                                    <context>syncope</context>
                                </properties>
                            </deployable>
                        </deployables>
                    </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>

        </plugins>
            
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>

        <testResources>
            <testResource>
                <directory>src/test/resources</directory>
                <filtering>true</filtering>
            </testResource>
        </testResources>
    </build>

    <reporting>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <configuration>
                    <configLocation>${project.parent.basedir}/syncope_checks.xml</configLocation>
                </configuration>
            </plugin>
        </plugins>
    </reporting>

</project>
