javamavennexusmaven-centralmaven-deploy-plugin

Publish from internal nexus to maven central


I have an internal nexus that contains all the artifacts that we build. Once an artifact is tested, I want to take the sane artifact and deploy it to Maven Central without rebuilding it.

I know that I might be able to do that using mvn deploy:deploy-file but it seems complicated. Is there an easy way to do it?

Note: due to historical reasons,we don't use SNAPSHOT versions. All versions are in the style of artifact-name-X.Y.Z.jar were X.Y.Z is the version number. We have an internal tool that can be queried for sanity.


Solution

  • I've ended using an approach similar to what they have in here: https://central.sonatype.org/pages/manual-staging-bundle-creation-and-deployment.html

    So, if I had the following files:

    ossrh-test-1.2.pom
    ossrh-test-1.2.jar
    ossrh-test-1.2-javadoc.jar
    ossrh-test-1.2-sources.jar
    

    I've invoked this command for the JAR:

    mvn gpg:sign-and-deploy-file -Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ -DrepositoryId=ossrh -DpomFile=ossrh-test-1.2.pom -Dfile=ossrh-test-1.2.jar
    

    And the following commands for the sources and JavaDocs:

    mvn gpg:sign-and-deploy-file -Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ -DrepositoryId=ossrh -DpomFile=ossrh-test-1.2.pom -Dfile=ossrh-test-1.2-sources.jar -Dclassifier=sources
    mvn gpg:sign-and-deploy-file -Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ -DrepositoryId=ossrh -DpomFile=ossrh-test-1.2.pom -Dfile=ossrh-test-1.2-javadoc.jar -Dclassifier=javadoc
    

    Last but not least, since I had to create fake sources and javadoc jars I've just taken a jar, unzipped it, put a readme file inside of it instead of the old content, updated the manifest and zipped it again. Then I've uploaded it as my fake sources/javadoc jars.