Skip to content

Conversation

@wiktorolko
Copy link
Contributor

Added the maven-publish to enable releasing artefacts to maven repository.

My goal is to have 0.4.0 released to 'http://maven.snplow.com/releases/'. Could you @BenFradet help here?

To release the 0.4.0 artifact all you need to do is:

  • add maven repo credentials to build.gradle
  • invoke './gradlew publish'

@BenFradet
Copy link
Contributor

I think we want to aim for central directly, we can definitely help with those creds 👍

@wiktorolko
Copy link
Contributor Author

OK, if you think that we should aim for mavenCentral, then there are some additional changes that needs to be made.

I'll follow this guide https://medium.com/@nmauti/sign-and-publish-on-maven-central-a-project-with-the-new-maven-publish-gradle-plugin-22a72a4bfd4b and update the PR with necessary changes.

@wiktorolko
Copy link
Contributor Author

I've ended-up following the official guide: https://central.sonatype.org/pages/gradle.html

To release the jar you'll need to:

  • Modify credentials in the gradle.properties file
  • Invoke ./gradlew uploadArchives

@wiktorolko
Copy link
Contributor Author

I guess this PR should be merged to develop.
Then a new one should be created: develop->master.
Then you could checkout master, modify credentials in gradle.properties (it should only take place in your local env and should never be pushed to git repo), invoke ./gradlew uploadArchives.

@wiktorolko
Copy link
Contributor Author

Is there anything I can do to have it released?

@BenFradet
Copy link
Contributor

Sorry, I was "out" last week.

We actually don't use sonatype directly but rather bintray which is then mirrored. It seems there is a plugin for gradle: https://github.com/bintray/gradle-bintray-plugin.

We usually have the following four env variables:

  • BINTRAY_USER
  • BINTRAY_API_KEY
  • SONA_USER
  • SONA_PASS

in our .travis.yml (I can take care of inputting those).

and then a small script that actually takes care of publishing.

You can check out https://github.com/snowplow/snowplow-android-tracker/blob/master/.travis/deploy.sh and https://github.com/snowplow/snowplow-android-tracker/blob/master/.travis.yml#L46-L51

The example above only publishes to bintray but I'd think it's not terribly hard to do the mirroring with the mavenCentralSync closure from the plugin.

@wiktorolko
Copy link
Contributor Author

I've followed the README of the gradle-bintray-plugin, but didn't have a chance to test it e2e ... I hope it will work ;)

@wiktorolko
Copy link
Contributor Author

@BenFradet would you have some time this week to approve this PR, merge to master and do the release?

The build.gradle:

  • was created according to the description here: https://github.com/bintray/gradle-bintray-plugin. I've made sure that all the mavenCentral requirements are met (signing, authors, descriptions, ...)
  • is using the four env variables that you've mentioned (BINTRAY_USER, BINTRAY_API_KEY, SONA_USER, SONA_PASS)

Copy link
Contributor

@BenFradet BenFradet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, just a couple of minor comments 👍

build.gradle Outdated
key = System.getenv('BINTRAY_API_KEY')

pkg {
repo = 'maven'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's snowplow-maven

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

build.gradle Outdated
repo = 'maven'
name = archivesBaseName
licenses = ['Apache-2.0']
vcsUrl = 'https://github.com/snowplow-referer-parser/java-referer-parser'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need the .git extension

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right (verified examples in the gradle-bintray-plugin). Fixed.

version {
name = version
gpg {
sign = true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we have a key so this will most likely fail

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's obligatory to have signing enabled.

https://github.com/bintray/gradle-bintray-plugin#Maven_Central_Sync

(...) also files must be signed to be sent to Maven Central, so GPG file signing should be enabled (see above) if Maven Central sync is enabled

Here is an article how to create a signature:
https://medium.com/@nmauti/publishing-a-project-on-maven-central-8106393db2c3

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah indeed, didn't know bintray did it for us: https://github.com/bintray/gradle-bintray-plugin#gpg-file-signing

Copy link
Contributor

@BenFradet BenFradet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, can you just make the deploy.sh file executable?

@wiktorolko
Copy link
Contributor Author

I didn't even know that it's possible ;) Good - learning new things :)

@BenFradet BenFradet changed the title Add maven-plugin to enable releasing to maven repository Add ability to publish to bintray and central Oct 31, 2018
@BenFradet BenFradet merged commit 7fbe6f1 into snowplow-referer-parser:develop Oct 31, 2018
@BenFradet
Copy link
Contributor

As part of hacktoberfest, we have a raffle to win Snowplow t-shirts.
To enter the raffle you can fill out this form: https://docs.google.com/forms/d/e/1FAIpQLSeBbwQMWD9w9CEvjKt1KblDVpMy9mHOvQXS6YMRYH3geM8pCw/viewform

@wiktorolko
Copy link
Contributor Author

This PR got merged to develop, what needs to be done to deploy it to maven central?

@BenFradet
Copy link
Contributor

sorry this dropped off my radar, I'll try publishing an RC today

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants