Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable publish to maven central via Sonatype with plugin scoping #849

Merged
merged 9 commits into from Nov 7, 2019

Conversation

@jayv
Copy link
Contributor

jayv commented Nov 6, 2019

Motivation

Directly publishing to sonatype maven central gives us more control over the artifacts to be promoted to central.

Modifications

  • add POM metadata as required by maven central
  • add signing of artifacts as per maven central requirements
  • update Docker Compose to pass PGP and Sonatype credentials from the ENV

Result

Gradle can now publish to maven central.

jayv added 2 commits Nov 5, 2019
__Motivation__

Directly publishing to sonatype maven central gives us more control over the artifacts to be promoted to central.

__Modifications__

- add POM metadata as required by maven central
- add signing of artifacts as per maven central requirements
- update Docker Compose to pass PGP and Sonatype credentials from the ENV

__Result__

Gradle can now publish to maven central.
Copy link
Member

idelpivnitskiy left a comment

Great that we close to publishing to Maven Central 🎉

@@ -29,7 +29,7 @@ if (!repositories) {
}
}

apply plugin: "servicetalk-root"
apply plugin: "io.servicetalk.servicetalk-gradle-plugin-internal-root"

This comment has been minimized.

Copy link
@idelpivnitskiy

idelpivnitskiy Nov 6, 2019

Member

Agreed, we should namespace our plugins with io.servicetalk 👍

docker/docker-compose.yaml Outdated Show resolved Hide resolved
command: >
bash -cl "./gradlew --no-daemon --parallel --max-workers=4 -PreleaseBuild=true clean check &&
./gradlew --no-daemon -PreleaseBuild=true bintrayUpload"
./gradlew --no-daemon -PreleaseBuild=true publish bintrayUpload"

This comment has been minimized.

Copy link
@idelpivnitskiy

idelpivnitskiy Nov 6, 2019

Member

Let's remove bintrayUpload from both release and snapshot publications, and remove all bintray-related dependencies and configuration. We don't need it anymore.

This comment has been minimized.

Copy link
@jayv

jayv Nov 7, 2019

Author Contributor

Hmm not sure about removing it as part of this PR, let's just deactivate for now.

This comment has been minimized.

Copy link
@idelpivnitskiy

idelpivnitskiy Nov 7, 2019

Member

I'm ok with removing the bintray plugin as a follow up. Let's remove it from docker files, including bintray env variables.

This comment has been minimized.

Copy link
@jayv

jayv Nov 7, 2019

Author Contributor

I've kept the env vars for now. Keeping most of it intact will simplify rollback if we encounter issues in the near term.

servicetalk-grpc-gradle-plugin/plugin-config.gradle Outdated Show resolved Hide resolved
def signingPassword = findProperty("signingPassword")
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications.mavenJava
}

This comment has been minimized.

Copy link
@idelpivnitskiy

idelpivnitskiy Nov 6, 2019

Member

Add the following section right after signing block:

tasks.withType(AbstractPublishToMaven) {
  onlyIf {
    // Disable all tasks that try to publish something else, expect defined "mavenJava" publication.
    // That could be automatically configured "pluginMaven" publication for gradle plugins that are required
    // only for Gradle Plugin Portal and should not be published to Maven Central
    publication == publishing.publications.mavenJava
  }
}

Note: you need to import AbstractPublishToMaven, otherwise it doesn't work.

It helps to remove the error we saw:

Multiple publications with coordinates 'io.servicetalk:servicetalk-gradle-plugin-internal:0.20.0-SNAPSHOT' are published to repository 'mavenLocal'. The publications will overwrite each other!

If we do not do this, pluginMaven publication overrides the jar, pom, and maven-metadata files generated by mavenJava publication. It removes source and javadoc metadata from maven-metadata.xml 😞

This comment has been minimized.

Copy link
@jayv

jayv Nov 7, 2019

Author Contributor

Just verified, signatures are intact and plugin meta-data exists in the JAR, so this approach does seem to work indeed! 🥇

@idelpivnitskiy

This comment has been minimized.

Copy link
Member

idelpivnitskiy commented Nov 7, 2019

I've verified, grpc sample project with servicetalk-grpc-gradle-plugin works well after my changes with locally published artifacts 🎉

jayv added 2 commits Nov 7, 2019

if (project.isReleaseBuild || (!!findProperty("signingKey") && !!findProperty("signingPassword"))) {
signing {
required project.isReleaseBuild

This comment has been minimized.

Copy link
@idelpivnitskiy

idelpivnitskiy Nov 7, 2019

Member

As we discussed offline, let's not force signing if there are no keys. We may need to publish a release to maven local to testing purposes.

If you decided to protect the whole signing block behind !!findProperty("signingKey") && !!findProperty("signingPassword")) check, please also move pluginManager.apply("signing") under this condition. Otherwise, signing plugin may apply some default configuration.

This comment has been minimized.

Copy link
@jayv

jayv Nov 7, 2019

Author Contributor

Oh good catch!

@jayv

This comment has been minimized.

Copy link
Contributor Author

jayv commented Nov 7, 2019

This should solve #845

@jayv

This comment has been minimized.

Copy link
Contributor Author

jayv commented Nov 7, 2019

@idelpivnitskiy check again, updated the readme to remove bintray section.
I think we're ready for a mvn central snap/prod release attempt.

Copy link
Member

idelpivnitskiy left a comment

Last comment and LGTM!
Merge of this PR will trigger snapshots upload to sonatype. After we verify that snapshots work fine we can make a release.
Great work!

README.adoc Outdated
Currently, all ServiceTalk released artifacts are available in a Bintray repo:
https://dl.bintray.com/servicetalk/servicetalk/, but will be published to Maven Central
link:https://github.com/apple/servicetalk/issues/845[soon].
All ServiceTalk released artifacts are available in link:https://repo1.maven.org/maven2/io/servicetalk/[the Maven

This comment has been minimized.

Copy link
@idelpivnitskiy

idelpivnitskiy Nov 7, 2019

Member

I would suggest reverting docs changes until this is actually true. We can update README.md after the release and after we test that everything resolves correctly with our sample projects.

This reverts commit d00c697.
@jayv jayv merged commit f67ce6f into apple:master Nov 7, 2019
3 checks passed
3 checks passed
pull request validation (jdk11) Build finished.
Details
pull request validation (jdk8) Build finished.
Details
pull request validation (quality) Build finished.
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.