<?xml version="1.0" encoding="UTF-8"?>
<!--

    Copyright 2018-2023 Open Text.

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

         http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<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>com.github.cafapi</groupId>
    <artifactId>caf-common-parent</artifactId>
    <version>5.0.0-431</version>
    <packaging>pom</packaging>

    <name>${project.artifactId}</name>
    <description>This is a common parent for any project.</description>
    <url>http://cafapi.github.io/</url>

    <inceptionYear>2018</inceptionYear>

    <organization>
        <name>Open Text Corporation</name>
        <url>https://www.opentext.com</url>
    </organization>

    <licenses>
        <license>
            <name>Apache-2.0</name>
            <url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
        </license>
    </licenses>

    <developers>
        <developer>
            <id>andyreidz</id>
            <name>Andy Reid</name>
            <email>andrew.reid@microfocus.com</email>
        </developer>
        <developer>
            <id>dermot-hardy</id>
            <name>Dermot Hardy</name>
            <email>dermot.hardy@microfocus.com</email>
        </developer>
        <developer>
            <id>michael-bryson</id>
            <name>Michael Bryson</name>
            <email>michael.bryson@microfocus.com</email>
        </developer>
    </developers>

    <scm>
        <connection>scm:git:https://github.com/CAFapi/caf-common-parent.git</connection>
        <developerConnection>scm:git:https://github.com/CAFapi/caf-common-parent.git</developerConnection>
        <url>https://github.com/CAFapi/caf-common-parent</url>
    </scm>

    <distributionManagement>
        <snapshotRepository>
            <id>ossrh</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        </snapshotRepository>
    </distributionManagement>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <maven.compiler.release>17</maven.compiler.release>
        <netbeans.hint.jdkPlatform>JDK_17</netbeans.hint.jdkPlatform>
        <gmavenplusPluginGroovyVersion>3.0.19</gmavenplusPluginGroovyVersion>
        <skipLicenseHeadersCheck>false</skipLicenseHeadersCheck>
        <enforceCorrectDependencies>true</enforceCorrectDependencies>
        <enforceBannedDependencies>true</enforceBannedDependencies>
        <enforceCompatibleDependencies>true</enforceCompatibleDependencies>
        <dockerHubPrivate>docker.io</dockerHubPrivate>
        <dockerHubPublic>docker.io</dockerHubPublic>
        <dockerImagePrefix>dev/</dockerImagePrefix>
        <dockerOrgSeperator>/</dockerOrgSeperator>
        <dockerVersionSeperator>:</dockerVersionSeperator>
        <copyrightYear>2023</copyrightYear>
        <copyrightNotice>Copyright ${project.inceptionYear}-${copyrightYear} Open Text.</copyrightNotice>
        <licenseHeaderText>
<![CDATA[
${copyrightNotice}

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
]]>
        </licenseHeaderText>
    </properties>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>com.mycila</groupId>
                    <artifactId>license-maven-plugin</artifactId>
                    <version>4.3</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-antrun-plugin</artifactId>
                    <version>3.1.0</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <version>3.6.0</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-clean-plugin</artifactId>
                    <version>3.3.1</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.11.0</version>
                    <configuration>
                        <compilerArgs>
                            <arg>-Xlint:deprecation</arg>
                            <arg>-Xlint:unchecked</arg>
                        </compilerArgs>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <version>3.6.0</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-ear-plugin</artifactId>
                    <version>3.3.0</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-enforcer-plugin</artifactId>
                    <version>3.4.1</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-failsafe-plugin</artifactId>
                    <version>3.1.2</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-gpg-plugin</artifactId>
                    <version>3.1.0</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-install-plugin</artifactId>
                    <version>3.1.1</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-jar-plugin</artifactId>
                    <version>3.3.0</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-javadoc-plugin</artifactId>
                    <version>3.6.0</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-plugin-plugin</artifactId>
                    <version>3.9.0</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-release-plugin</artifactId>
                    <version>3.0.1</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>3.3.1</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-site-plugin</artifactId>
                    <version>4.0.0-M9</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-source-plugin</artifactId>
                    <version>3.3.0</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>3.1.2</version>
                    <configuration>
                        <!-- Workaround file.encoding warning -->
                        <argLine>-Dfile.encoding=UTF-8</argLine>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>3.4.0</version>
                </plugin>
                <plugin>
                    <groupId>org.basepom.maven</groupId>
                    <artifactId>duplicate-finder-maven-plugin</artifactId>
                    <version>2.0.1</version>
                </plugin>
                <plugin>
                    <groupId>org.bidib.buildnumber</groupId>
                    <artifactId>maven-jgit-buildnumber-plugin</artifactId>
                    <version>1.2.12</version>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.gmavenplus</groupId>
                    <artifactId>gmavenplus-plugin</artifactId>
                    <version>3.0.2</version>
                </plugin>
                <plugin>
                    <groupId>org.sonatype.plugins</groupId>
                    <artifactId>nexus-staging-maven-plugin</artifactId>
                    <version>1.6.13</version>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <!-- Get the git buildnumbers -->
            <plugin>
                <groupId>org.bidib.buildnumber</groupId>
                <artifactId>maven-jgit-buildnumber-plugin</artifactId>
                <executions>
                    <execution>
                        <id>git-buildnumber</id>
                        <phase>initialize</phase>
                        <goals>
                            <goal>extract-buildnumber</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- Set the git.branch property to 'unknown' if it could not be retrieved -->
            <plugin>
                <groupId>org.codehaus.gmavenplus</groupId>
                <artifactId>gmavenplus-plugin</artifactId>
                <executions>
                    <execution>
                        <id>set-git-branch-if-unknown</id>
                        <phase>initialize</phase>
                        <goals>
                            <goal>execute</goal>
                        </goals>
                        <configuration>
                            <scripts>
                                <script><![CDATA[
                                    if (project.properties['git.branch'].allWhitespace) {
                                        project.properties.setProperty('git.branch', 'unknown');
                                    }
                                ]]></script>
                            </scripts>
                        </configuration>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>org.codehaus.groovy</groupId>
                        <artifactId>groovy</artifactId>
                        <version>${gmavenplusPluginGroovyVersion}</version>
                        <scope>runtime</scope>
                    </dependency>
                    <dependency>
                        <groupId>org.codehaus.groovy</groupId>
                        <artifactId>groovy-ant</artifactId>
                        <version>${gmavenplusPluginGroovyVersion}</version>
                        <scope>runtime</scope>
                    </dependency>
                </dependencies>
            </plugin>

            <!-- Add the project and version information to the JAR Manifest -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifestEntries>
                            <Implementation-Title>${project.groupId}.${project.artifactId}</Implementation-Title>
                            <Implementation-Version>${git.revision}</Implementation-Version>
                            <Specification-Version>${project.version}</Specification-Version>
                            <X-Git-Branch>${git.branch}</X-Git-Branch>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>

            <!-- Create a jar archive of the source files -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- Generate javadocs -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                        <configuration>
                            <quiet>true</quiet>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!-- Check the license headers -->
            <plugin>
                <groupId>com.mycila</groupId>
                <artifactId>license-maven-plugin</artifactId>
                <configuration>
                    <licenseSets>
                        <licenseSet>
                            <inlineHeader>${licenseHeaderText}</inlineHeader>
                            <excludes>
                                <exclude>official-build.props</exclude>
                                <exclude>**/.editorconfig</exclude>
                                <exclude>**/.gitattributes</exclude>
                                <exclude>**/*.dat</exclude>
                                <exclude>**/*.notjson</exclude>
                                <exclude>**/*.sln</exclude>
                                <exclude>**/.angular/**</exclude>
                                <exclude>**/.vs/**</exclude>
                                <exclude>**/artifacts/**</exclude>
                                <exclude>**/dist/**</exclude>
                                <exclude>**/docs/**</exclude>
                                <exclude>**/resources/**/*.txt</exclude>
                                <exclude>**/test-configs/**</exclude>
                                <exclude>**/test-data/**</exclude>
                                <exclude>**/test-license/**</exclude>
                                <exclude>**/testcases/**</exclude>
                            </excludes>
                        </licenseSet>
                    </licenseSets>
                    <mapping>
                        <conf>SCRIPT_STYLE</conf>
                        <config>XML_STYLE</config>
                        <csproj>XML_STYLE</csproj>
                        <less>SLASHSTAR_STYLE</less>
                        <manifest>XML_STYLE</manifest>
                        <npmrc>SCRIPT_STYLE</npmrc>
                        <props>XML_STYLE</props>
                        <scss>SLASHSTAR_STYLE</scss>
                    </mapping>
                    <skip>${skipLicenseHeadersCheck}</skip>
                </configuration>
                <executions>
                    <execution>
                        <id>check-license-headers</id>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- Check the dependencies -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>check-dependencies</id>
                        <goals>
                            <goal>analyze-only</goal>
                        </goals>
                        <configuration>
                            <failOnWarning>${enforceCorrectDependencies}</failOnWarning>
                            <ignoreNonCompile>true</ignoreNonCompile>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!-- Check for banned dependencies -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <executions>
                    <execution>
                        <id>enforce-banned-dependencies</id>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <banDuplicatePomDependencyVersions/>
                                <bannedDependencies>
                                    <excludes>
                                        <exclude>commons-logging:commons-logging</exclude>
                                        <exclude>log4j:log4j</exclude>
                                        <exclude>javax.*</exclude>
                                        <exclude>org.apache.logging.log4j:log4j-core</exclude>
                                        <exclude>org.apache.logging.log4j:log4j-slf4j-impl</exclude>
                                        <exclude>org.glassfish:javax.*</exclude>
                                        <exclude>org.hamcrest:hamcrest-all</exclude>
                                        <exclude>org.jboss.logmanager:jboss-logmanager</exclude>
                                        <exclude>org.jboss.logmanager:log4j-jboss-logmanager</exclude>
                                        <exclude>org.jboss.slf4j:slf4j-jboss-logmanager</exclude>
                                        <exclude>org.jboss.spec.javax.*</exclude>
                                        <exclude>org.mockito:mockito-all</exclude>
                                        <exclude>org.slf4j:slf4j-jcl</exclude>
                                        <exclude>org.slf4j:slf4j-jdk14</exclude>
                                        <exclude>org.slf4j:slf4j-log4j12</exclude>
                                        <exclude>org.slf4j:slf4j-log4j13</exclude>
                                        <exclude>org.slf4j:slf4j-nop</exclude>
                                        <exclude>org.slf4j:slf4j-simple</exclude>
                                        <exclude>org.wildfly.core:wildfly-logging</exclude>
                                    </excludes>
                                    <includes>
                                        <include>org.slf4j:slf4j-simple:*:*:test</include>
                                    </includes>
                                    <searchTransitive>true</searchTransitive>
                                </bannedDependencies>
                            </rules>
                            <fail>${enforceBannedDependencies}</fail>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!-- Check the dependencies for duplicate classes and resources -->
            <plugin>
                <groupId>org.basepom.maven</groupId>
                <artifactId>duplicate-finder-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>deepcheck-dependencies</id>
                        <goals>
                            <goal>check</goal>
                        </goals>
                        <configuration>
                            <failBuildInCaseOfDifferentContentConflict>
                                ${enforceCompatibleDependencies}
                            </failBuildInCaseOfDifferentContentConflict>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!-- Use the Nexus Staging Maven Plugin for deployment -->
            <plugin>
                <groupId>org.sonatype.plugins</groupId>
                <artifactId>nexus-staging-maven-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <serverId>ossrh</serverId>
                    <nexusUrl>https://oss.sonatype.org/</nexusUrl>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <!-- Update the license headers if required -->
        <profile>
            <id>update-licenses</id>
            <activation>
                <property>
                    <name>!RE_BUILD_TYPE</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.mycila</groupId>
                        <artifactId>license-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>update-license-headers</id>
                                <phase>process-sources</phase>
                                <goals>
                                    <goal>format</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <!-- Sign the artifacts with GnuPG -->
        <profile>
            <id>sign-artifacts</id>
            <activation>
                <property>
                    <name>RE_BUILD_TYPE</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>
