During the build I can see that there are 3 poms generated
build/publications/pluginMaven/pom-default.xml
build/publications/mavenJava/pom-default.xml
build/publications/MyPluginNameMarkerMaven/pom-default.xml
Where the pluginMaven and the mavenJava pom are equal.
So during the publish tasks it trys to upload the artefact twice, which is by default disabled for releaseRepositories in our nexus.
So I think I have misconfigured the publish task.
I’m not sure how the java-gradle-plugin and the publish plugin work together and how to configure the pom generation.
Thank you a lot for this thread. I experienced the same issue, getting this error from our private nexus server:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':artifact-client-gradle-plugin:artifact-client-gradle-plugin:publishPluginMavenPublicationToMavenRepository'.
> Failed to publish publication 'pluginMaven' to repository 'maven'
> Could not write to resource 'https://example.com/nexus/repository/maven-releases/com/example/tools/some-gradle-plugin/1.0.0/some-gradle-plugin-1.0.0.jar'.
> Could not PUT 'https://example.com/nexus/repository/maven-releases/com/example/tools/some-gradle-plugin/1.0.0/some-gradle-plugin-1.0.0.jar'. Received status code 400 from server: Repository does not allow updating assets: maven-releases
Similar to you I had a publications bloc in the publishing section to publish the sources of the plugin:
With newer version of Gradle (I tried 5.6.2) I have seen this message when pushing to a local folder as repository:
> Task :publishPluginMavenPublicationToLocalRepository
Multiple publications with coordinates 'org.example:plugin-maven-publish:0.1-SNAPSHOT' are published to repository 'local'. The publications will overwrite each other!
If instead of a local folder you push to a nexus that is configured to reject overwrites (in case of a release repository it makes sense).
How to write the publishing section to upload the java-sources jar during the publication of the plugin?
I got a reply from Marc Philipp on twitter/github (see this PR in particular):
You should add the artifacts to the pluginMaven publication instead of creating a second one ( mavenJava )
Like this:
publishing {
// afterEvaluate is necessary because java-gradle-plugin
// creates its publications in an afterEvaluate callback
afterEvaluate {
publications {
pluginMaven {
// customize main publications here
artifact sourcesJar
artifact javadocJar
pom {
name = "main artifact"
}
}
}
}
}