<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.green-code-initiative</groupId>
    <artifactId>creedengo-integration-test</artifactId>
    <version>0.3.0</version>

    <name>creedengo integration test</name>
    <description>Repository that contains integration testing framework for creedengo plugins.</description>
    <url>https://github.com/green-code-initiative/creedengo-integration-test</url>

    <inceptionYear>2025</inceptionYear>
    <organization>
        <name>green-code-initiative</name>
        <url>https://github.com/green-code-initiative</url>
    </organization>

    <licenses>
        <license>
            <name>GPL v3</name>
            <url>https://www.gnu.org/licenses/gpl-3.0.en.html</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <developers>
        <developer>
            <name>Maxime MALGORN</name>
            <email>utarwyn@users.noreply.github.com</email>
            <organization>green-code-initiative</organization>
            <organizationUrl>https://github.com/green-code-initiative</organizationUrl>
        </developer>
        <developer>
            <name>Geoffrey LALLOUÉ</name>
            <email>glalloue@users.noreply.github.com</email>
            <organization>green-code-initiative</organization>
            <organizationUrl>https://github.com/green-code-initiative</organizationUrl>
        </developer>
        <developer>
            <name>David DE CARVALHO</name>
            <email>dedece35@users.noreply.github.com</email>
            <organization>green-code-initiative</organization>
            <organizationUrl>https://github.com/green-code-initiative</organizationUrl>
        </developer>
        <developer>
            <name>Olivier LE GOAËR</name>
            <email>olegoaer@users.noreply.github.com</email>
            <organization>green-code-initiative</organization>
            <organizationUrl>https://github.com/green-code-initiative</organizationUrl>
        </developer>
        <developer>
            <name>Jean-Yves CRONIER</name>
            <email>jycr@users.noreply.github.com</email>
            <organization>green-code-initiative</organization>
            <organizationUrl>https://github.com/green-code-initiative</organizationUrl>
        </developer>
    </developers>

    <scm>
        <connection>scm:git:https://github.com/green-code-initiative/creedengo-integration-test</connection>
        <developerConnection>scm:git:https://github.com/green-code-initiative/creedengo-integration-test</developerConnection>
        <url>https://github.com/green-code-initiative/creedengo-integration-test</url>
        <tag>HEAD</tag>
    </scm>
    <issueManagement>
        <system>GitHub</system>
        <url>https://github.com/green-code-initiative/creedengo-integration-test/issues</url>
    </issueManagement>

    <properties>

        <sonar.organization>green-code-initiative</sonar.organization>
        <sonar.host.url>https://sonarcloud.io</sonar.host.url>

        <!--
            Default version when disabling Maven `maven-git-versioning-extension` extension
            cf. https://github.com/qoomon/maven-git-versioning-extension#intellij&#45;&#45;-multi-modules-projects
        -->
        <revision>current-SNAPSHOT</revision>

        <!-- Helps ensure build reproducibility (cf. https://maven.apache.org/guides/mini/guide-reproducible-builds.html) -->
        <!--suppress UnresolvedMavenProperty -->
        <project.build.outputTimestamp>${git.commit.timestamp.datetime}</project.build.outputTimestamp>

        <java.version>17</java.version>
        <maven.compiler.source>${java.version}</maven.compiler.source>
        <maven.compiler.target>${java.version}</maven.compiler.target>
        <!-- to prevent message: system modules path not set in conjunction with -source 11 -->
        <maven.compiler.release>${java.version}</maven.compiler.release>

        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

        <!-- URL of the Maven repository where sonarqube will be downloaded -->
        <test-it.orchestrator.artifactory.url>https://repo1.maven.org/maven2</test-it.orchestrator.artifactory.url>
        <test-it.sonarqube.version>26.2.0.119303</test-it.sonarqube.version>

        <assertj.version>3.27.7</assertj.version>

        <!-- version 6 KO when component integrated and integration test launched -->
        <!-- error : java.lang.NoSuchMethodError: 'java.lang.Object org.apache.commons.lang3.ObjectUtils.getIfNull(java.lang.Object, java.lang.Object)' -->
<!--        <orchestrator.version>6.1.0.3962</orchestrator.version>-->
        <orchestrator.version>5.6.2.2625</orchestrator.version>

        <logback.version>1.5.31</logback.version>

        <data-url-handler.version>0.0.1</data-url-handler.version>

        <!-- Mutation testing -->
        <pitest.version>1.17.3</pitest.version>
        <pitest-junit5-plugin.version>1.2.1</pitest-junit5-plugin.version>
        <junit.version>5.13.4</junit.version>

    </properties>

    <dependencyManagement>
        <dependencies>
            <!-- Align JUnit Platform versions to avoid conflicts with PITest -->
            <dependency>
                <groupId>org.junit.platform</groupId>
                <artifactId>junit-platform-launcher</artifactId>
                <version>1.13.4</version>
            </dependency>
            <dependency>
                <groupId>org.junit.platform</groupId>
                <artifactId>junit-platform-engine</artifactId>
                <version>1.13.4</version>
            </dependency>
            <dependency>
                <groupId>org.junit.jupiter</groupId>
                <artifactId>junit-jupiter-engine</artifactId>
                <version>${junit.version}</version>
            </dependency>
            <dependency>
                <groupId>org.junit.jupiter</groupId>
                <artifactId>junit-jupiter-api</artifactId>
                <version>${junit.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>

        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <version>${assertj.version}</version>
        </dependency>

        <!-- Dependencies used by integration tests -->
        <dependency>
            <groupId>org.sonarsource.orchestrator</groupId>
            <artifactId>sonar-orchestrator-junit5</artifactId>
            <version>${orchestrator.version}</version>
        </dependency>
        <dependency>
            <groupId>org.sonarsource.sonarqube</groupId>
            <artifactId>sonar-ws</artifactId>
            <version>${test-it.sonarqube.version}</version>
        </dependency>
        <dependency>
            <groupId>io.github.jycr</groupId>
            <artifactId>java-data-url-handler</artifactId>
            <version>${data-url-handler.version}</version>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>${logback.version}</version>
        </dependency>

        <!-- JUnit Jupiter engine required by the PITest minion to run tests -->
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <profiles>
        <profile>
            <id>mutation-testing</id>
            <!--
                Mutation testing with PITest, targeting only ProfileBackupTest.
                Run with: ./mvnw test-compile pitest:mutationCoverage -P mutation-testing
            -->
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.pitest</groupId>
                        <artifactId>pitest-maven</artifactId>
                        <version>${pitest.version}</version>
                        <dependencies>
                            <!-- JUnit 5 plugin for PITest -->
                            <dependency>
                                <groupId>org.pitest</groupId>
                                <artifactId>pitest-junit5-plugin</artifactId>
                                <version>${pitest-junit5-plugin.version}</version>
                                <exclusions>
                                    <!-- Exclude the launcher bundled by the plugin to use the project's one -->
                                    <exclusion>
                                        <groupId>org.junit.platform</groupId>
                                        <artifactId>junit-platform-launcher</artifactId>
                                    </exclusion>
                                </exclusions>
                            </dependency>
                            <!-- Provide the correct TestEngine to the PITest minion -->
                            <dependency>
                                <groupId>org.junit.jupiter</groupId>
                                <artifactId>junit-jupiter-engine</artifactId>
                                <version>${junit.version}</version>
                            </dependency>
                            <!-- Launcher aligned with the project version -->
                            <dependency>
                                <groupId>org.junit.platform</groupId>
                                <artifactId>junit-platform-launcher</artifactId>
                                <version>1.13.4</version>
                            </dependency>
                        </dependencies>
                        <configuration>
                            <!-- Production classes to mutate -->
                            <targetClasses>
                                <param>org.greencodeinitiative.creedengo.integration.tests.profile.ProfileBackup</param>
                            </targetClasses>
                            <!-- Only ProfileBackupTest as test suite -->
                            <targetTests>
                                <param>org.greencodeinitiative.creedengo.integration.tests.profile.ProfileBackupTest</param>
                            </targetTests>
                            <!-- Java 17 flags required by PITest -->
                            <jvmArgs>
                                <jvmArg>--add-opens=java.base/java.lang=ALL-UNNAMED</jvmArg>
                                <jvmArg>--add-opens=java.base/java.util=ALL-UNNAMED</jvmArg>
                                <jvmArg>--add-opens=java.base/java.io=ALL-UNNAMED</jvmArg>
                            </jvmArgs>
                            <!-- Standard mutation operators -->
                            <mutators>
                                <mutator>STRONGER</mutator>
                            </mutators>
                            <!-- Quality thresholds: fail if score < 80% -->
                            <mutationThreshold>80</mutationThreshold>
                            <coverageThreshold>80</coverageThreshold>
                            <!-- HTML + XML report -->
                            <outputFormats>
                                <outputFormat>HTML</outputFormat>
                                <outputFormat>XML</outputFormat>
                            </outputFormats>
                            <timestampedReports>false</timestampedReports>
                            <verbose>false</verbose>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>maven-central-publishing</id>
            <!--
                For publishing in Maven Central.
                For more information:
                - https://central.sonatype.org/publish/publish-guide/#deployment
                - https://central.sonatype.org/publish/release/#login-into-ossrh
            -->
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <version>3.4.0</version>
                        <executions>
                            <execution>
                                <id>attach-sources</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>jar-no-fork</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>3.12.0</version>
                        <executions>
                            <execution>
                                <id>attach-javadoc</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <stylesheet>java</stylesheet>
                            <doclint>none</doclint>
                        </configuration>
                    </plugin>
                    <plugin>
                        <!--
                            For publishing in Maven Central, GPG key must be published to one of following servers:
                            - keyserver.ubuntu.com
                            - keys.openpgp.org
                            - pgp.mit.edu

                            For more informatino: https://central.sonatype.org/publish/requirements/gpg/#distributing-your-public-key
                        -->
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>3.2.8</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                                <configuration>
                                    <gpgArguments>
                                        <arg>--pinentry-mode</arg>
                                        <arg>loopback</arg>
                                    </gpgArguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.sonatype.central</groupId>
                        <artifactId>central-publishing-maven-plugin</artifactId>
                        <version>0.10.0</version>
                        <extensions>true</extensions>
                        <configuration>
                            <publishingServerId>central</publishingServerId>
                            <tokenAuth>true</tokenAuth>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
