<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.camunda.community</groupId>
    <artifactId>community-hub-release-parent</artifactId>
    <version>2.1.0</version>
    <packaging>pom</packaging>

    <name>Camunda Community Hub - Release Parent Pom</name>

    <description>
        This POM defines the required plugins and profiles to allow a Camunda Community Hub release build.
        Inherit this POM when you want to use https://github.com/camunda-community-hub/community-action-maven-release
    </description>

    <properties>
        <version.java>11</version.java>
        <maven.compiler.source>${version.java}</maven.compiler.source>
        <maven.compiler.target>${version.java}</maven.compiler.target>
        <!-- Avoid the message "[WARNING] Using platform encoding (UTF-8 actually) ... also for the failsafe plugin -->
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

        <skip.camunda.release>false</skip.camunda.release>
        <skip.central.release>false</skip.central.release>

        <nexus.snapshot.repository.id>camunda-nexus</nexus.snapshot.repository.id>
        <nexus.snapshot.repository>https://artifacts.camunda.com/artifactory/camunda-bpm-community-extensions-snapshots/</nexus.snapshot.repository>
        <nexus.release.repository.id>camunda-nexus</nexus.release.repository.id>
        <nexus.release.repository>https://artifacts.camunda.com/artifactory/camunda-bpm-community-extensions/</nexus.release.repository>
        <nexus.staging.deploy.id>camunda-nexus</nexus.staging.deploy.id>
        <nexus.staging.deploy.url>https://artifacts.camunda.com/artifactory</nexus.staging.deploy.url>

        <autoReleaseAfterClose>true</autoReleaseAfterClose>
    </properties>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-clean-plugin</artifactId>
                    <version>3.3.2</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.11.0</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>3.3.1</version>
                    <configuration>
                        <encoding>UTF-8</encoding>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>3.2.1</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-failsafe-plugin</artifactId>
                    <version>3.2.1</version>
                </plugin>
                <plugin>
                    <!-- Pin version down to 2.5 to be able to run on JDK 17 -->
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-jar-plugin</artifactId>
                    <version>3.3.0</version>
                    <configuration>
                        <archive>
                            <manifest>
                                <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                                <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
                            </manifest>
                        </archive>
                    </configuration>
                </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-source-plugin</artifactId>
                    <version>3.3.0</version>
                    <executions>
                        <execution>
                            <id>attach-sources</id>
                            <phase>package</phase>
                            <goals>
                                <goal>jar</goal>
                            </goals>
                            <configuration>
                                <attach>true</attach>
                                <forceCreation>true</forceCreation>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-javadoc-plugin</artifactId>
                    <version>3.6.0</version>
                    <configuration>
                        <quiet>true</quiet>
                        <!--                            <source>${version.java}</source>-->
                        <failOnError>false</failOnError>
                        <doclint>none</doclint>
                    </configuration>
                    <executions>
                        <execution>
                            <id>attach-javadocs</id>
                            <phase>package</phase>
                            <goals>
                                <goal>jar</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-gpg-plugin</artifactId>
                    <version>3.1.0</version>
                    <executions>
                        <execution>
                            <id>sign-artifacts</id>
                            <phase>verify</phase>
                            <goals>
                                <goal>sign</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <gpgArguments>
                            <arg>--pinentry-mode</arg>
                            <arg>loopback</arg>
                        </gpgArguments>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-deploy-plugin</artifactId>
                    <version>3.1.1</version>
                    <configuration>
                        <skip>true</skip>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.sonatype.plugins</groupId>
                    <artifactId>nexus-staging-maven-plugin</artifactId>
                    <version>1.6.13</version>
                </plugin>
                <plugin>
                    <groupId>org.sonatype.central</groupId>
                    <artifactId>central-publishing-maven-plugin</artifactId>
                    <version>0.7.0</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-enforcer-plugin</artifactId>
                    <version>3.4.1</version>
                    <configuration>
                        <rules>
                            <requireMavenVersion>
                                <version>3.6.2</version>
                            </requireMavenVersion>
                            <requireJavaVersion>
                                <version>${version.java}</version>
                            </requireJavaVersion>
                        </rules>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <distributionManagement>
        <snapshotRepository>
            <id>${nexus.snapshot.repository.id}</id>
            <url>${nexus.snapshot.repository}</url>
        </snapshotRepository>
        <repository>
            <id>${nexus.release.repository.id}</id>
            <url>${nexus.release.repository}</url>
        </repository>
    </distributionManagement>

    <profiles>
        <profile>
            <!--
            This profile defines steps needed to create artifacts for the release.
            Typically these are sources.jar, javadoc.jar and GPG signatures for poms and all artifacts.
            -->
            <id>community-action-maven-release</id>
            <build>
                <plugins>
                    <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-gpg-plugin</artifactId>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <!--
            This profile configures environment for the publication using the nexus staging plugin into
            Camunda repository (artifactory).
            -->
            <id>camunda-repository</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.sonatype.plugins</groupId>
                        <artifactId>nexus-staging-maven-plugin</artifactId>
                        <extensions>true</extensions>
                        <executions>
                            <execution>
                                <!-- skip Mojo Execution if skip.camunda.release is set to false -->
                                <id>default-deploy</id>
                                <phase>deploy</phase>
                                <goals>
                                    <goal>deploy</goal>
                                </goals>
                                <configuration>
                                    <detectBuildFailures>true</detectBuildFailures>
                                    <serverId>${nexus.staging.deploy.id}</serverId>
                                    <nexusUrl>${nexus.staging.deploy.url}</nexusUrl>
                                    <skipStaging>true</skipStaging>
                                    <skipNexusStagingDeployMojo>${skip.camunda.release}</skipNexusStagingDeployMojo>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <!--
            This profile configures environment for the publication using the central publishing plugin
            into Maven Central Publisher Portal via https://central.sonatype.org/publish/publish-portal-maven/
            -->
            <id>central-sonatype-publish</id>
            <properties>
                <serverId>central</serverId>
                <!-- 
                deploymentName is redundant with central.sonatype.deployment.name but is kept for backward compatibility.
                -->
                <deploymentName>${project.groupId}:${project.artifactId}:${project.version}</deploymentName>
                <!-- 
                If central.sonatype.deployment.name is set, it always takes precedence over deploymentName.
                This is the property that child POMs inheriting from this POM should use to override the deployment name in the Sonatype Central Portal.
                -->
                <central.sonatype.deployment.name>${deploymentName}</central.sonatype.deployment.name>               
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.sonatype.central</groupId>
                        <artifactId>central-publishing-maven-plugin</artifactId>
                        <version>0.8.0</version>
                        <extensions>true</extensions>
                        <configuration>
                            <autoPublish>${autoReleaseAfterClose}</autoPublish>
                            <checksums>required</checksums>
                            <deploymentName>${central.sonatype.deployment.name}</deploymentName>
                            <publishingServerId>${serverId}</publishingServerId>
                            <skipPublishing>${skip.central.release}</skipPublishing>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
            <!-- This part overwrites the default distribution management pointing to Camunda Artifactory -->
            <distributionManagement>
                <snapshotRepository>
                    <id>${serverId}</id>
                    <url>https://central.sonatype.com/repository/maven-snapshots/</url>
                </snapshotRepository>
            </distributionManagement>
        </profile>

        <profile>
            <!--
            This profile configures environment for the publication using the nexus staging plugin into
            OSS Nexus repository.
            -->
            <id>oss-maven-central</id>
            <properties>
                <serverId>central</serverId>
                <nexusUrl>https://ossrh-staging-api.central.sonatype.com</nexusUrl> <!-- This is just the default, overwritten by action as some artifacts go to s01.oss...-->
                <central.staging.deploy.id>${serverId}</central.staging.deploy.id>
                <central.staging.deploy.url>${nexusUrl}</central.staging.deploy.url>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.sonatype.plugins</groupId>
                        <artifactId>nexus-staging-maven-plugin</artifactId>
                        <extensions>true</extensions>
                        <executions>
                            <execution>
                                <id>deploy-to-maven-central</id>
                                <phase>deploy</phase>
                                <goals>
                                    <goal>deploy</goal>
                                </goals>
                                <configuration>
                                    <serverId>${central.staging.deploy.id}</serverId>
                                    <nexusUrl>${central.staging.deploy.url}</nexusUrl>
                                    <altStagingDirectory>${session.executionRootDirectory}/target/central-staging</altStagingDirectory>
                                    <skipNexusStagingDeployMojo>${skip.central.release}</skipNexusStagingDeployMojo>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-enforcer-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>warn-deprecated-profile</id>
                                <goals>
                                    <goal>enforce</goal>
                                </goals>
                                <configuration>
                                    <rules>
                                        <evaluateBeanshell>
                                            <condition>false</condition>
                                            <message>
⚠️ Deprecated Profile Notice: The oss-maven-central profile is deprecated and will be removed in a future release.

A new profile, central-sonatype-publish, is available for use with the new Central Portal publishing interface.
Please refer to the documentation for migration guidance:
https://github.com/camunda-community-hub/community/blob/main/maintainers-reviewers/RELEASE.MD#migration-to-sonatype-central-portal--how-to
                                            </message>
                                        </evaluateBeanshell>
                                    </rules>
                                    <fail>false</fail>
                                </configuration>
                            </execution>
                            <execution>
                                <id>fail-deprecated-profile-zeebe-no-ackn</id>
                                <goals>
                                    <goal>enforce</goal>
                                </goals>
                                <configuration>
                                    <rules>
                                        <evaluateBeanshell>
                                            <condition><![CDATA[
                                                !"${project.groupId}".startsWith("io.zeebe") ||
                                                "${oss-maven-central.acknowledge.deprecation}".equals("true")
                                                ]]>
                                            </condition>
                                            <message>
❌ Deployment Blocked: Publishing under the io.zeebe namespace using the deprecated oss-maven-central profile is no longer supported.
To deploy to Maven Central, please use the central-sonatype-publish profile, which supports the new Central Portal publishing interface.

&#x1f6d1; To bypass this check (not recommended), you may pass -Doss-maven-central.acknowledge.deprecation=true.

Please refer to the documentation for migration guidance and namespace-specific rollout details:
https://github.com/camunda-community-hub/community/blob/main/maintainers-reviewers/RELEASE.MD#migration-to-sonatype-central-portal--how-to
                                            </message>
                                        </evaluateBeanshell>
                                        <evaluateBeanshell>
                                            <condition><![CDATA[
                                                !"${project.groupId}".startsWith("io.camunda") ||
                                                "${oss-maven-central.acknowledge.deprecation}".equals("true")
                                                ]]>
                                            </condition>
                                            <message>
❌ Deployment Blocked: Publishing under the io.camunda namespace using the deprecated oss-maven-central profile is no longer supported.
To deploy to Maven Central, please use the central-sonatype-publish profile, which supports the new Central Portal publishing interface.

&#x1f6d1; To bypass this check (not recommended), you may pass -Doss-maven-central.acknowledge.deprecation=true.

Please refer to the documentation for migration guidance and namespace-specific rollout details:
https://github.com/camunda-community-hub/community/blob/main/maintainers-reviewers/RELEASE.MD#migration-to-sonatype-central-portal--how-to
                                            </message>
                                        </evaluateBeanshell>
                                        <evaluateBeanshell>
                                            <condition><![CDATA[
                                                !"${project.groupId}".startsWith("org.camunda") ||
                                                "${oss-maven-central.acknowledge.deprecation}".equals("true")
                                                ]]>
                                            </condition>
                                            <message>
❌ Deployment Blocked: Publishing under the org.camunda namespace using the deprecated oss-maven-central profile is no longer supported.
To deploy to Maven Central, please use the central-sonatype-publish profile, which supports the new Central Portal publishing interface.

&#x1f6d1; To bypass this check (not recommended), you may pass -Doss-maven-central.acknowledge.deprecation=true.

Please refer to the documentation for migration guidance and namespace-specific rollout details:
https://github.com/camunda-community-hub/community/blob/main/maintainers-reviewers/RELEASE.MD#migration-to-sonatype-central-portal--how-to
                                            </message>
                                        </evaluateBeanshell>
                                    </rules>
                                    <fail>true</fail>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
            <!-- This part overwrites the default distribution management pointing to Camunda Artifactory -->
            <distributionManagement>
                <snapshotRepository>
                    <id>${central.staging.deploy.id}</id>
                    <url>${central.staging.deploy.url}/content/repositories/snapshots</url>
                </snapshotRepository>
                <repository>
                    <id>${central.staging.deploy.id}</id>
                    <url>${central.staging.deploy.url}/service/local/staging/deploy/maven2/</url>
                </repository>
            </distributionManagement>
        </profile>
    </profiles>

    <licenses>
        <license>
            <name>The Apache Software License, Version 2.0</name>
            <url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
        </license>
    </licenses>

    <organization>
        <name>Camunda</name>
        <url>https://www.camunda.com</url>
    </organization>

    <developers>
        <developer>
            <id>camunda</id>
            <name>Camunda Community</name>
            <organization>Camunda</organization>
            <organizationUrl>https://github.com/camunda</organizationUrl>
        </developer>
    </developers>

    <url>https://github.com/camunda-community-hub/</url>

    <scm>
        <url>https://github.com/camunda-community-hub/community-hub-release-parent</url>
        <connection>scm:git:git@github.com:camunda-community-hub/community-hub-release-parent.git</connection>
        <developerConnection>scm:git:git@github.com:camunda-community-hub/community-hub-release-parent.git</developerConnection>
        <tag>HEAD</tag>
    </scm>

</project>
