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

    <!-- region project data -->
    <groupId>mx.whiteweb.sdev</groupId>
    <artifactId>white-utils</artifactId>
    <version>1.0.4</version>
    <name>${project.groupId}:${project.artifactId}</name>
    <description>A lightweight library containing shared and generic utility classes for Java-based projects.</description>
    <url>https://github.com/WhiteOrganization/white-utils</url>
    <!-- This section (packaging) is defined because the project is meant to be a library and a JAR will be generated. -->
    <packaging>jar</packaging>
    <!--endregion-->

    <properties>
        <!-- region Configure Java version & Main full package and class name -->
        <!-- WARNING: add release scope if 1.9 and older versions are used at build/plugins/plugin/[maven-compiler-plugin]/configuration-->
        <java.version>8</java.version>
        <!--endregion-->
        <!-- region General configurations of the project -->
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <maven.compiler.source>${java.version}</maven.compiler.source>
        <maven.compiler.target>${java.version}</maven.compiler.target>
        <junit.jupiter.version>5.9.2</junit.jupiter.version>
        <junit.platform.version>1.3.2</junit.platform.version>
        <surefire.failsafe.plugin.version>3.0.0-M8</surefire.failsafe.plugin.version>
        <surefire.version>2.22.2</surefire.version>
        <skipTests>false</skipTests>
        <skipITs>${skipTests}</skipITs>
        <skipUTs>${skipTests}</skipUTs>
        <logs.path>${project.build.directory}/test-reports/logs</logs.path>
        <slf4j.version>2.0.9</slf4j.version>
        <!-- region Maven Central deployments -->
        <organization>WhiteOrganization</organization>
        <repository.name>${project.artifactId}</repository.name>
        <!-- endregion Maven Central deployments -->
        </properties>

    <dependencies>
        <!-- region Testing (No-Spring) -->
        <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-suite-engine</artifactId>
            <version>1.9.2</version>
        </dependency>
        <!-- endregion Testing -->

        <!-- region SLF4J -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${slf4j.version}</version>
        </dependency>
        <!-- endregion SLF4J -->
    </dependencies>

    <!-- region Maven releases support -->
    <!-- Sonatype configuration required to deploy to maven central -->
    <licenses>
        <license>
            <name>Apache License, Version 2.0</name>
            <url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
        </license>
    </licenses>

    <developers>
        <developer>
            <name>Obed Vazquez</name>
            <email>obed.vazquez@gmail.com</email>
            <organization>${organization}</organization>
            <organizationUrl>https://github.com/${organization}/</organizationUrl>
        </developer>
    </developers>

    <!-- You also require Maven settings.xml configuration to authenticate when performing a `mvn release:prepare` -->
    <scm>
        <connection>scm:git:https://github.com/${organization}/${repository.name}.git</connection>
        <developerConnection>scm:git:https://github.com/${organization}/${repository.name}.git</developerConnection>
        <url>https://github.com/${organization}/${repository.name}/tree/main</url>
        <tag>${project.artifactId}-${project.version}</tag>
    </scm>

    <!-- in settings.xml you need this configuration:
    <servers>
        <server>
          <id>central</id>
        <username>${env.CENTRAL_USERNAME}</username>
        <password>${env.CENTRAL_PASSWORD}</password>
    </server>
            </servers>

    <profiles>
    <profile>
        <id>release</id>
        <activation>
            <activeByDefault>false</activeByDefault>
        </activation>
        <properties>
            <gpg.executable>gpg</gpg.executable>
            <gpg.passphrase>${env.GPG_PASSPHRASE}</gpg.passphrase>
        </properties>
    </profile>
    </profiles>

    <activeProfiles>
    <activeProfile>release</activeProfile>
    </activeProfiles>
    -->
    <!-- in this repo's case local deployments are not being used, instead this is replaced by the
        detect-version-and-tag.yml & publish-to-central.yml workflows.
    -->

    <!-- endregion Maven releases support -->

    <!-- region Profiles -->
    <profiles>
        <!-- region Sonatype Maven Central Profile -->
        <profile>
            <id>maven-central</id>
            <activation>
                <property>
                    <name>target</name>
                    <value>sonatype</value>
                </property>
            </activation>
            <build>
                <plugins>
                    <!-- region Sonatype Plugins -->
                    <!-- region Maven Release Plugin -->
                    <!-- we can now use `mvn release:clean release:prepare -D target=sonatype`
                        followed by `mvn release:perform -D target=sonatype` -->
                    <!-- https://central.sonatype.org/publish/publish-maven/#performing-a-release-deployment-with-the-maven-release-plugin -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-release-plugin</artifactId>
                        <version>3.1.1</version>
                        <configuration>
                            <autoVersionSubmodules>true</autoVersionSubmodules>
                            <useReleaseProfile>false</useReleaseProfile>
                            <releaseProfiles>release</releaseProfiles>
                            <goals>deploy</goals>
                        </configuration>
                    </plugin>
                    <!-- endregion Maven Release Plugin -->

                    <!-- region Sonatype Nexus Config -->
                    <!-- https://central.sonatype.org/publish/publish-maven/#distribution-management-and-authentication -->
                    <!-- https://central.sonatype.org/publish/publish-maven/#nexus-staging-maven-plugin-for-deployment-and-release -->
                    <!-- for SNAPSHOT's use `mvn clean deploy -D target=sonatype` -->
                    <!-- for Releases: use `mvn versions:set -DnewVersion=1.x.x -D target=sonatype`
                        followed by `mvn clean deploy -D target=sonatype` -->
<!--                    <plugin>-->
<!--                        <groupId>org.sonatype.plugins</groupId>-->
<!--                        <artifactId>nexus-staging-maven-plugin</artifactId>-->
<!--                        &lt;!&ndash; Versions: https://search.maven.org/artifact/org.sonatype.plugins/nexus-staging-maven-plugin &ndash;&gt;-->
<!--                        <version>1.7.0</version>-->
<!--                        <extensions>true</extensions>-->
<!--                        <configuration>-->
<!--                            <serverId>ossrh</serverId>-->
<!--                            <nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>-->
<!--                            <autoReleaseAfterClose>true</autoReleaseAfterClose>-->
<!--                        </configuration>-->
<!--                    </plugin>-->
                    <!-- endregion Sonatype Nexus Config -->

                    <!-- region Sonatype SRC+Javadocs plugin -->
                    <!-- https://central.sonatype.org/publish/publish-maven/#javadoc-and-sources-attachments
                        The sources and Javadocs will be included in the deployment  -->
                    <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-no-fork</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>

                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>3.11.2</version>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <additionalOptions>
                                <additionalOption>-Xdoclint:all</additionalOption>
                                <additionalOption>-Xdoclint:-missing</additionalOption>
                            </additionalOptions>
                        </configuration>
                    </plugin>
                    <!-- endregion Sonatype SRC+Javadocs plugin -->

                    <!-- region GPG Signed -->
                    <!-- relies on the gpg command being installed and the GPG credentials in settings.xml
                        https://central.sonatype.org/publish/publish-maven/#gpg-signed-components -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>3.2.7</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <!-- endregion GPG Signed -->

                    <!-- endregion Sonatype Plugins -->

                </plugins>
            </build>
        </profile>
        <!-- endregion Sonatype Maven Central Profile -->


        <profile>
            <id>disable-java8-doc-lint</id>
            <activation>
                <activeByDefault>true</activeByDefault>
<!--                <jdk>[1.8,)</jdk>-->
            </activation>
            <properties>
                <!-- region disable DockLint -->
                <!-- Eliminates the JavaDoc problems in later versions when you have problems in the documentation -->
                <doclint>none</doclint>
                <!-- endregion disable DockLint -->
<!--                <name>spring.profiles.active</name>-->
<!--                <value>disable-java8-doc-lint</value>-->
                <activatedProperties>disable-java8-doc-lint</activatedProperties>
            </properties>
        </profile>
        <profile>
            <id>headless</id>
<!--            <activation>-->
<!--                <jdk>[1.8,)</jdk>-->
<!--            </activation>-->
            <properties>
                <!-- region disable DockLint -->
                <!-- Eliminates the JavaDoc problems in later versions when you have problems in the documentation -->
                <doclint>none</doclint>
                <!-- endregion disable DockLint -->
                <excluded.tags>ExcludeWhenHeadless</excluded.tags>
<!--                <name>spring.profiles.active</name>-->
<!--                <value>headless</value>-->
                <activatedProperties>headless</activatedProperties>
            </properties>
        </profile>
    </profiles>
    <!-- endregion Profiles -->

    <build>
<!--        <finalName>${project.artifactId}</finalName>-->
        <plugins>
            <!-- region Established the java version defined in the properties' section for every scope (compatible with newer java versions) -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <!-- WARNING: add release property for 1.9 and older versions -->
<!--                    <release>${java.version}</release>-->
                </configuration>
            </plugin>
            <!-- endregion -->

            <!-- region Maven Generates JavaDocs of the project and adds it to the generated JAR-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>3.4.1</version>
                <configuration>
                    <detectJavaApiLink>false</detectJavaApiLink>
                </configuration>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <!--endregion-->

            <!-- region Maven is able to run JUnit5 Unit Tests (surefire) -->
            <!-- This requires junit-jupiter-engine [in junit-jupiter] dependency! -->
            <!-- This will run everything that Starts or ends with Test[(Case)|s]{0-1}. -->
<!--            <plugin>-->
<!--                <groupId>org.apache.maven.plugins</groupId>-->
<!--                <artifactId>maven-surefire-plugin</artifactId>-->
<!--                <version>${surefire.failsafe.plugin.version}</version>-->
<!--                <executions>-->
<!--                    <execution><goals><goal>test</goal></goals></execution>-->
<!--                </executions>-->
<!--&lt;!&ndash;                <configuration>&ndash;&gt;-->
<!--&lt;!&ndash;                    <reportsDirectory>${logs.path}</reportsDirectory>&ndash;&gt;-->
<!--&lt;!&ndash;                    <redirectTestOutputToFile>true</redirectTestOutputToFile>&ndash;&gt;-->
<!--&lt;!&ndash;                </configuration>&ndash;&gt;-->

<!--                &lt;!&ndash; region Deprecated in 3.0.0-M4 &ndash;&gt;-->
<!--                &lt;!&ndash; above M3 will get this on its own, but it will not let you know,-->
<!--                    it will just throw a problem with org/apache/maven/surefire/booter/ForkedProcessEvent &ndash;&gt;-->
<!--                <dependencies>-->
<!--                    <dependency>-->
<!--                        <groupId>org.junit.platform</groupId>-->
<!--                        <artifactId>junit-platform-surefire-provider</artifactId>-->
<!--                        <version>RELEASE</version>-->
<!--                    </dependency>-->
<!--                    <dependency>-->
<!--                        <groupId>org.junit.jupiter</groupId>-->
<!--                        <artifactId>junit-jupiter-engine</artifactId>-->
<!--                        <version>RELEASE</version>-->
<!--                    </dependency>-->
<!--                </dependencies>-->
<!--                &lt;!&ndash; endregion Deprecated in 3.0.0-M4 &ndash;&gt;-->
<!--            </plugin>-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.2</version>
                <executions>
                    <execution><goals><goal>test</goal></goals></execution>
                </executions>
                <configuration>
                    <redirectTestOutputToFile>true</redirectTestOutputToFile>
                    <reportsDirectory>${logs.path}</reportsDirectory>
                    <!-- override sufrefire plugins behaviors, provided by: https://stackoverflow.com/questions/6612344/prevent-unit-tests-but-allow-integration-tests-in-maven#:~:text=%20%3Cskiptests%3E%24%7Bskiptests%7D%3C%2Fskiptests%3E%20%3Cskipits%3E%24%7Bskipits%7D%3C%2Fskipits%3E -->
                    <skipTests>${skipUTs}</skipTests>
                </configuration>
            </plugin>

            <!-- region surefire-report Generates an HTML report -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-report-plugin</artifactId>
                <version>${surefire.failsafe.plugin.version}</version>
                <configuration>
<!--                    <reportsDirectories>${logs.path}</reportsDirectories>-->
                    <reportsDirectories>
                        <reportsDirectory>${logs.path}</reportsDirectory>
                    </reportsDirectories>
                </configuration>
            </plugin>
            <!-- endregion surefire-report Generates an HTML report -->

            <!-- endregion -->

            <!-- region Maven runs Integration Tests -->
            <plugin>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>${surefire.failsafe.plugin.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <reportsDirectory>${logs.path}</reportsDirectory>
                    <!--suppress MavenModelInspection -->
                    <excludedGroups>${excluded.tags}</excludedGroups>
                    <!-- override sufrefire plugins behaviors, provided by: https://stackoverflow.com/questions/6612344/prevent-unit-tests-but-allow-integration-tests-in-maven#:~:text=%20%3Cskiptests%3E%24%7Bskiptests%7D%3C%2Fskiptests%3E%20%3Cskipits%3E%24%7Bskipits%7D%3C%2Fskipits%3E -->
                    <skipTests>${skipTests}</skipTests>
                    <skipITs>${skipITs}</skipITs>
                </configuration>
            </plugin>
            <!-- endregion Maven runs Integration Tests -->

            <!-- region Maven Central Deployments-->
            <!-- https://central.sonatype.org/publish/publish-portal-maven/ -->
            <plugin>
                <groupId>org.sonatype.central</groupId>
                <artifactId>central-publishing-maven-plugin</artifactId>
                <version>0.9.0</version>
                <extensions>true</extensions>
                <configuration>
                    <publishingServerId>central</publishingServerId>
                    <autoPublish>true</autoPublish>
                    <waitUntil>published</waitUntil>
                </configuration>
            </plugin>

            <!-- endregion Maven Central Deployments-->


            <!-- region Maven releases support -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-release-plugin</artifactId>
                <version>3.1.1</version>
            </plugin>
            <!-- endregion Maven releases support -->
        </plugins>
    </build>

</project>