Skip to content

[P2] Publish artifacts to Maven Central #314

@sfloess

Description

@sfloess

Problem

Artifacts are only published to packagecloud.io, not Maven Central.

Impact

  • Severity: MEDIUM
  • Category: Distribution/Adoption
  • Not discoverable in Maven Central search
  • Users must add custom repository to pom.xml
  • Limits adoption (many orgs only allow Maven Central)
  • Reduced visibility in ecosystem

Current Distribution

<distributionManagement>
    <repository>
        <id>packagecloud-flossware</id>
        <url>https://packagecloud.io/flossware/java/maven2/</url>
    </repository>
</distributionManagement>

Maven Central Requirements

  1. Group ID: org.flossware.jplatform ✅ (already correct)
  2. Artifact signing: GPG signature required
  3. Javadoc JAR: Must be published
  4. Sources JAR: Must be published
  5. POM completeness: developers, scm, licenses ✅
  6. OSSRH account: Create at https://issues.sonatype.org/

Implementation Steps

1. Sign Artifacts

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-gpg-plugin</artifactId>
    <version>3.0.1</version>
    <executions>
        <execution>
            <id>sign-artifacts</id>
            <phase>verify</phase>
            <goals><goal>sign</goal></goals>
        </execution>
    </executions>
</plugin>

2. Generate Javadoc and Sources JARs

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-javadoc-plugin</artifactId>
    <executions>
        <execution><id>attach-javadocs</id></execution>
    </executions>
</plugin>
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-source-plugin</artifactId>
    <executions>
        <execution><id>attach-sources</id></execution>
    </executions>
</plugin>

3. Add Nexus Staging Plugin

<plugin>
    <groupId>org.sonatype.plugins</groupId>
    <artifactId>nexus-staging-maven-plugin</artifactId>
    <version>1.6.13</version>
</plugin>

4. Configure in ~/.m2/settings.xml

<servers>
    <server>
        <id>ossrh</id>
        <username>${env.OSSRH_USERNAME}</username>
        <password>${env.OSSRH_PASSWORD}</password>
    </server>
</servers>

GitHub Actions Integration

- name: Deploy to Maven Central
  run: mvn deploy -P release
  env:
    OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
    OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
    GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}

Priority

P2 - Medium - Should be done for v1.2 or v1.3 release.

Resources

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions