I have a multi-project gradle (version 2.1!!) build consisting of non-java projects.
I would like to deploy the generated artifacts (.tar.gz files) to a Nexus and also to a directory.
Currently I define the repositories in the root build.gradle
in the repositories
block and also again for each sub-project in a repositories
block inside the subprojects
in the root build.gradle
file.
I apply the base
plugin to the root project and the maven-publish
plugin to all subprojects that have artifacts to be deployed.
I tried to follow the instructions here:
- https://docs.gradle.org/2.1/userguide/publishing_maven.html
- https://docs.gradle.org/2.1/dsl/org.gradle.api.publish.maven.MavenPublication.html
- https://discuss.gradle.org/t/how-to-have-multiple-uploadarchives/19381/3
- How can I make uploadArchives dependent on another task?
- and a few more...
but nothing worked. :-(
Here's what I do:
...
# apply the maven-publish plugin only to sub-projects that produce artifacts that should be uploaded.
apply plugin: 'maven-publish'
publishing {
publications {
tarFiles (MavenPublication) {
artifact compressTar
}
}
repositories {
add rootProject.repositories.fsShare
add rootProject.repositories.nexusDeploy
}
}
...
The compressTar
is my custom Tar
task that creates the artifacts that I want to upload.
When I execute ./gradlew publishTarFilesPublicationToNexusDeployRepository
I get the following error:
Execution failed for task ':mySubProject:publishTarFilesPublicationToNexusDeployRepository'.
> Failed to publish publication 'tarFiles' to repository 'nexusDeploy'
> Failed to retrieve remote metadata myRootProject:mySubProject:0.0.0.0-SNAPSHOT/maven-metadata.xml: Could not transfer metadata myRootProject:mySubProject:0.0.0.0-SNAPSHOT/maven-metadata.xml from/to remote (https://myProject.nexus.url:443/nexus3/repository/builds/): Could not get resource 'myRootProject/mySubProject/0.0.0.0-SNAPSHOT/maven-metadata.xml'
When I execute uploadArchives
, the task succeeds, but nothing is uploaded anywhere and from the output it looks like the uploadArchives
task is only executed for sub-projects that didn't get the maven-plugin applied.
What is the right way to do this? Which plugins should I apply when/where?