<?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>io.axual.utils</groupId>
    <artifactId>utils-parent</artifactId>
    <version>1.0.0</version>
    <name>Axual Utilities Parent</name>
    <description>Parent file for Axual utility projects</description>
    <modules>
        <module>axual-header-cleaning</module>
    </modules>
    <packaging>pom</packaging>

    <licenses>
        <license>
            <name>Apache 2.0</name>
            <url>http://www.apache.org/licenses/license-2.0.txt</url>
            <distribution>repo</distribution>
            <comments>A business-friendly OSS license</comments>
        </license>
    </licenses>

    <organization>
        <name>Axual B.V.</name>
        <url>https://axual.com/</url>
    </organization>
    <url>https://gitlab.com/axual/public/axual-utils</url>
    <inceptionYear>2025</inceptionYear>

    <scm>
        <developerConnection>scm:git:ssh://git@gitlab.com:axual/public/axual-utils.git
        </developerConnection>
        <connection>scm:git:ssh://git@gitlab.com:axual/public/axual-utils.git</connection>
        <url>scm:git:ssh://git@gitlab.com:axual/public/axual-utils.git</url>
        <tag>HEAD</tag>
    </scm>

    <developers>
        <developer>
            <name>Axual</name>
            <email>opensource@axual.com</email>
            <organization>Axual B.V.</organization>
            <organizationUrl>https://axual.com</organizationUrl>
        </developer>
    </developers>

    <properties>
        <!-- license properties -->
        <license.licensename>apache_v2</license.licensename>
        <!-- Utils are build for Java 17 by default, can be overridden in submodules -->
        <java.version>11</java.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

        <!-- Spring boot starter uses older version to ensure compatibility,
         use explicit version for new projects -->


        <!-- Test variables, can be overridden on Maven invocations -->
        <skipTests>false</skipTests>
        <skipUTs>false</skipUTs>
        <skipITs>false</skipITs>
    </properties>

    <dependencyManagement>
        <dependencies>
            <!-- Generic dependencies -->
            <dependency>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok</artifactId>
                <version>1.18.38</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
                <version>1.7.36</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>org.apache.kafka</groupId>
                <artifactId>kafka-clients</artifactId>
                <version>3.9.1</version>
                <scope>provided</scope>
            </dependency>

            <dependency>
                <groupId>org.junit</groupId>
                <artifactId>junit-bom</artifactId>
                <version>5.13.0</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>org.mockito</groupId>
                <artifactId>mockito-junit-jupiter</artifactId>
                <version>5.18.0</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.awaitility</groupId>
                <artifactId>awaitility</artifactId>
                <version>4.3.0</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.assertj</groupId>
                <artifactId>assertj-core</artifactId>
                <version>3.27.3</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-simple</artifactId>
                <version>1.7.36</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.testcontainers</groupId>
                <artifactId>junit-jupiter</artifactId>
                <version>1.21.1</version>
                <scope>test</scope>
            </dependency>


        </dependencies>

    </dependencyManagement>


    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.14.0</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <annotationProcessorPaths>
                        <path>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                            <version>1.18.38</version>
                        </path>
                    </annotationProcessorPaths>
                </configuration>
            </plugin>

            <!-- failsafe plugin: https://maven.apache.org/surefire/maven-failsafe-plugin -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>3.5.3</version>
                <configuration>
                    <skip>${skipTests}</skip>
                </configuration>
                <executions>
                    <execution>
                        <configuration>
                            <skip>${skipTests}</skip>
                            <skipTests>${skipITs}</skipTests>
                            <argLine>@{itCoverageAgent} -DskipUTs</argLine>
                            <includes>
                                <include>**/*IT.java</include>
                            </includes>
                            <reuseForks>true</reuseForks>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!-- surefire plugin: https://maven.apache.org/surefire/maven-surefire-plugin -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.5.3</version>
                <configuration>
                    <argLine>@{utCoverageAgent}</argLine>
                    <skipTests>${skipUTs}</skipTests>
                    <parallel>suites</parallel>
                    <includes>
                        <include>**/Test*.java</include>
                        <include>**/*Test.java</include>
                        <include>**/*Tests.java</include>
                        <include>**/*TestCase.java</include>
                    </includes>
                    <excludes>
                        <exclude>**/IT*.java</exclude>
                        <exclude>**/*IT.java</exclude>
                    </excludes>
                </configuration>
            </plugin>


            <!-- jacoco plugin: https://www.eclemma.org/jacoco/trunk/doc/maven.html -->
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.8.13</version>
                <executions>
                    <execution>
                        <id>prepare-unit-tests</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                        <configuration>
                            <destFile>${project.build.directory}/jacoco.exec</destFile>
                            <propertyName>utCoverageAgent</propertyName>
                        </configuration>
                        <phase>test-compile</phase>
                    </execution>
                    <execution>
                        <id>prepare-agent</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                        <phase>pre-integration-test</phase>
                        <configuration>
                            <destFile>${project.build.directory}/jacoco-it.exec</destFile>
                            <propertyName>itCoverageAgent</propertyName>
                        </configuration>
                    </execution>
                    <execution>
                        <id>jacoco-site</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>report-integration</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>report-integration</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <!-- install plugin -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-install-plugin</artifactId>
                <version>3.1.4</version>
            </plugin>
            <!-- deploy plugin -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>3.1.4</version>
            </plugin>
            <!-- dependency plugin -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>3.8.1</version>
            </plugin>

            <!-- jar plugin -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.4.2</version>
                <configuration>
                    <archive>
                        <manifest>
                            <addDefaultImplementationEntries>true
                            </addDefaultImplementationEntries>
                        </manifest>
                        <manifestEntries>
                            <Created-By>${java.vm.name} ${java.version} (${java.vm.vendor})
                            </Created-By>
                            <Implementation-Vendor-ArtifactId>${project.artifactId}
                            </Implementation-Vendor-ArtifactId>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>3.11.2</version>
                <configuration>
                    <source>${java.version}</source>
                </configuration>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <!-- source plugin -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>3.3.1</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <archive>
                        <manifest>
                            <addDefaultImplementationEntries>true
                            </addDefaultImplementationEntries>
                        </manifest>
                        <manifestEntries>
                            <Created-By>${java.vm.name} ${java.version} (${java.vm.vendor})
                            </Created-By>
                            <Implementation-Vendor-ArtifactId>${project.artifactId}
                            </Implementation-Vendor-ArtifactId>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>

            <!-- license plugin -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>license-maven-plugin</artifactId>
                <version>2.5.0</version>
                <configuration>
                    <licenseName>${license.licensename}</licenseName>
                    <outputDirectory>${project.basedir}</outputDirectory>
                    <thirdPartyFilename>NOTICE.txt</thirdPartyFilename>
                    <verbose>false</verbose>
                    <processStartTag>
                        ========================LICENSE_START=================================
                    </processStartTag>
                    <processEndTag>
                        =========================LICENSE_END==================================
                    </processEndTag>
                    <includes>
                        <includes>**/*.java</includes>
                    </includes>
                    <skipUpdateLicense>false</skipUpdateLicense>
                    <trimHeaderLine>true</trimHeaderLine>
                </configuration>
                <executions>
                    <execution>
                        <id>add-third-party-license</id>
                        <goals>
                            <goal>add-third-party</goal>
                        </goals>
                        <phase>generate-resources</phase>
                        <configuration>
                            <excludedScopes>system,test</excludedScopes>
                        </configuration>
                    </execution>
                    <execution>
                        <id>verify-license-headers</id>
                        <goals>
                            <goal>check-file-header</goal>
                        </goals>
                        <phase>process-sources</phase>
                    </execution>
                    <execution>
                        <id>generate-license-headers</id>
                        <goals>
                            <goal>update-file-header</goal>
                        </goals>
                        <phase>process-sources</phase>
                    </execution>
                </executions>
            </plugin>
        </plugins>

    </build>


    <profiles>
        <profile>
            <id>sign-artifacts</id>
            <build>
                <plugins>
                    <!-- Nexus Staging Plugin -->
                    <plugin>
                        <groupId>org.sonatype.plugins</groupId>
                        <artifactId>nexus-staging-maven-plugin</artifactId>
                        <version>1.7.0</version>
                        <extensions>true</extensions>
                        <configuration>
                            <serverId>maven_central_releases</serverId>
                            <nexusUrl>https://oss.sonatype.org/</nexusUrl>
                            <autoReleaseAfterClose>true</autoReleaseAfterClose>
                            <stagingProgressTimeoutMinutes>30</stagingProgressTimeoutMinutes>
                        </configuration>
                    </plugin>

                    <plugin>
                        <groupId>org.simplify4u.plugins</groupId>
                        <artifactId>sign-maven-plugin</artifactId>
                        <version>1.1.0</version>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>


    <distributionManagement>
        <snapshotRepository>
            <id>snapshots</id>
            <!--suppress UnresolvedMavenProperty -->
            <url>${axual.maven.repository.url.snapshots}</url>
        </snapshotRepository>
        <repository>
            <id>releases</id>
            <!--suppress UnresolvedMavenProperty -->
            <url>${axual.maven.repository.url.releases}</url>
        </repository>
    </distributionManagement>

</project>
