Skip to content

Commit

Permalink
Migrate to Central Portal publishing (#230)
Browse files Browse the repository at this point in the history
* Replaced nexus-staging-maven-plugin with central-publishing-maven-plugin
* Removed unused javadoc properties
* Removed Java version enforcement
* Removed gpg arguments
* Removed outdated workflow references
  • Loading branch information
freya022 authored Feb 3, 2025
1 parent 5637243 commit bd70e2f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 61 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/maven-publish.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# https://theoverengineered.blog/posts/publishing-my-first-artifact-to-maven-central-using-github-actions
# https://maven.apache.org/maven-release/maven-release-plugin/examples/non-interactive-release.html
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onworkflow_dispatchinputs
# https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Publishing-using-Apache-Maven

name: Publish to Maven Central
Expand All @@ -24,7 +21,7 @@ jobs:
distribution: 'temurin'
java-version: '17'
cache: 'maven'
server-id: ossrh
server-id: central
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
gpg-private-key: ${{ secrets.OSSRH_GPG_SECRET_KEY }}
Expand All @@ -34,7 +31,7 @@ jobs:
- name: Compile and release
run: >
mvn -B --file pom.xml
-P check-docs,docs,release
-P docs,release
-Dkotlin.compiler.incremental=false
deploy
env:
Expand Down
82 changes: 26 additions & 56 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,6 @@
<tag>3.X</tag>
</scm>

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

<profiles>
<profile>
<id>docs</id>
Expand Down Expand Up @@ -128,12 +117,29 @@
</profile>
<profile>
<id>release</id>
<properties>
<maven.javadoc.failOnError>true</maven.javadoc.failOnError>
<maven.javadoc.failOnWarnings>true</maven.javadoc.failOnWarnings>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.4.1</version>
<executions>
<execution>
<id>enforce-all-profiles-are-activated</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireActiveProfile>
<profiles>docs</profiles> <!-- Run dokka -->
</requireActiveProfile>
</rules>
<fail>true</fail>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
Expand Down Expand Up @@ -161,43 +167,13 @@
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.4.1</version>
<executions>
<execution>
<id>enforce-all-profiles-are-activated</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireActiveProfile>
<profiles>docs</profiles>
</requireActiveProfile>
<requireJavaVersion>
<!-- Generating docs on the JDK 17 is important -->
<version>[17, 18)</version>
</requireJavaVersion>
</rules>
<fail>true</fail>
</configuration>
</execution>
</executions>
</plugin>
<!-- Good resources:
https://github.com/classgraph/classgraph/blob/e81f793faba16ed102aeba4760fa0b5cd6e260d2/pom.xml
https://central.sonatype.org/publish/publish-maven/
-->
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.13</version> <!-- Updated for Java 16+ -->
<groupId>org.sonatype.central</groupId>
<artifactId>central-publishing-maven-plugin</artifactId>
<version>0.7.0</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
<publishingServerId>central</publishingServerId>
<autoPublish>true</autoPublish>
</configuration>
</plugin>
<plugin>
Expand All @@ -211,12 +187,6 @@
<goals>
<goal>sign</goal>
</goals>
<configuration>
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
</execution>
</executions>
</plugin>
Expand Down

0 comments on commit bd70e2f

Please sign in to comment.