<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>org.entando</groupId>
    <artifactId>entando-maven-root</artifactId>
    <version>6.2.1</version>
    <packaging>pom</packaging>

    <name>Entando Maven Root Parent POM</name>
    <description>Entando Maven Root Parent POM</description>
    <inceptionYear>2019</inceptionYear>
    <url>https://central.entando.com</url>

    <licenses>
        <license>
            <name>GNU LESSER GENERAL PUBLIC LICENSE, Version 2.1, February 1999</name>
            <url>https://www.gnu.org/licenses/lgpl-2.1.txt</url>
            <distribution>repo</distribution>
        </license>
    </licenses>
    <developers>
        <developer>
            <id>ampie</id>
            <name>Ampie Barnard</name>
            <email>a.barnard@entando.com</email>
            <organization>Entando</organization>
            <organizationUrl>https://www.entando.com/</organizationUrl>
        </developer>
    </developers>
    <organization>
        <name>Entando Inc.</name>
        <url>https://www.entando.com/</url>
    </organization>
    <repositories>
        <repository>
            <id>nexus-jx</id>
            <url>https://nexus-jx.apps.serv.run/repository/maven-releases/</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>
    <scm>
        <connection>scm:git:git@github.com:${github.organization}/${project.artifactId}.git</connection>
        <developerConnection>scm:git:git@github.com:${github.organization}/${project.artifactId}.git
        </developerConnection>
        <url>https://github.com/${github.organization}/${project.artifactId}/</url>
        <tag>HEAD</tag>
    </scm>
    <distributionManagement>
        <snapshotRepository>
            <id>sonatype-nexus-snapshot</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        </snapshotRepository>
        <repository>
            <id>sonatype-nexus-staging</id>
            <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
        </repository>
    </distributionManagement>
    <properties>
        <!--Properties to override in child poms -->
        <preDeploymentTestGroups></preDeploymentTestGroups>
        <postDeploymentTestGroups></postDeploymentTestGroups>
        <checkstyleConfigLocation></checkstyleConfigLocation>
        <owaspSuppressionFileLocation></owaspSuppressionFileLocation>
        <javaDocOptions>-Xdoclint:none</javaDocOptions>

        <!-- properties to control verification -->
        <verifyAllFailures>true</verifyAllFailures>
        <ignoreAllFailures>false</ignoreAllFailures>
        <skipPostDeploymentTests>true</skipPostDeploymentTests>
        <skipPreDeploymentTests>true</skipPreDeploymentTests>
        <!-- Miscellaneous properties -->
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <github.organization>entando</github.organization>
        <!--Standard Sonar configuration -->
        <sonar.host.url>https://sonarcloud.io</sonar.host.url>
        <sonar.organization>${github.organization}</sonar.organization>
        <sonar.projectKey>${github.organization}_${project.artifactId}</sonar.projectKey>
        <sonar.coverage.jacoco.xmlReportPaths>target/site/jacoco/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
        <sonar.java.checkstyle.reportPaths>target/checkstyle-result.xml</sonar.java.checkstyle.reportPaths>
        <!--JDBC Driver versions -->
        <postgresql.driver.version>42.2.8</postgresql.driver.version>
        <!-- plugin  versions -->
        <maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
        <maven-surefire-plugin.version>3.0.0-M4</maven-surefire-plugin.version>
        <maven-checkstyle-plugin.version>3.1.1</maven-checkstyle-plugin.version>
        <maven-failsafe-plugin.version>3.0.0-M4</maven-failsafe-plugin.version>
        <maven-gpg-plugin.version>1.6</maven-gpg-plugin.version>
        <maven-javadoc-plugin.version>3.2.0</maven-javadoc-plugin.version>
        <maven-source-plugin.version>3.2.1</maven-source-plugin.version>
        <maven-jar-plugin.version>3.2.0</maven-jar-plugin.version>
        <maven-shade-plugin.version>3.2.2</maven-shade-plugin.version>
        <maven-deploy-plugin.version>2.8.2</maven-deploy-plugin.version>
        <maven-project-info-reports-plugin.version>3.0.0</maven-project-info-reports-plugin.version>
        <maven-enforcer-plugin.version>3.0.0-M3</maven-enforcer-plugin.version>
        <maven-site-plugin.version>3.9.0</maven-site-plugin.version>
        <jacoco-maven-plugin.version>0.8.5</jacoco-maven-plugin.version>
        <dependency-check-maven.version>5.3.2</dependency-check-maven.version>
        <maven-surefire-report-plugin.version>3.0.0-M4</maven-surefire-report-plugin.version>
    </properties>
    <issueManagement>
        <system>Github</system>
        <url>https://github.com/${github.organization}/${project.artifactId}/issues/</url>
    </issueManagement>
    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <!--We need to make sure all HTML reports are generated so that we can link to them from the PR status check-->
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-report-plugin</artifactId>
                    <version>${maven-surefire-report-plugin.version}</version>
                    <executions>
                        <execution>
                            <id>unit-tests</id>
                            <goals>
                                <goal>report-only</goal>
                            </goals>
                            <phase>verify</phase>
                            <configuration>
                                <outputDirectory>target/site/</outputDirectory>
                            </configuration>
                        </execution>
                        <execution>
                            <id>integration-tests</id>
                            <goals>
                                <goal>failsafe-report-only</goal>
                            </goals>
                            <phase>post-integration-test</phase>
                            <configuration>
                                <outputDirectory>target/site/</outputDirectory>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-site-plugin</artifactId>
                    <version>${maven-site-plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.owasp</groupId>
                    <artifactId>dependency-check-maven</artifactId>
                    <version>${dependency-check-maven.version}</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>aggregate</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <suppressionFile>${owaspSuppressionFileLocation}</suppressionFile>
                        <failOnError>true</failOnError>
                        <failBuildOnAnyVulnerability>${verifyAllFailures}</failBuildOnAnyVulnerability>
                        <name>National Vulnerability Database Report</name>
                        <!--JUNIT/XML required to verify failures from the pipeline-->
                        <formats>HTML,XML,JUNIT</formats>
                        <outputDirectory>target/site</outputDirectory>
                        <retireJsAnalyzerEnabled>false</retireJsAnalyzerEnabled>
                    </configuration>
                    <dependencies>
                        <dependency>
                            <groupId>org.postgresql</groupId>
                            <artifactId>postgresql</artifactId>
                            <version>${postgresql.driver.version}</version>
                        </dependency>
                    </dependencies>
                </plugin>
                <plugin>
                    <groupId>org.jacoco</groupId>
                    <artifactId>jacoco-maven-plugin</artifactId>
                    <version>${jacoco-maven-plugin.version}</version>
                    <executions>
                        <execution>
                            <id>prepare-agent</id>
                            <goals>
                                <goal>prepare-agent</goal>
                            </goals>
                        </execution>
                        <execution>
                            <!--Bring it into core Maven build lifecycle for Sonar without needing the site phase-->
                            <id>report</id>
                            <goals>
                                <goal>report</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>${maven-surefire-plugin.version}</version>
                    <configuration>
                        <skip>${skipPreDeploymentTests}</skip>
                        <forkCount>1</forkCount>
                        <testFailureIgnore>${ignoreAllFailures}</testFailureIgnore>
                        <groups>${preDeploymentTestGroups}</groups>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-failsafe-plugin</artifactId>
                    <version>${maven-failsafe-plugin.version}</version>
                    <configuration>
                        <testFailureIgnore>${ignoreAllFailures}</testFailureIgnore>
                        <skip>${skipPostDeploymentTests}</skip>
                        <groups>${postDeploymentTestGroups}</groups>
                        <includes>
                            <include>**/*IntegrationTest.java,**/*IntegratedTest.java,**/*IT.java</include>
                        </includes>
                    </configuration>
                    <executions>
                        <execution>
                            <id>run-tests</id>
                            <goals>
                                <goal>integration-test</goal>
                                <goal>verify</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-checkstyle-plugin</artifactId>
                    <version>${maven-checkstyle-plugin.version}</version>
                    <configuration>
                        <configLocation>${checkstyleConfigLocation}</configLocation>
                        <encoding>UTF-8</encoding>
                        <consoleOutput>true</consoleOutput>
                        <failsOnError>true</failsOnError>
                        <violationSeverity>warning</violationSeverity>
                        <failOnViolation>${verifyAllFailures}</failOnViolation>
                        <linkXRef>false</linkXRef>
                        <includeTestSourceDirectory>true</includeTestSourceDirectory>
                        <outputDirectory>target/site</outputDirectory>
                    </configuration>
                    <executions>
                        <execution>
                            <id>validate</id>
                            <phase>validate</phase>
                            <goals>
                                <goal>check</goal>
                                <goal>checkstyle</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-enforcer-plugin</artifactId>
                    <version>${maven-enforcer-plugin.version}</version>
                </plugin>

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-jar-plugin</artifactId>
                    <version>${maven-jar-plugin.version}</version>
                    <configuration>
                        <archive>
                            <manifest>
                                <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                                <addDefaultSpecificationEntries>false</addDefaultSpecificationEntries>
                            </manifest>
                            <manifestEntries>
                                <Implementation-Build>${project.version}</Implementation-Build>
                            </manifestEntries>
                        </archive>
                    </configuration>
                    <executions>
                        <execution>
                            <id>build-test-jar</id>
                            <goals>
                                <goal>test-jar</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>${maven-compiler-plugin.version}</version>
                    <configuration>
                        <compilerArgs>
                            <arg>-Xlint:unchecked</arg>
                        </compilerArgs>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-source-plugin</artifactId>
                    <version>${maven-source-plugin.version}</version>
                    <executions>
                        <execution>
                            <id>attach-sources</id>
                            <goals>
                                <goal>jar-no-fork</goal>
                                <goal>test-jar</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-javadoc-plugin</artifactId>
                    <version>${maven-javadoc-plugin.version}</version>
                    <executions>
                        <execution>
                            <id>attach-javadocs</id>
                            <goals>
                                <goal>jar</goal>
                            </goals>
                            <configuration>
                                <doclint>none</doclint>
                            </configuration>
                        </execution>

                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-gpg-plugin</artifactId>
                    <version>${maven-gpg-plugin.version}</version>
                    <executions>
                        <execution>
                            <id>sign-artifacts</id>
                            <phase>verify</phase>
                            <goals>
                                <goal>sign</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-deploy-plugin</artifactId>
                    <version>${maven-deploy-plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-project-info-reports-plugin</artifactId>
                    <version>${maven-project-info-reports-plugin.version}</version>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-site-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-deploy-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-project-info-reports-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-report-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <!--
            This profile is intended for build environments where we want the entire build to succeed, only to inspect
            the build output afterwards to decided whether to fail or not. This profile achieves this goal by
            manipulating a set of properties that will disable build failure when quality checks fail. One use case
            for this profile is where the pull request on GitHub itself can be updated with status checks providing
            feedback on exactly which quality checks have failed, and links to the various quality reports. Under
            these circumstances it makes more sense to evaluate all quality checks in one go, and the providing full
            feedback to the author of the pull request. Generally, developers are expected to run a clean Maven build
            locally before pushing changes to a pull request.
            -->
            <id>no-fail</id>
            <properties>
                <verifyAllFailures>false</verifyAllFailures>
                <ignoreAllFailures>true</ignoreAllFailures>
            </properties>
        </profile>
        <profile>
            <!--
            This profile is typically executed right in the beginning of the pipeline. For instance, this is the first
            step that is executed to verify that the changes in the pull request comply to the coding standards in 
            Checkstyle, have test sufficient coverage from unit tests and integration tests and don't have any
            dependencies with known vulnerabilities. This profile is also responsible for static code analysis, but
            this is done directly against Sonar Cloud and the outcome of that process generally doesn't affect the build.

            Only tests that do NOT require the deployment artifact to have been deployed to Kubernetes should be
            executed here. Any other checks that can be done without needing to deploy the artifact should be done here.
            Keep in mind that the build environment should also guarantee that certain common services are available,
            such as Kubernetes itself and Keycloak.

             -->
            <id>pre-deployment-verification</id>
            <properties>
                <skipPreDeploymentTests>false</skipPreDeploymentTests>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.owasp</groupId>
                        <artifactId>dependency-check-maven</artifactId>
                    </plugin>
                    <plugin>
                        <groupId>org.jacoco</groupId>
                        <artifactId>jacoco-maven-plugin</artifactId>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-jar-plugin</artifactId>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-checkstyle-plugin</artifactId>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-project-info-reports-plugin</artifactId>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <!--
            This profile is executed whenever a Maven artifact needs to be prepared and deployed to the
            default, local Nexus in Entando's Jenkins X build environment. Note that this will not necessarily result in
            a deployment to Maven Central, but the resulting artifact could potentially be deployed there if all the
            necessary quality steps succeed. For this reason, this profile needs to fulfill Maven Central's requirements:
            sources and JavaDocs need to be attached and the resulting artifact also needs to be signed using GPG, using
            a key that is managed on our own build infrastructureThis profile will typically be invoked  before the
            post-deployment tests  are executed, as these test may need to deploy the binary artifact (e.g. into a Docker image
            and/or Kubernetes).
            -->
            <id>prepare-for-nexus</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-jar-plugin</artifactId>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-project-info-reports-plugin</artifactId>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <!--
            This profile is only executed once all Docker images have been built, and are ready for deployment
            to Kubernetes. The assumption here is that there will be some form of inter-process communication with
            the code that has been deployed to Kubernetes, exposed using Ingresses and/or Routes. Standard
            connectivity with Kubernetes will be provided by means of the entando.default.routing.suffix
            system property. No code coverage will be done here.
            -->
            <id>post-deployment-verification</id>
            <properties>
                <skipPostDeploymentTests>false</skipPostDeploymentTests>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-failsafe-plugin</artifactId>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
    <reporting>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-project-info-reports-plugin</artifactId>
                <reportSets>
                    <reportSet>
                        <reports>
                            <report>dependency-info</report>
                            <report>distribution-management</report>
                            <report>index</report>
                            <report>ci-management</report>
                            <report>issue-management</report>
                            <report>licenses</report>
                            <report>plugins</report>
                            <report>scm</report>
                            <report>summary</report>
                        </reports>
                    </reportSet>
                </reportSets>
            </plugin>
        </plugins>
    </reporting>
</project>

