<?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-fit</artifactId>
    <version>3.0.1</version>
  </parent>

  <name>Apache Syncope FIT Build Tools</name>
  <description>Apache Syncope FIT Build Tools</description>
  <groupId>org.apache.syncope.fit</groupId>
  <artifactId>syncope-fit-build-tools</artifactId>
  <packaging>war</packaging>
  
  <properties>
    <rootpom.basedir>${basedir}/../..</rootpom.basedir>
  </properties>

  <dependencies>
    <dependency> 
      <groupId>jakarta.servlet</groupId> 
      <artifactId>jakarta.servlet-api</artifactId> 
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.apache.bval</groupId>
      <artifactId>bval-jsr</artifactId>
    </dependency>

    <dependency>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-spring-boot-starter-jaxrs</artifactId>
      <exclusions>
        <exclusion>
          <groupId>org.apache.tomcat.embed</groupId>
          <artifactId>tomcat-embed-el</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-log4j2</artifactId>
    </dependency>

    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-jdbc</artifactId>
    </dependency>

    <dependency>
      <groupId>com.unboundid</groupId>
      <artifactId>unboundid-ldapsdk</artifactId>
    </dependency>

    <dependency>
      <groupId>jakarta.xml.ws</groupId>
      <artifactId>jakarta.xml.ws-api</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-core</artifactId>
      <version>${cxf.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-rt-transports-http</artifactId>
      <version>${cxf.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-rt-ws-policy</artifactId>
      <version>${cxf.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-rt-wsdl</artifactId>
      <version>${cxf.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-rt-frontend-jaxws</artifactId>
      <version>${cxf.version}</version>
    </dependency>
        
    <dependency>
      <groupId>net.tirasa.connid.bundles.soap</groupId>
      <artifactId>soap-utilities</artifactId>
      <version>${connid.soap.version}</version>
      <exclusions>
        <exclusion>
          <groupId>org.apache.cxf</groupId>
          <artifactId>cxf-rt-frontend-jaxws</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-rt-frontend-jaxrs</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-rt-rs-service-description</artifactId>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.jaxrs</groupId>
      <artifactId>jackson-jaxrs-json-provider</artifactId>
    </dependency>

    <dependency>
      <groupId>net.tirasa.connid</groupId>
      <artifactId>connector-framework</artifactId>
    </dependency>
    <dependency>
      <groupId>net.tirasa.connid</groupId>
      <artifactId>connector-framework-internal</artifactId>
    </dependency>
    <dependency>
      <groupId>net.tirasa.connid</groupId>
      <artifactId>slf4j-logging</artifactId>
    </dependency>

    <dependency>
      <groupId>org.apache.groovy</groupId>
      <artifactId>groovy</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.groovy</groupId>
      <artifactId>groovy-templates</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.groovy</groupId>
      <artifactId>groovy-xml</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.groovy</groupId>
      <artifactId>groovy-jsr223</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.groovy</groupId>
      <artifactId>groovy-datetime</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.groovy</groupId>
      <artifactId>groovy-dateutil</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.groovy</groupId>
      <artifactId>groovy-sql</artifactId>
    </dependency>

    <dependency>
      <groupId>com.icegreen</groupId>
      <artifactId>greenmail</artifactId>
    </dependency>
    
    <dependency>
      <groupId>com.h2database</groupId>
      <artifactId>h2</artifactId>
    </dependency>

    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
    </dependency>
    <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>com.lmax</groupId>
      <artifactId>disruptor</artifactId>
    </dependency>
    <dependency>
      <groupId>commons-logging</groupId>
      <artifactId>commons-logging</artifactId>
      <scope>provided</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <inherited>true</inherited>
        <executions>
          <execution>
            <id>set-bundles</id>
            <phase>process-resources</phase>
            <goals>
              <goal>copy</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <!-- repackage the ConnId SOAP bundle to avoid conflicts with local CXF's SOAP service implementation -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <inherited>true</inherited>
        <executions>
          <execution>
            <id>repack-soap-bundle</id>
            <phase>prepare-package</phase>
            <configuration>
              <target>
                <unzip src="${bundles.directory}/net.tirasa.connid.bundles.soap-${connid.soap.version}-bundle.jar"
                       dest="${bundles.directory}/soap">
                  <patternset>
                    <include name="META-INF/*"/>
                    <include name="net/**"/>
                    <include name="lib/soap-utilities-${connid.soap.version}.jar"/>
                  </patternset>
                </unzip>

                <delete file="${bundles.directory}/net.tirasa.connid.bundles.soap-${connid.soap.version}-bundle.jar"/>

                <jar destfile="${bundles.directory}/net.tirasa.connid.bundles.soap-${connid.soap.version}-bundle.jar"
                     basedir="${bundles.directory}/soap"
                     filesetmanifest="merge"/>                  

                <delete dir="${bundles.directory}/soap"/>
              </target>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

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

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <inherited>true</inherited>
        <configuration>
          <webResources>
            <resource>
              <directory>${basedir}</directory>
              <targetPath>META-INF</targetPath>
              <includes>
                <include>LICENSE</include>
                <include>NOTICE</include>
              </includes>
            </resource>
            <resource>
              <directory>${bundles.directory}</directory>
              <targetPath>WEB-INF/classes/bundles</targetPath>
            </resource>
          </webResources>
          <packagingExcludes>WEB-INF/classes/META-INF/LICENSE*,WEB-INF/classes/META-INF/NOTICE*,WEB-INF/classes/META-INF/DEPENDENCIES*</packagingExcludes>
        </configuration>
      </plugin>
    </plugins>
       
    <resources>
      <resource>
        <directory>src/main/resources</directory>
        <filtering>true</filtering>
      </resource>
      <resource>
        <directory>${basedir}/../../src/main/resources</directory>
        <filtering>true</filtering>
        <includes>
          <include>banner.txt</include>
        </includes>
      </resource>
      <resource>
        <directory>${basedir}</directory>
        <targetPath>META-INF</targetPath>
        <includes>
          <include>LICENSE</include>
          <include>NOTICE</include>
        </includes>
      </resource>
    </resources>
  </build>
  
  <profiles>
    <profile>
      <id>debug</id>
      
      <build>
        <defaultGoal>clean verify cargo:run</defaultGoal>
        
        <plugins>
          <plugin>
            <groupId>org.codehaus.cargo</groupId>
            <artifactId>cargo-maven3-plugin</artifactId>
            <inherited>true</inherited>
            <configuration>
              <container>
                <containerId>tomcat9x</containerId>
                <zipUrlInstaller>
                  <url>https://repo1.maven.org/maven2/org/apache/tomcat/tomcat/${tomcat.version}/tomcat-${tomcat.version}.zip</url>
                  <downloadDir>${settings.localRepository}/org/codehaus/cargo/cargo-container-archives</downloadDir>
                  <extractDir>${project.build.directory}/cargo/extract</extractDir>
                </zipUrlInstaller>
                <timeout>300000</timeout>
                <log>${cargo.log}</log>
                <output>${cargo.output}</output>
              </container>
              <configuration>
                <properties>
                  <cargo.jvmargs>-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n</cargo.jvmargs>
                </properties>
              </configuration>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>payara</id>

      <dependencies>
        <dependency>
          <groupId>org.glassfish</groupId>
          <artifactId>jakarta.faces</artifactId>
          <version>${javax.faces.version}</version>
        </dependency>
      </dependencies>

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

        <plugins>
          <plugin>
            <artifactId>maven-war-plugin</artifactId>
            <configuration>
              <packagingExcludes>WEB-INF/lib/bval-*.jar</packagingExcludes>
            </configuration>
          </plugin>

          <plugin>
            <groupId>org.codehaus.cargo</groupId>
            <artifactId>cargo-maven3-plugin</artifactId>
            <inherited>true</inherited>
            <configuration>
              <container>
                <containerId>payara</containerId>
                <zipUrlInstaller>
                  <url>https://repo1.maven.org/maven2/fish/payara/distributions/payara/${payara.version}/payara-${payara.version}.zip</url>
                  <downloadDir>${settings.localRepository}/org/codehaus/cargo/cargo-container-archives</downloadDir>
                  <extractDir>${project.build.directory}/cargo/extract</extractDir>
                </zipUrlInstaller>
                <timeout>300000</timeout>
                <log>${cargo.log}</log>
                <output>${cargo.output}</output>
              </container>
              <configuration>
                <properties>
                  <cargo.glassfish.removeDefaultDatasource>false</cargo.glassfish.removeDefaultDatasource>
                  <cargo.jvmargs>-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n</cargo.jvmargs>
                </properties>
              </configuration>
              <skip>${skipTests}</skip>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>wildfly</id>
      
      <build>
        <defaultGoal>clean verify cargo:run</defaultGoal>
        
        <plugins>
          <plugin>
            <groupId>org.codehaus.cargo</groupId>
            <artifactId>cargo-maven3-plugin</artifactId>
            <inherited>true</inherited>
            <configuration>
              <container>
                <containerId>wildfly23x</containerId>
                <zipUrlInstaller>
                  <url>https://download.jboss.org/wildfly/${wildfly.version}/wildfly-${wildfly.version}.zip</url>
                  <downloadDir>${settings.localRepository}/org/codehaus/cargo/cargo-container-archives</downloadDir>
                  <extractDir>${project.build.directory}/cargo/extract</extractDir>
                </zipUrlInstaller>
                <timeout>300000</timeout>
                <log>${cargo.log}</log>
                <output>${cargo.output}</output>
              </container>
              <configuration>
                <properties>
                  <cargo.jvmargs>-Xdebug</cargo.jvmargs>
                </properties>
              </configuration>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
