<?xml version="1.0" encoding="UTF-8"?>

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

    <groupId>com.oracle.database.saga</groupId>
    <artifactId>parent-pom</artifactId>
    <version>23.3.0</version>
    <name>saga</name>
    <packaging>pom</packaging>

    <description>Oracle saga framework</description>
    <url>https://docs.oracle.com/en/database/oracle/oracle-database/23/adfns/developing-applications-saga.html#GUID-DE723847-0907-48E8-87C8-9A5D2DB63A8D</url>

    <licenses>
        <license>
            <name>Oracle Free Use Terms and Conditions (FUTC)</name>
            <url>
                https://www.oracle.com/downloads/licenses/oracle-free-license.html</url>
        </license>
    </licenses>

    <developers>
        <developer>
            <organization>Oracle America, Inc.</organization>
            <organizationUrl>http://www.oracle.com</organizationUrl>
        </developer>
    </developers>

    <scm>
        <url></url>
    </scm>

    <modules>
        <module>saga</module>
        <module>filter</module>
        <module>code-coverage</module>
    </modules>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>10</maven.compiler.source>
        <maven.compiler.target>10</maven.compiler.target>
        <sonar.coverage.jacoco.xmlReportPaths>
            ${maven.multiModuleProjectDirectory}/tests/target/site/jacoco-aggregate/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
        <jacoco.plugin.version>0.8.10</jacoco.plugin.version>
        <surefire.plugin.version>3.1.0</surefire.plugin.version>
        <failsafe.plugin.version>3.1.0</failsafe.plugin.version>
        <skip.IT>true</skip.IT>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.oracle.database.messaging</groupId>
                <artifactId>aqapi</artifactId>
                <version>23.2.0.0</version>
            </dependency>
            <dependency>
                <groupId>javax.jms</groupId>
                <artifactId>javax.jms-api</artifactId>
                <version>2.0.1</version>
            </dependency>
            <dependency>
                <groupId>com.oracle.database.jdbc</groupId>
                <artifactId>ojdbc11</artifactId>
                <version>23.2.0.0</version>
            </dependency>
            <dependency>
                <groupId>org.junit.jupiter</groupId>
                <artifactId>junit-jupiter-api</artifactId>
                <version>5.9.2</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.mockito</groupId>
                <artifactId>mockito-junit-jupiter</artifactId>
                <version>5.3.1</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
                <version>2.0.7</version>
            </dependency>
            <dependency>
                <groupId>org.eclipse.microprofile.lra</groupId>
                <artifactId>microprofile-lra-api</artifactId>
                <version>2.0</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>com.oracle.database.security</groupId>
                <artifactId>oraclepki</artifactId>
                <version>23.2.0.0</version>
            </dependency>
            <dependency>
                <groupId>com.oracle.database.security</groupId>
                <artifactId>osdt_cert</artifactId>
                <version>21.10.0.0</version>
            </dependency>
            <dependency>
                <groupId>com.oracle.database.security</groupId>
                <artifactId>osdt_core</artifactId>
                <version>21.10.0.0</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <pluginManagement><!-- lock down plugins versions to avoid using Maven
            defaults (may be moved to parent pom) -->
            <plugins>
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.8.1</version>
                    <configuration>
                        <release>11</release>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.jacoco</groupId>
                    <artifactId>jacoco-maven-plugin</artifactId>
                    <version>${jacoco.plugin.version}</version>
                    <executions>
                        <!-- jacoco agent for unit-tests code coverage -->
                        <execution>
                            <id>initialize-coverage-before-unit-test-execution</id>
                            <goals>
                                <goal>prepare-agent</goal>
                            </goals>
                        </execution>
                        <!-- jacoco agent for integration-tests code coverage -->
                        <execution>
                            <id>
                                initialize-coverage-before-integration-test-execution</id>
                            <goals>
                                <goal>prepare-agent</goal>
                            </goals>
                            <phase>pre-integration-test</phase>
                            <configuration>
                                <propertyName>integrationTestCoverageAgent</propertyName>
                            </configuration>
                        </execution>
                        <execution>
                            <id>report</id>
                            <goals>
                                <goal>report</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>

                <!-- UNIT tests-->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>${surefire.plugin.version}</version>

                    <configuration>
                        <!--<skipTests>${skipTests}</skipTests> -->
                        <excludes>
                            <exclude>**/*IT.java</exclude>
                        </excludes>
                        <!--
               NOTE: In case if you need to pass in
                        special JVM argumengts for instance say, to enable Java
                        language
               preview features, the following
                        is how it MUST be done. The @{argLine} goes through late
                        evaluattion that
               points to Jacoco agent
                        JVM argument followed by any additional JVM arguments of
                        your choice each separated
               by space. The
                        expression @{argLine} retains Jacoco JVM agent argument.
                        Without this any additional JVM
               arguments
                        that you add will be taken but you lose Jacoco's
                        argument causing to lose code coverage report
               files
                        and hence the coverage report.
          -->
                        <argLine>@{argLine} --enable-preview</argLine>
                    </configuration>
                </plugin>

                <!-- INTEGRATION tests -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-failsafe-plugin</artifactId>
                    <version>${failsafe.plugin.version}</version>
                    <executions>
                        <execution>
                            <id>integration-tests</id>
                            <goals>
                                <goal>integration-test</goal>
                                <goal>verify</goal>
                            </goals>
                            <configuration>
                                <skipITs>${skip.IT}</skipITs>
                                <additionalClasspathElements>
                                    <additionalClasspathElement>
                                        ${basedir}/target/classes</additionalClasspathElement>
                                </additionalClasspathElements>
                                <includes>
                                    <include>**/*IT.java</include>
                                </includes>
                                <!--
                   NOTE: When running as a
                                Maven plugin, the JaCoCo agent configuration is
                                prepared by invoking the 
                   prepare-agent
                                or prepare-agent-integration goals, before the
                                actual tests are run. This sets a property
                   named
                                argLine which points to the JaCoCo agent, later
                                passed as a JVM argument to the test runner.
              -->
                                <argLine>${integrationTestCoverageAgent}</argLine>

                                <!--
                   NOTE: In case if you
                                need to pass in special JVM argumengts for
                                instance say, to enable Java language
               preview
                                features, the following is how it MUST be done.
                                The @{argLine} goes through late evaluattion
                                that
               points to Jacoco agent JVM
                                argument followed by any additional JVM
                                arguments of your choice each separated
               by
                                space. The expression @{argLine} retains Jacoco
                                JVM agent argument. Without this any additional
                                JVM
               arguments that you add will
                                be taken but you lose Jacoco's argument causing
                                to lose code coverage report
               files
                                and hence the coverage report.
              -->
                                <argLine>@{argLine} --enable-preview</argLine>
                            </configuration>
                        </execution>

                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <profiles>
        <profile>
            <id>coverage</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.jacoco</groupId>
                        <artifactId>jacoco-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>prepare-agent</id>
                                <goals>
                                    <goal>prepare-agent</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>
