-
Notifications
You must be signed in to change notification settings - Fork 3
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
AbstractPublishToMaven tasks depend on signing tasks #368
Conversation
Generate changelog in
|
71a1d03
to
ff44f48
Compare
publishGradlePlugin() | ||
|
||
when: | ||
ExecutionResult result = runSuccessfullyWithSigning('-P__TESTING_CIRCLE_TAG=tag', 'publishToMavenLocal', "--info", "--warning-mode=fail") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"--warning-mode=fail" making sure there are no gradle warnings anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's be better to just test with Gradle 8 using gradleVersion = '8.6'
.
697d90d
to
d984383
Compare
@@ -120,13 +121,18 @@ class ExternalPublishRootPluginIntegrationSpec extends IntegrationSpec { | |||
|
|||
if (type == 'gradle-plugin') { | |||
subprojectBuildGradle << ''' | |||
apply plugin: 'java-gradle-plugin' | |||
apply plugin: 'groovy' | |||
apply plugin: 'com.palantir.external-publish-jar' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this be applied by default by com.palantir.external-publish-gradle-plugin
? The com.palantir.external-publish-jar
sets up the MavenPublication
see:
Line 33 in f66f7f2
ExternalPublishBasePlugin.applyTo(project) |
If I remove this line, then some of the tests will fail with:
* Exception is:
org.gradle.internal.execution.WorkValidationException: A problem was found with the configuration of task ':gradle-plugin:publishPluginMavenPublicationToSonatypeRepository' (type 'PublishToMavenRepository').
- In plugin 'org.gradle.maven-publish' type 'org.gradle.api.publish.maven.tasks.PublishToMavenRepository' property 'credentials.username' doesn't have a configured value.
Reason: This property isn't marked as optional and no value has been configured.
Possible solutions:
1. Assign a value to 'credentials.username'.
2. Mark property 'credentials.username' as optional.```
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the gradle plugin publish plugin also sets up a publication to publish to the Gradle plugins portal? At least they end up in different places (gradle plugin portal vs maven central). I wonder if this is bit is now wrong/has changed:
Lines 51 to 57 in f125d70
ExtraPropertiesExtension extraProperties = project.getExtensions().getExtraProperties(); | |
extraProperties.set( | |
"gradle.publish.key", | |
envVars.envVarOrFromTestingProperty("GRADLE_KEY").getOrNull()); | |
extraProperties.set( | |
"gradle.publish.secret", | |
envVars.envVarOrFromTestingProperty("GRADLE_SECRET").getOrNull()); |
Honestly I thought it looked weird the other day as ExtraPropertiesExtension
is super old/deprecated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently this is still the way? https://docs.gradle.org/current/userguide/publishing_gradle_plugins.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the credentials setup is done per repo level (sonatypeRepo) and is configured by the nexus-publish plugin: https://github.com/palantir/gradle-external-publish-plugin/blob/develop/src/main/java/com/palantir/gradle/externalpublish/ExternalPublishRootPlugin.java#L48-L57. This means that publish<publicationName>toSonatypeRepository
should get the credentials for the sonatypeRepository
.
If we were to add the mavenPublication in the external-publish-gradle-plugin
similar to:
https://github.com/palantir/gradle-external-publish-plugin/blob/develop/src/main/java/com/palantir/gradle/externalpublish/ExternalPublishJarPlugin.java#L33-L35
it works. I guess this is the part we are missing in the plugin: https://github.com/gradle-nexus/publish-plugin?tab=readme-ov-file#add-metadata.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I'm a bit confused by all this. I think the Gradle plugin publish plugin is setting up a publication for us (pluginMaven
?). Publishing to the Gradle plugin portal shouldn't require anything to do to with sonatype though - that's just for publishing to maven central. I guess this only need to hold up this PR if we now need to add the jar... I'll take a look and investigate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I think I worked out what's going wrong. The Gradle plugin did not apply the ExternalPublishBasePlugin
, which has a method disableOtherPublicationsFromPublishingToSonatype
that stops non-sonatype publications from trying to publish to sonatype. The Gradle plugin publish plugin's publication was trying to be published to sonatype, but didn't have the creds as it never got them from the sonatype plugin. Now it is appropriately ignored.
d984383
to
220f4a3
Compare
|
||
then: | ||
result.success | ||
result.wasExecuted(":gradle-plugin:publishPluginMavenPublicationToMavenLocal") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gradle plugin portal does not need signing, we don't do it and so it doesn't need to be checked here.
This was a nasty one |
👍🏻 |
👍 |
Released 1.15.0 |
Before this PR
Failures in gradle 8.5 projects that are publishing multiple external publications: see circleCi failure
In
gradle-failure-reports
we have 2 publications:maven
andpluginMaven
which both generate the same artifact. Each publication has asign
task, both sign tasks write to the same output and clobber each other. Gradle thinks each one of the publish tasks for the publication is using the output of the wrong sign task so complains.After this PR
Workaround for implicit dependency gradle#26091
If the signing plugin is applied, then the publishing tasks
AbstractPublishToMaven
will depend onSign
tasks.==COMMIT_MSG==
AbstractPublishToMaven tasks depend on signing tasks
==COMMIT_MSG==
Possible downsides?