0

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:

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?

Dominik
  • 141
  • 1
  • 3
  • 14

1 Answers1

0

Apparently there were two un-related "problems at work" here.

Problem 1): I was not able to publish to Nexus and got a Failed to retrieve remote metadata-error:

Answer 1): I was trying to publish a "SNAPSHOT" to a repository that was configured not to accept "SNAPSHOT" build. Renaming the build version from 1.2.3.4-SNAPSHOT to anything else (e.g. 1.2.3.4-SNAPSHOT-dev or more reasonable 1.2.3.build4`) worked fine.

Problem 2) Publishing to 'flatDir' repository didn't work. The maven-publish plugin didn't create the publish task for it.

Answer 2) To use maven-publish to publish to a directory, flatDir apparently is not recognized as repository the maven-publish plugin can publish to. Defining the 'directory' repository as follows worked fine:

maven {
    name "fsShare"
    url "/share/pkg"
}
Dominik
  • 141
  • 1
  • 3
  • 14