Skip to content

Uploading maven plugin to maven central

Roman Ivanov edited this page May 16, 2014 · 9 revisions

After you finish all changes, that you want to push you have to do few steps:

  1. You need gpg-key.

How to config GPG and sign artifact

  1. Edit your ~/.m2/settings.xml
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                        http://maven.apache.org/xsd/settings-1.0.0.xsd">
    <servers>
        <server>
            <id>sonatype-nexus-snapshots</id>
            <username>SONATYPE_LOGIN</username>
            <password>SONATYPE_PASSWORD</password>
        </server>

        <server>
            <id>sonatype-nexus-staging</id>
            <username>SONATYPE_LOGIN</username>
            <password>SONATYPE_PASSWORD</password>
        </server>
    </servers>
</settings>

Now, after running:

mvn deploy

your snapshot will be placed in snapshot repository. You may do some tests. For this you should add

<pluginRepositories>
    <pluginRepository>
      <id>snapshots</id>
      <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
    </pluginRepository>
  </pluginRepositories>

to your project pom.xml. Also add section with plugin (version should be current snapshot).

  1. After you tested plugin you may do stable release and push it to central.

Run

mvn clean install

It asks you for the passphrase.

After it has been finished in target folder you can find pom, jars and sign files.

Now you should create bundle:

jar -cvf dsm-maven-plugin-bundle.jar dsm-maven-plugin-2.1.pom dsm-maven-plugin-2.1.pom.asc dsm-maven-plugin-2.1.jar dsm-maven-plugin-2.1.jar.asc dsm-maven-plugin-2.1-javadoc.jar dsm-maven-plugin-2.1-javadoc.jar.asc dsm-maven-plugin-2.1-sources.jar dsm-maven-plugin-2.1-sources.jar.asc

Now you can upload it to central. For this go to Sonytype OSS Login with your sonatype jira account:

login picture

Select Staging Upload

Select upload picture

Select Artifact Bundle in Uploading mode

uploading picture

Select your bundle and upload it. If you do it first time - create ticket on Sonatype jira in OSSRH section and ask admin to release it.

If you did it before - just press release button and wait a few hours. release