Skip to content

Uploading maven plugin to maven central

Roman Ivanov edited this page Mar 19, 2018 · 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 repository. Login to https://oss.sonatype.org/#stagingRepositories Find in list of bundles (it almost always at the most bottom), your package, "Close" it, and then after operation is done, press "Release". Wait for some time 10min - 2 hours to let artifact appear on maven central. Recheck http://repo1.maven.org/maven2/com/github/sevntu-checkstyle/dsm-maven-plugin/

=================================

IN CASE you need to test snapshot:

In 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).

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.2.pom dsm-maven-plugin-2.1.2.pom.asc dsm-maven-plugin-2.1.2.jar dsm-maven-plugin-2.1.2.jar.asc dsm-maven-plugin-2.1.2-javadoc.jar dsm-maven-plugin-2.1.2-javadoc.jar.asc dsm-maven-plugin-2.1.2-sources.jar dsm-maven-plugin-2.1.2-sources.jar.asc

Now you can upload it to central. For this go to Sonytype OSS Login with sevntu_checkstyle (ask Roman Ivanov for password) 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