<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you 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.apache.syncope</groupId>
    <artifactId>syncope</artifactId>
    <version>1.1.4</version>
  </parent>

  <name>Apache Syncope Console</name>
  <description>Apache Syncope Console</description>

  <groupId>org.apache.syncope</groupId>
  <artifactId>syncope-console</artifactId>
  <packaging>war</packaging>

  <distributionManagement>
    <site>
      <id>syncope.website</id>
      <name>Apache Syncope website</name>
      <url>${site.deploymentBaseUrl}/${project.artifactId}</url>
    </site>
  </distributionManagement>
  
  <dependencies>

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

    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>servlet-api</artifactId>
      <scope>provided</scope>
    </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>org.apache.httpcomponents</groupId>
      <artifactId>httpclient</artifactId>
    </dependency>

    <!-- TEST -->
    <dependency>
      <groupId>org.apache.syncope</groupId>
      <artifactId>syncope-build-tools</artifactId>
      <version>${project.version}</version>
      <type>war</type>
      <scope>test</scope>
    </dependency>
    <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>wssample</artifactId>
      <type>war</type>
      <scope>test</scope>
    </dependency>
    <!-- /TEST -->
  </dependencies>

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

    <plugins>

      <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}" />
                <copy file="${project.build.directory}/test-classes/db.jsp" todir="${cargo.run.dir}" />
                <copy todir="${cargo.run.dir}/WEB-INF/classes" includeEmptyDirs="false">
                  <fileset dir="${project.build.directory}/test-classes">
                    <exclude name="**/*.class" />
                    <exclude name="restClientContext.xml" />
                  </fileset>
                </copy>
              </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="${test.csvdir.path}" 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>
            <dependencies>
              <dependency>
                <groupId>com.h2database</groupId>
                <artifactId>h2</artifactId>
              </dependency>
            </dependencies>
            <systemProperties>
              <syncope.console.configuration>${project.build.directory}/test-classes/configuration.properties</syncope.console.configuration>
            </systemProperties>
          </container>
          <configuration>
            <type>standalone</type>
            <properties>
              <cargo.servlet.port>${cargo.servlet.port}</cargo.servlet.port>
              <cargo.tomcat.ajp.port>${cargo.tomcat.ajp.port}</cargo.tomcat.ajp.port>
              <cargo.rmi.port>${cargo.rmi.port}</cargo.rmi.port>

              <!--<cargo.jvmargs>-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n</cargo.jvmargs>-->
              <cargo.jvmargs>-noverify ${javaagent} -Drebel.spring_plugin=false -Xms512m -Xmx1024m -XX:PermSize=512m -XX:MaxPermSize=1024m</cargo.jvmargs>
            </properties>
            <configfiles>
              <configfile>
                <file>${project.build.directory}/test-classes/context.xml</file>
                <todir>conf/</todir>
                <tofile>context.xml</tofile>
              </configfile>
            </configfiles>
          </configuration>
          <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>
              <groupId>org.connid.bundles.soap</groupId>
              <artifactId>wssample</artifactId>
              <type>war</type>
              <properties>
                <context>wssample</context>
              </properties>
            </deployable>
            <deployable>
              <groupId>org.apache.syncope</groupId>
              <artifactId>syncope-build-tools</artifactId>
              <type>war</type>
              <properties>
                <context>syncope-build-tools</context>
              </properties>
            </deployable>
          </deployables>
        </configuration>
      </plugin>
      
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-checkstyle-plugin</artifactId>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-pmd-plugin</artifactId>
      </plugin>

      <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <executions>
          <execution>
            <id>bundle-manifest</id>
            <phase>process-classes</phase>
            <goals>
              <goal>manifest</goal>
            </goals>
            <configuration>
              <instructions>
                <Bundle-Name>${project.name}</Bundle-Name>
                <Bundle-SymbolicName>org.apache.syncope.console</Bundle-SymbolicName>
                <Bundle-Version>${project.version}</Bundle-Version>
                <Export-Package>
                  org.apache.syncope.console*;version=${project.version};-split-package:=merge-first
                </Export-Package>
                <Import-Package>
                  javax.servlet,
                  javax.xml*,
                  org.w3c.dom,
                  org.apache.commons.lang*;version="[2.6,3)",
                  org.apache.http*;version="[4,5)",
                  org.apache.syncope.client*;version=${project.version},
                  org.apache.syncope.common*;version=${project.version},
                  org.apache.wicket*;version="[6,7)",
                  org.codehaus.jackson*;version="[1.9,2)",
                  org.springframework*;version="[3,4)",
                  ch.qos.logback.classic;resolution:=optional,
                  javax.swing.tree;resolution:=optional,
                  org.slf4j;resolution:=optional
                </Import-Package>
              </instructions>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <configuration>
          <archive>
            <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
          </archive>
        </configuration>
      </plugin>
    </plugins>

    <resources>
      <resource>
        <directory>src/main/resources</directory>
        <filtering>true</filtering>
      </resource>
      <resource>
        <directory>..</directory>
        <targetPath>META-INF</targetPath>
        <includes>
          <include>LICENSE</include>
          <include>NOTICE</include>
        </includes>
      </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>skipTests</id>
      <properties>
        <javaagent />
      </properties>
      
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <inherited>true</inherited>
            <executions>
              <execution>
                <id>set-bundles</id>
                <phase>none</phase>
              </execution>
            </executions>
          </plugin>
          
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <inherited>true</inherited>
            <executions>
              <execution>
                <id>explodeSyncopeWAR</id>
                <phase>none</phase>
              </execution>
              <execution>
                <id>setupCSV</id>
                <phase>none</phase>
              </execution>
            </executions>
          </plugin>
      
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <inherited>true</inherited>
            <configuration>
              <skipTests>${skipTests}</skipTests>
            </configuration>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <inherited>true</inherited>
            <configuration>
              <skipTests>${skipTests}</skipTests>
            </configuration>
          </plugin>
          
          <plugin>
            <groupId>org.codehaus.cargo</groupId>
            <artifactId>cargo-maven2-plugin</artifactId>
            <inherited>true</inherited>
            <executions>
              <execution>
                <id>start-container</id>
                <phase>none</phase>
              </execution>
              <execution>
                <id>stop-container</id>
                <phase>none</phase>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>dev</id>
      <properties>
        <skipTests>true</skipTests>
        <javaagent />
      </properties>
      <build>
        <defaultGoal>clean verify cargo:run</defaultGoal>
        
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <configuration>
              <webXml>${project.build.directory}/test-classes/web.xml</webXml>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>jrebel</id>
      <properties>
        <skipTests>true</skipTests>
        <javaagent>-javaagent:${env.REBEL_HOME}/jrebel.jar</javaagent>
      </properties>
      <build>
        <defaultGoal>clean verify cargo:run</defaultGoal>

        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <configuration>
              <webXml>${project.build.directory}/test-classes/web.xml</webXml>
            </configuration>
          </plugin>
          
          <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-integratison-test</phase>
                <goals>
                  <goal>stop</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

</project>
