<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://maven.apache.org/POM/4.0.0"
         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>it.serendigity.maven.parent</groupId>
    <artifactId>sndp-public-base-parent</artifactId>
    <version>1.2.4</version>
    <packaging>pom</packaging>

    <name>sndp-public-base-parent</name>
    <description>Parent pom in order to inherit basic configuration for the public projects</description>

    <url>https://serendipity-projects.github.io/${project.artifactId}</url>

    <organization>
        <name>Serendipity S.r.l.</name>
        <url>https://www.serendigity.it</url>
    </organization>

    <developers>
        <developer>
            <id>sndp-official</id>
            <name>Serendipity Developer official account</name>
            <organization>Serendipity S.r.l.</organization>
            <url>https://www.serendigity.it</url>
        </developer>
    </developers>

    <scm>
        <url>https://github.com/serendipity-projects</url>
        <connection>scm:git:git://github.com/serendipity-projects/${project.artifactId}.git</connection>
        <developerConnection>scm:git:git@github.com:serendipity-projects/${project.artifactId}.git</developerConnection>
        <tag>HEAD</tag>
    </scm>

    <distributionManagement>
        <snapshotRepository>
            <id>ossrh</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        </snapshotRepository>
        <repository>
            <id>ossrh</id>
            <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
        </repository>
    </distributionManagement>

    <repositories>
        <repository>
            <id>ossrh-snapshots</id>
            <releases>
                <enabled>false</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
                <updatePolicy>always</updatePolicy>
            </snapshots>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        </repository>
    </repositories>

    <ciManagement>
        <system>github-actions</system>
        <url>https://github.com/serendipity-projects/${project.artifactId}/actions</url>
    </ciManagement>

    <issueManagement>
        <system>GitHub</system>
        <url>https://github.com/serendipity-projects/${project.artifactId}/issues</url>
    </issueManagement>

    <licenses>
        <license>
            <name>Apache License</name>
            <url>https://opensource.org/licenses/Apache-2.0</url>
            <distribution>repo</distribution>
        </license>
    </licenses>


    <properties>

        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

        <!-- Nota: versione 2.0.0 M9 Non funziona quando si lancia site dà errore con markdown-->
        <doxia.version>2.0.0</doxia.version>

        <scm.version>2.1.0</scm.version>
        <junit.version>5.13.0-M2</junit.version>
        <log4j.version>2.24.3</log4j.version>

        <javadoc.plugin.version>3.11.2</javadoc.plugin.version>

        <!-- SITE properties -->
        <site.input.directory>${project.reporting.outputDirectory}</site.input.directory>

        <site.output.prefix.basedir></site.output.prefix.basedir>
        <site.output.directory>${project.reporting.outputDirectory}/${site.output.prefix.basedir}
        </site.output.directory>

        <site.output.staging.directory>${project.build.directory}/site-staging
        </site.output.staging.directory>


        <site.deploy.rootdir>${user.home}/test/maven_site</site.deploy.rootdir>
        <site.skip.deploy>false</site.skip.deploy>
        <!-- Sonar -->
        <sonar.organization>serendipity-projects</sonar.organization>
        <sonar.cloud.host>https://sonarcloud.io</sonar.cloud.host>
    </properties>


    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>nl.jqno.equalsverifier</groupId>
                <artifactId>equalsverifier</artifactId>
                <version>3.19.2</version>
                <scope>test</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-api</artifactId>
            <version>${log4j.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>${log4j.version}</version>
        </dependency>

        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-params</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <version>4.0.0-M1</version>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <!--BUILD -->

    <build>

        <plugins>

            <plugin>
                <groupId>com.amashchenko.maven.plugin</groupId>
                <artifactId>gitflow-maven-plugin</artifactId>
                <version>1.21.0</version>

                <configuration>
                    <verbose>true</verbose>
                    <gitFlowConfig>
                        <developmentBranch>master</developmentBranch>
                    </gitFlowConfig>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <version>3.5.0</version>
                <executions>

                    <execution>
                        <id>enforce-java-version</id>
                        <goals>
                            <goal>display-info</goal>
                            <goal>enforce</goal>
                        </goals>
                        <phase>validate</phase>
                        <!-- require java 11 -->
                        <configuration>
                            <rules>
                                <requireJavaVersion>
                                    <version>[17,)</version>
                                </requireJavaVersion>
                            </rules>
                            <fail>true</fail>
                        </configuration>
                    </execution>

                    <execution>
                        <id>enforce-maven</id>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <requireMavenVersion>
                                    <version>3.6.3</version>
                                </requireMavenVersion>
                            </rules>
                        </configuration>
                    </execution>

                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>${javadoc.plugin.version}</version>

                <executions>
                    <!-- Standard javadoc -->
                    <execution>
                        <id>generate-standard-javadoc</id>

                        <goals>
                            <goal>jar</goal>
                        </goals>
                        <configuration>
                            <doclint>none</doclint>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <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>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>3.1.4</version>
                <executions>
                    <execution>
                        <id>skip-default-deploy</id>
                        <phase>deploy</phase>
                        <goals>
                            <goal>deploy</goal>
                        </goals>

                    </execution>
                </executions>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.sonatype.plugins</groupId>
                <artifactId>nexus-staging-maven-plugin</artifactId>
                <version>1.7.0</version>
                <executions>
                    <execution>
                        <id>default-deploy</id>
                        <phase>deploy</phase>
                        <goals>
                            <goal>deploy</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <serverId>ossrh</serverId>
                    <nexusUrl>https://oss.sonatype.org/</nexusUrl>
                    <autoReleaseAfterClose>true</autoReleaseAfterClose>
                </configuration>
            </plugin>


            <!-- -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-site-plugin</artifactId>
                <version>4.0.0-M16</version>
                <executions>
                    <execution>
                        <id>attach-descriptor</id>
                        <goals>
                            <goal>attach-descriptor</goal>
                        </goals>
                    </execution>
                </executions>

                <dependencies>

                    <!-- add support for markdown -->
                    <dependency>
                        <groupId>org.apache.maven.doxia</groupId>
                        <artifactId>doxia-module-markdown</artifactId>
                        <version>${doxia.version}</version>
                    </dependency>

                    <dependency>
                        <groupId>org.apache.maven.doxia</groupId>
                        <artifactId>doxia-sink-api</artifactId>
                        <version>${doxia.version}</version>
                    </dependency>

                    <!-- add support for scm -->
                    <dependency>
                        <groupId>org.apache.maven.wagon</groupId>
                        <artifactId>wagon-scm</artifactId>
                        <version>3.5.3</version>
                    </dependency>

                    <dependency>
                        <groupId>org.apache.maven.scm</groupId>
                        <artifactId>maven-scm-provider-gitexe</artifactId>
                        <version>${scm.version}</version>
                    </dependency>

                    <dependency>
                        <groupId>org.apache.maven.scm</groupId>
                        <artifactId>maven-scm-api</artifactId>
                        <version>${scm.version}</version>
                    </dependency>

                    <dependency>
                        <groupId>org.apache.maven.scm</groupId>
                        <artifactId>maven-scm-manager-plexus</artifactId>
                        <version>${scm.version}</version>
                    </dependency>

                </dependencies>

                <configuration>

                    <inputDirectory>${site.input.directory}</inputDirectory>
                    <outputDirectory>${site.output.directory}</outputDirectory>
                    <stagingSiteURL>${site.output.staging.directory}</stagingSiteURL>
                    <topSiteURL>${project.distributionManagement.site.url}</topSiteURL>
                    <skipDeploy>true</skipDeploy>
                </configuration>

            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-project-info-reports-plugin</artifactId>
                <version>3.9.0</version>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.5.3</version>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>3.5.3</version>
                <configuration>
                    <skip>${skip.failsafe.tests}</skip>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.8.13</version>
                <configuration>
                    <excludes>
                        <exclude>it/serendigity/**/HelpMojo.*</exclude>
                    </excludes>
                    <sessionId>jacoco-session-id</sessionId>
                </configuration>

                <executions>
                    <execution>
                        <id>pre-unit-test</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>

                    <execution>
                        <id>post-unit-test</id>
                        <phase>test</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>

                    <execution>
                        <id>pre-integration-test</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>prepare-agent-integration</goal>
                        </goals>
                        <configuration>
                            <destFile>${project.build.directory}/jacoco-it.exec</destFile>
                            <propertyName>invoker.mavenOpts</propertyName>
                        </configuration>
                    </execution>

                    <execution>
                        <id>report-integration-test</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>report-integration</goal>
                        </goals>
                        <configuration>
                            <dataFile>${project.build.directory}/jacoco-it.exec</dataFile>
                            <outputDirectory>${project.reporting.outputDirectory}/jacoco-it</outputDirectory>
                        </configuration>
                    </execution>

                    <!-- merge all test (unit test and integration test result) -->
                    <execution>
                        <id>merge-test-result</id>
                        <goals>
                            <goal>merge</goal>
                        </goals>
                        <phase>post-integration-test</phase>
                        <configuration>
                            <fileSets>
                                <fileSet
                                        implementation="org.apache.maven.shared.model.fileset.FileSet">
                                    <directory>${project.build.directory}</directory>
                                    <includes>
                                        <include>*.exec</include>
                                    </includes>
                                </fileSet>
                            </fileSets>
                            <destFile>${project.build.directory}/jacoco-all.exec</destFile>
                        </configuration>
                    </execution>

                    <!-- report all test (unit test and integration test result) -->
                    <execution>
                        <id>report-all-test</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                        <configuration>
                            <dataFile>${project.build.directory}/jacoco-all.exec</dataFile>
                            <outputDirectory>${project.reporting.outputDirectory}/jacoco-all</outputDirectory>
                        </configuration>
                    </execution>

                </executions>

            </plugin>

            <!-- <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId>
                <version>3.1.1</version> <dependencies> <dependency> <groupId>com.github.checkstyle</groupId>
                <artifactId>checkstyle-sonar-plugin</artifactId> <version>8.35</version>
                </dependency> </dependencies> </plugin> -->

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-pmd-plugin</artifactId>
                <version>3.26.0</version>
            </plugin>

        </plugins>
    </build>

    <!-- ******* REPORTING ******* -->
    <reporting>
        <plugins>


            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-project-info-reports-plugin</artifactId>
                <version>3.4.3</version>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>${javadoc.plugin.version}</version>
                <configuration>
                    <additionalparam>-Xdoclint:none</additionalparam>
                </configuration>
                <reportSets>

                    <reportSet>
                        <reports>
                            <report>javadoc</report>
                            <report>test-javadoc</report>
                        </reports>
                        <configuration>
                            <show>package</show>
                        </configuration>
                    </reportSet>

                    <reportSet>
                        <!-- aggregate reportSet (multimodule) -->
                        <id>aggregate</id>
                        <!-- don't run aggregate in child modules -->
                        <inherited>false</inherited>
                        <reports>
                            <report>aggregate</report>
                        </reports>
                    </reportSet>

                </reportSets>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-report-plugin</artifactId>
                <version>3.5.3</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jxr-plugin</artifactId>
                <version>3.6.0</version>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-plugin-plugin</artifactId>
                <version>3.15.1</version>
            </plugin>

            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.8.13</version>
                <configuration>
                    <excludes>
                        <exclude>it/serendigity/**/HelpMojo.*</exclude>
                    </excludes>
                </configuration>

                <reportSets>
                    <reportSet>
                        <reports>
                            <report>report</report>
                            <report>report-integration</report>
                        </reports>
                    </reportSet>
                </reportSets>
            </plugin>

            <plugin>
                <groupId>nl.demon.shadowland.maven.plugins</groupId>
                <artifactId>sonarqube-maven-report</artifactId>
                <version>0.2.2</version>
                <configuration>
                    <sonarHostURL>${sonar.cloud.host}</sonarHostURL>
                </configuration>
            </plugin>

            <!-- <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId>
                <version>3.1.1</version> <reportSets> <reportSet> <reports> <report>checkstyle</report>
                </reports> </reportSet> </reportSets> </plugin> -->

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-pmd-plugin</artifactId>
                <version>3.22.0</version>
                <configuration>
                    <linkXref>true</linkXref>
                    <sourceEncoding>utf-8</sourceEncoding>

                    <excludes>
                        <exclude>**/*Bean.java</exclude>
                        <exclude>**/HelpMojo.java</exclude>
                        <exclude>**/generated/*.java</exclude>
                    </excludes>
                    <excludeRoots>
                        <excludeRoot>target/generated-sources/stubs</excludeRoot>
                    </excludeRoots>
                </configuration>
            </plugin>

            <plugin>
                <groupId>com.github.spotbugs</groupId>
                <artifactId>spotbugs-maven-plugin</artifactId>
                <version>4.9.3.0</version>
            </plugin>

        </plugins>
    </reporting>

    <profiles>
        <profile>
            <id>sign-artifact</id>
            <build>
                <plugins>
                    <plugin>
                        <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>
                </plugins>
            </build>
        </profile>

        <!-- DEPLOY SITE PROFILE -->
        <!-- ... LOCAL -->
        <profile>
            <id>site-local</id>

            <distributionManagement>
                <site>
                    <id>deploy-site-local</id>
                    <name>Site deployments</name>
                    <url>file://${site.deploy.rootdir}/${project.artifactId}/</url>


                </site>
            </distributionManagement>

        </profile>

        <!-- ... GITHUB -->
        <profile>
            <id>site-github</id>

            <distributionManagement>
                <site>
                    <id>deploy-site-github</id>
                    <name>Site deploy github</name>
                    <url>scm:git:https://git@github.com/serendipity-projects/${project.artifactId}/</url>
                </site>
            </distributionManagement>

            <properties>
                <site.skip.deploy>true</site.skip.deploy>
                <scm-publish.pubScmUrl>
                    scm:git:SerendipityOfficialDev@github.com:serendipity-projects/${project.artifactId}.git
                </scm-publish.pubScmUrl>
                <scm-publish.siteDocOuputDirectory>${project.build.directory}/site</scm-publish.siteDocOuputDirectory>
            </properties>
            <build>
                <plugins>
                    <!-- Staging site -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-site-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>stage-for-scm-publish</id>
                                <phase>post-site</phase>
                                <goals>
                                    <goal>stage</goal>
                                </goals>

                                <configuration>
                                    <stagingDirectory>${site.output.staging.directory}</stagingDirectory>
                                    <topSiteURL>${project.distributionManagement.site.url}</topSiteURL>
                                    <skipDeploy>true</skipDeploy>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-scm-publish-plugin</artifactId>
                        <version>3.3.0</version>

                        <executions>
                            <execution>
                                <id>publish-docs</id>
                                <phase>site-deploy</phase>
                                <inherited>true</inherited>
                                <goals>
                                    <goal>publish-scm</goal>
                                </goals>

                                <configuration>
                                    <content>${site.output.staging.directory}</content>
                                    <scmBranch>gh-pages</scmBranch>
                                </configuration>

                            </execution>
                        </executions>

                        <dependencies>

                            <!-- add support for scm -->

                            <dependency>
                                <groupId>org.apache.maven.scm</groupId>
                                <artifactId>maven-scm-provider-gitexe</artifactId>
                                <version>2.0.1</version>
                            </dependency>
                            <dependency>
                                <groupId>org.apache.maven.scm</groupId>
                                <artifactId>maven-scm-api</artifactId>
                                <version>2.0.1</version>
                            </dependency>
                        </dependencies>
                    </plugin>
                </plugins>
            </build>

        </profile>

    </profiles>


</project>
