<?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>4.1.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.cxf</groupId>
      <artifactId>cxf-spring-boot-starter-jaxrs</artifactId>
      <exclusions>
        <exclusion>
          <groupId>org.apache.tomcat.embed</groupId>
          <artifactId>tomcat-embed-el</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-tomcat</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-log4j2</artifactId>
    </dependency>
    <dependency>
      <groupId>com.lmax</groupId>
      <artifactId>disruptor</artifactId>
    </dependency>

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

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

    <dependency>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-rt-transports-http</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-rt-frontend-jaxws</artifactId>
      <version>${cxf.version}</version>
    </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.jakarta.rs</groupId>
      <artifactId>jackson-jakarta-rs-json-provider</artifactId>
    </dependency>

    <dependency>
      <groupId>org.springframework.kafka</groupId>
      <artifactId>spring-kafka-test</artifactId>
      <exclusions>
        <exclusion>
          <groupId>org.junit.jupiter</groupId>
          <artifactId>junit-jupiter-api</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.junit.platform</groupId>
          <artifactId>junit-platform-launcher</artifactId>
        </exclusion>
      </exclusions>
    </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>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>net.tirasa</groupId>
      <artifactId>groovy-security-sandbox</artifactId>
    </dependency>

    <dependency>
      <groupId>com.icegreen</groupId>
      <artifactId>greenmail</artifactId>
    </dependency>
    
    <dependency>
      <groupId>com.h2database</groupId>
      <artifactId>h2</artifactId>
    </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 dest="${bundles.directory}/soap">
                  <fileset dir="${bundles.directory}/" includes="net.tirasa.connid.bundles.soap-*-bundle.jar"/>
                  <patternset>
                    <include name="META-INF/*"/>
                    <include name="net/**"/>
                    <include name="lib/soap-utilities-${connid.soap.version}.jar"/>
                  </patternset>
                </unzip>

                <delete>
                  <fileset dir="${bundles.directory}/" includes="net.tirasa.connid.bundles.soap-*-bundle.jar"/>
                </delete>

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

                <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>tomcat11x</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>
              </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>${jakarta.faces.version}</version>
        </dependency>
      </dependencies>

      <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>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>
              </container>
              <configuration>
                <properties>
                  <cargo.glassfish.removeDefaultDatasource>false</cargo.glassfish.removeDefaultDatasource>
                  <cargo.jvmargs>-Djdk.util.zip.disableZip64ExtraFieldValidation=true
                    -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>wildfly39x</containerId>
                <zipUrlInstaller>
                  <url>https://github.com/wildfly/wildfly/releases/download/${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>
              </container>
              <configuration>
                <properties>
                  <cargo.jvmargs>-Xdebug</cargo.jvmargs>
                </properties>
              </configuration>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
