Is there a recipe to use buildr to upload to maven central via ossrh?

StackOverflow https://stackoverflow.com/questions/13056533

  •  14-07-2021
  •  | 
  •  

Вопрос

Using maven, one can push artifacts to central via ossrh; this requires GPG signatures, source, and javadocs in addition to the usual maven-deploy-plugin of the core jar.

Is there a recipe to arrange all of this with buildr?

Это было полезно?

Решение

We do this in Apache ODE so that artifacts comply to Apache's release policy and are accepted by Nexus. I assume that OSSRH works similar.

The GPG task used in ODE is based on a Buildr How-to document but is slightly extended to work. You can find it here. To sign all artifacts before upload, simply add a gpg_sign_before_upload to your toplevel project (see here for an example).

Другие советы

I have just gone and implemented this for several of my projects. Here is what I had to do.

Buildr includes a built in gpg addon but it seems to have a bug when an artifact does not have a pom so I had to drop in a patch to fix this. Then I created a custom addon that allows me to generate a pom as part of the build process that is available here. Then I simply add some metadata to the main buildfile as demonstrated here. So ignoring the bug fix patch and the custom addon. The following demonstrates the code required to add to the buildfile

pom.add_apache2_license
pom.add_github_project('realityforge/gelf4j')
pom.add_developer('realityforge', 'Peter Donald', 'peter@realityforge.org', ['Developer'])
pom.optional_dependencies.concat [:getopt4j, :slf4j_api, :log4j, :logback_core, :logback_classic]

...

package(:jar)
package(:sources)
package(:javadoc)

I then tend to add configuration for the release location either directly to the build file or more likely into a _buildr.rb file in the same directory as the buildfile that contains code similar to the following

repositories.release_to[:url] = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
repositories.release_to[:username] = 'username'
repositories.release_to[:password] = 'password'

Hope that helps.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top