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

    SPDX-License-Identifier: Apache-2.0
    
    Copyright 2021 Dirk Lemmermann Software & Consulting (dlsc.com)
    
    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
    
        https://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.dlsc</groupId>
    <artifactId>dlsc-maven-parent</artifactId>
    <version>1.0.0</version>
    <packaging>pom</packaging>

    <properties>
        <!-- !! children should override these properties !! -->
        <project.identifier>dlsc</project.identifier>
        <project.github.repository>dlsc-software-consulting-gmbh/dlsc-maven-parent</project.github.repository>
        <java.version>1.8</java.version>
        <sonar.projectKey>dlsc-software-consulting-gmbh_DLSC-MavenParent</sonar.projectKey>
        <!-- override if multi-project -->
        <local.repository.path>${project.build.directory}/repository</local.repository.path>
        <!-- override when needed -->
        <sonar.organization>dlsc-software-consulting-gmbh</sonar.organization>
        <sonar.host.url>https://sonarcloud.io</sonar.host.url>
        <sonar.moduleKey>${project.artifactId}</sonar.moduleKey>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <maven.version>3.8.4</maven.version>
        <nexus.url>https://oss.sonatype.org</nexus.url>
        <repository.url>git@github.com:${project.github.repository}.git</repository.url>
        <version.antrun.plugin>3.0.0</version.antrun.plugin>
        <version.clean.plugin>3.1.0</version.clean.plugin>
        <version.compiler.plugin>3.8.1</version.compiler.plugin>
        <version.dependency.plugin>3.1.2</version.dependency.plugin>
        <version.deploy.plugin>3.0.0-M1</version.deploy.plugin>
        <version.directory.plugin>0.3.1</version.directory.plugin>
        <version.enforcer.plugin>3.0.0-M3</version.enforcer.plugin>
        <version.failsafe.plugin>3.0.0-M5</version.failsafe.plugin>
        <version.git.plugin>3.0.1</version.git.plugin>
        <version.gpg.plugin>1.6</version.gpg.plugin>
        <version.install.plugin>3.0.0-M1</version.install.plugin>
        <version.javadoc.plugin>3.2.0</version.javadoc.plugin>
        <version.jar.plugin>3.1.2</version.jar.plugin>
        <version.jreleaser.plugin>0.8.0</version.jreleaser.plugin>
        <version.nexus.plugin>1.6.8</version.nexus.plugin>
        <version.resources.plugin>3.1.0</version.resources.plugin>
        <version.site.plugin>3.7.1</version.site.plugin>
        <version.source.plugin>3.2.1</version.source.plugin>
        <version.surefire.plugin>3.0.0-M4</version.surefire.plugin>
        <version.versions.plugin>2.8.1</version.versions.plugin>
    </properties>

    <name>dlsc-maven-parent</name>
    <description>Parent POM for all DLSC projects</description>
    <url>https://github.com/dlsc-software-consulting-gmbh</url>
    <inceptionYear>2021</inceptionYear>

    <organization>
        <name>DLSC Software &amp; Consulting</name>
        <url>https://dlsc.com</url>
    </organization>

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

    <developers>
        <developer>
            <id>dlemmermann</id>
            <name>Dirk Lemmermann</name>
            <url>https://dlsc.com</url>
        </developer>
    </developers>

    <issueManagement>
        <system>github.com</system>
        <url>https://github.com/${project.github.repository}/issues</url>
    </issueManagement>

    <scm>
        <connection>scm:git:${repository.url}</connection>
        <developerConnection>scm:git:${repository.url}</developerConnection>
        <tag>HEAD</tag>
        <url>${repository.url}</url>
    </scm>

    <build>
        <pluginManagement>
            <!-- fix plugin versions for reproducibility -->
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-antrun-plugin</artifactId>
                    <version>${version.antrun.plugin}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-clean-plugin</artifactId>
                    <version>${version.clean.plugin}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>${version.compiler.plugin}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <version>${version.dependency.plugin}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-deploy-plugin</artifactId>
                    <version>${version.deploy.plugin}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-enforcer-plugin</artifactId>
                    <version>${version.enforcer.plugin}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-failsafe-plugin</artifactId>
                    <version>${version.failsafe.plugin}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-gpg-plugin</artifactId>
                    <version>${version.gpg.plugin}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-install-plugin</artifactId>
                    <version>${version.install.plugin}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-jar-plugin</artifactId>
                    <version>${version.jar.plugin}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-javadoc-plugin</artifactId>
                    <version>${version.javadoc.plugin}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>${version.resources.plugin}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-site-plugin</artifactId>
                    <version>${version.site.plugin}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-source-plugin</artifactId>
                    <version>${version.source.plugin}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>${version.surefire.plugin}</version>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>versions-maven-plugin</artifactId>
                    <version>${version.versions.plugin}</version>
                </plugin>
                <plugin>
                    <groupId>org.commonjava.maven.plugins</groupId>
                    <artifactId>directory-maven-plugin</artifactId>
                    <version>${version.directory.plugin}</version>
                </plugin>
                <plugin>
                    <groupId>org.jreleaser</groupId>
                    <artifactId>jreleaser-maven-plugin</artifactId>
                    <version>${version.jreleaser.plugin}</version>
                </plugin>
                <plugin>
                    <groupId>org.sonatype.plugins</groupId>
                    <artifactId>nexus-staging-maven-plugin</artifactId>
                    <version>${version.nexus.plugin}</version>
                </plugin>
                <plugin>
                    <groupId>pl.project13.maven</groupId>
                    <artifactId>git-commit-id-plugin</artifactId>
                    <version>${version.git.plugin}</version>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <dependencies>
                    <dependency>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>extra-enforcer-rules</artifactId>
                        <version>1.3</version>
                    </dependency>
                </dependencies>
                <executions>
                    <execution>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <phase>validate</phase>
                        <configuration>
                            <rules combine.children="override">
                                <requireMavenVersion>
                                    <version>${maven.version}</version>
                                </requireMavenVersion>
                                <requireJavaVersion>
                                    <version>${java.version}</version>
                                </requireJavaVersion>
                                <enforceBytecodeVersion>
                                    <maxJdkVersion>${java.version}</maxJdkVersion>
                                </enforceBytecodeVersion>
                                <dependencyConvergence/>
                                <requireUpperBoundDeps/>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <!-- enrich JAR manifests with build information -->
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifestEntries>
                            <Build-Jdk>${java.version} (${java.vendor} ${java.vm.version})</Build-Jdk>
                            <Build-Timestamp>${git.build.time}</Build-Timestamp>
                            <Build-Revision>${git.commit.id}</Build-Revision>
                            <Build-OS>${os.name} ${os.arch} ${os.version}</Build-OS>
                        </manifestEntries>
                        <manifest>
                            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>versions-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.commonjava.maven.plugins</groupId>
                <artifactId>directory-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>resolve-rootdir</id>
                        <goals>
                            <goal>highest-basedir</goal>
                        </goals>
                        <phase>initialize</phase>
                        <configuration>
                            <property>rootdir</property>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <!-- grab Git information to enrich JAR manifests -->
                <groupId>pl.project13.maven</groupId>
                <artifactId>git-commit-id-plugin</artifactId>
                <executions>
                    <execution>
                        <id>resolve-git-properties</id>
                        <goals>
                            <goal>revision</goal>
                        </goals>
                        <phase>validate</phase>
                        <configuration>
                            <verbose>false</verbose>
                            <failOnNoGitDirectory>false</failOnNoGitDirectory>
                            <generateGitPropertiesFile>true</generateGitPropertiesFile>
                            <generateGitPropertiesFilename>${project.build.directory}/git.properties
                            </generateGitPropertiesFilename>
                            <dateFormat>yyyy-MM-dd'T'HH:mm:ssXXX</dateFormat>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <distributionManagement>
        <repository>
            <id>ossrh</id>
            <url>${nexus.url}/service/local/staging/deploy/maven2/</url>
        </repository>
        <snapshotRepository>
            <id>ossrh</id>
            <url>${nexus.url}/content/repositories/snapshots</url>
        </snapshotRepository>
        <site>
            <id>kordamp</id>
            <url>scm:git:ssh://git@github.com/${project.github.repository}.git</url>
        </site>
    </distributionManagement>

    <profiles>
        <profile>
            <id>publication</id>
            <activation>
                <property>
                    <name>release</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <!-- add LICENSE file to JARs -->
                    <plugin>
                        <groupId>com.coderplus.maven.plugins</groupId>
                        <artifactId>copy-rename-maven-plugin</artifactId>
                        <version>1.0.1</version>
                        <executions>
                            <execution>
                                <id>copy-license-file</id>
                                <goals>
                                    <goal>copy</goal>
                                </goals>
                                <phase>generate-sources</phase>
                                <configuration>
                                    <sourceFile>${session.executionRootDirectory}/LICENSE</sourceFile>
                                    <destinationFile>
                                        ${project.build.outputDirectory}/META-INF/LICENSE-${project.identifier}
                                    </destinationFile>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                                <configuration>
                                    <attach>true</attach>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>attach-sources</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                                <configuration>
                                    <attach>true</attach>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>gpg</id>
            <activation>
                <property>
                    <name>release</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                                <phase>verify</phase>
                                <configuration>
                                    <gpgArguments>
                                        <arg>--pinentry-mode</arg>
                                        <arg>loopback</arg>
                                    </gpgArguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>remote-deploy</id>
            <activation>
                <property>
                    <name>release</name>
                </property>
            </activation>
            <build>
                <defaultGoal>deploy</defaultGoal>
                <plugins>
                    <plugin>
                        <groupId>org.sonatype.plugins</groupId>
                        <artifactId>nexus-staging-maven-plugin</artifactId>
                        <extensions>true</extensions>
                        <configuration>
                            <serverId>central</serverId>
                            <nexusUrl>${nexus.url}</nexusUrl>
                            <autoReleaseAfterClose>true</autoReleaseAfterClose>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>local-deploy</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <properties>
                <altDeploymentRepository>local::file:${local.repository.path}</altDeploymentRepository>
            </properties>
            <build>
                <defaultGoal>deploy</defaultGoal>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-clean-plugin</artifactId>
                        <inherited>false</inherited>
                        <configuration>
                            <filesets>
                                <fileset>
                                    <directory>${local.repository.path}</directory>
                                </fileset>
                            </filesets>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
