Hi,
I am trying to publish both a binary jar and a separate sources jar to Nexus. I follow the example from http://www.gradle.org/docs/current/dsl/org.gradle.api.publish.maven.MavenPublication.html
So I have added a task:
task sourceJar(type: Jar) {
from sourceSets.main.allJava
}
// usage: gradle publish
publishing {
publications {
distributable(MavenPublication) {
artifact jar
}
sources(MavenPublication) {
from components.java
artifact sourceJar {
classifier "sources"
}
}
}
...
When I run gradle jar sourcesJar, I get two jars in my build forlder which seem fine.
However, when ruinning gradle publish, gradle creates jars with a different naming strategy, it seems. And this causes
:publishDistributablePublicationToNexusReleaseRepositoryUploading: de/example/example/0.1.10/example-example-0.1.10.jar to repository remote at http://nexus.example.de:8081/nexus/content/repositories/releases/
Transferring 2054K from remote
Uploaded 2054K
:generatePomFileForSourcesPublication
:sourceJar
:publishSourcesPublicationToNexusReleaseRepositoryUploading: de/example/example-example/0.1.10/example-example-0.1.10.jar to repository remote at http://nexus.example.de:8081/nexus/content/repositories/releases/
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':publishSourcesPublicationToNexusReleaseRepository'.
> Failed to publish publication 'sources' to repository 'nexusRelease'
> Error deploying artifact 'de.example:example-example:jar': Error deploying artifact: Failed to transfer file: http://nexus.example.de:8081/nexus/content/repositories/releases/de/example/example-example/0.1.10/example-example-0.1.10.jar. Return code is: 400
What I observe is that in the second case, there is no more suffix “-sources” in the jar filename, and I suspect that’s what causes the problem here. This was using gradle 1.12.
Any Ideas?