<?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.2.9</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>javax.servlet</groupId>
      <artifactId>javax.servlet-api</artifactId>
      <scope>provided</scope>
    </dependency>

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

    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-core</artifactId>
    </dependency> 
    <dependency>
      <groupId>com.lmax</groupId>
      <artifactId>disruptor</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-slf4j-impl</artifactId>
    </dependency>
    <dependency>
      <groupId>commons-logging</groupId>
      <artifactId>commons-logging</artifactId>
    </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.apache.pdfbox</groupId>
      <artifactId>pdfbox</artifactId>
    </dependency>
      
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-core</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-web</artifactId>
    </dependency>

    <dependency>
      <groupId>com.fasterxml.jackson.jaxrs</groupId>
      <artifactId>jackson-jaxrs-json-provider</artifactId>
    </dependency>

    <dependency>
      <groupId>org.webjars</groupId>
      <artifactId>jquery-ui</artifactId>
    </dependency>
    <dependency>
      <groupId>org.webjars</groupId>
      <artifactId>codemirror</artifactId>
    </dependency>

    <!-- TEST -->
    <dependency>
      <groupId>org.activiti</groupId>
      <artifactId>activiti-webapp-explorer2</artifactId>            
      <type>war</type>
      <scope>test</scope>
    </dependency>
    <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>
    <!-- SELENIUM INTEGRATION TEST -->
    <dependency>
      <groupId>org.seleniumhq.selenium</groupId>
      <artifactId>selenium-java</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.seleniumhq.selenium</groupId>
      <artifactId>selenium-api</artifactId>
      <scope>test</scope>
    </dependency>
    <!-- /SELENIUM INTEGRATION TEST -->
    <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>net.tirasa.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>setupActivitiModeler</id>
            <phase>process-resources</phase>
            <configuration>
              <target>
                <unzip src="${settings.localRepository}/org/activiti/activiti-webapp-explorer2/${activiti.version}/activiti-webapp-explorer2-${activiti.version}.war" dest="${project.build.directory}/activiti-webapp-explorer2" />
                
                <mkdir dir="${activiti-modeler.directory}" />
                
                <mkdir dir="${activiti-modeler.directory}/editor" />
                <copy todir="${activiti-modeler.directory}/editor">
                  <fileset dir="${project.build.directory}/activiti-webapp-explorer2/editor">
                    <exclude name="oryx.js" />
                  </fileset>
                </copy>
                <copy file="${project.build.directory}/activiti-webapp-explorer2/WEB-INF/classes/plugins.xml" todir="${activiti-modeler.directory}/editor" />
                <copy file="${project.build.directory}/activiti-webapp-explorer2/WEB-INF/classes/stencilset.json" todir="${activiti-modeler.directory}/editor" />
                
                <mkdir dir="${activiti-modeler.directory}/explorer" />
                <copy todir="${activiti-modeler.directory}/explorer">
                  <fileset dir="${project.build.directory}/activiti-webapp-explorer2/explorer" />
                </copy>
                
                <mkdir dir="${activiti-modeler.directory}/libs" />
                <copy todir="${activiti-modeler.directory}/libs">
                  <fileset dir="${project.build.directory}/activiti-webapp-explorer2/libs" />
                </copy>
              </target>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
          <execution>
            <id>setupTestWebapp</id>
            <phase>pre-integration-test</phase>
            <configuration>
              <target>
                <unzip src="${basedir}/../core/target/syncope.war" dest="${cargo.run.dir}" />
                <copy file="${basedir}/../core/target/test-classes/org/apache/syncope/core/sync/TestSyncActions.class" todir="${cargo.run.dir}/WEB-INF/classes/org/apache/syncope/core/sync" />
                <copy file="${basedir}/../core/target/test-classes/org/apache/syncope/core/sync/TestSyncRule.class" todir="${cargo.run.dir}/WEB-INF/classes/org/apache/syncope/core/sync" />
                <copy file="${basedir}/../core/target/test-classes/org/apache/syncope/core/rest/data/DoubleValueAttributableTransformer.class" todir="${cargo.run.dir}/WEB-INF/classes/org/apache/syncope/core/rest/data" />
                <copy file="${project.build.directory}/test-classes/db.jsp" todir="${cargo.run.dir}" />
              </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>com.google.code.maven-replacer-plugin</groupId>
        <artifactId>replacer</artifactId>
        <executions>
          <execution>
            <phase>process-resources</phase>
            <goals>
              <goal>replace</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <file>${activiti-modeler.directory}/editor/oryx.debug.js</file>
          <tokenValueMap>${basedir}/src/main/resources/oryx.debug.js-tokenValueMap.properties</tokenValueMap>
          <unescape>true</unescape>
          <regex>false</regex>
        </configuration>
      </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>
          </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>-noverify ${javaagent} -Drebel.spring_plugin=true 
                -XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC -XX:MaxPermSize=256m</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>net.tirasa.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.lang3;version="[3,4)",
                  org.apache.syncope.client*;version=${project.version},
                  org.apache.syncope.common*;version=${project.version},
                  org.apache.wicket*;version="[6,7)",
                  com.fasterxml.jackson*;version="[2.2.2,3)",
                  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>
        <inherited>true</inherited>
        <configuration>
          <webResources>
            <resource>
              <directory>src/main/webapp</directory>
              <includes>
                <include>WEB-INF/web.xml</include>
              </includes>
              <filtering>true</filtering>
            </resource>
            <resource>
              <directory>${project.build.outputDirectory}</directory>
              <includes>
                <include>META-INF/DEPENDENCIES*</include>
              </includes>
            </resource>
            <resource>
              <directory>${basedir}</directory>
              <targetPath>META-INF</targetPath>
              <includes>
                <include>LICENSE</include>
                <include>NOTICE</include>
              </includes>
            </resource>
          </webResources>
          <packagingExcludes>WEB-INF/classes/META-INF/LICENSE*,WEB-INF/classes/META-INF/NOTICE*,WEB-INF/classes/META-INF/DEPENDENCIES*</packagingExcludes>
          <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>setupTestWebapp</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>debug</id>

      <properties>
        <skipTests>true</skipTests>
      </properties>

      <build>
        <defaultGoal>clean verify cargo:run</defaultGoal>

        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <inherited>true</inherited>
            <executions>
              <execution>
                <id>testWebXML</id>
                <phase>pre-integration-test</phase>
                <configuration>
                  <target>
                    <touch millis="0" file="${project.build.directory}/test-classes/web.xml" />
                    <war destfile="${project.build.directory}/${project.build.finalName}.war" update="true">                      
                      <mappedresources>
                        <fileset dir="${project.build.directory}/test-classes" includes="web.xml" />
                        <globmapper from="web.xml" to="WEB-INF/web.xml" />
                      </mappedresources>
                    </war>
                  </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>
              <configuration>
                <properties>
                  <cargo.jvmargs>-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n
                    -noverify -XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC -XX:MaxPermSize=256m</cargo.jvmargs>
                </properties>
              </configuration>
            </configuration>
            <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>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-antrun-plugin</artifactId>
            <inherited>true</inherited>
            <executions>
              <execution>
                <id>testWebXML</id>
                <phase>pre-integration-test</phase>
                <configuration>
                  <target>
                    <touch millis="0" file="${project.build.directory}/test-classes/web.xml" />
                    <war destfile="${project.build.directory}/${project.build.finalName}.war" update="true">                      
                      <mappedresources>
                        <fileset dir="${project.build.directory}/test-classes" includes="web.xml" />
                        <globmapper from="web.xml" to="WEB-INF/web.xml" />
                      </mappedresources>                      
                    </war>
                  </target>
                </configuration>
                <goals>
                  <goal>run</goal>
                </goals>
              </execution>
            </executions>
          </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>

          <plugin>
            <groupId>org.codehaus.cargo</groupId>
            <artifactId>cargo-maven2-plugin</artifactId>
            <inherited>true</inherited>
            <configuration>
              <configuration>
                <properties>
                  <cargo.jvmargs>-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n
                    -noverify ${javaagent} -Drebel.spring_plugin=true 
                    -XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC -XX:MaxPermSize=256m</cargo.jvmargs>
                </properties>
              </configuration>
            </configuration>
            <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>selenium</id>

      <properties>
        <javaagent />
      </properties>

      <build>
        <defaultGoal>clean verify</defaultGoal>
        <plugins>

          <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>

</project>
