Deploy specific artifact?


(Sebastian Peters) #1

I’ve written a plugin that takes the default output of the buildDir/libs artifacts and puts them into a ZIP file that follows a special naming convention. However, I don’t know how to tell mavenDeployer which file it should deploy. By default, it simply takes the JAR file in buildDir/libs, as it would be expected, but my desired ZIP is in a completely different folder.

How do I specify the artifact to deploy? This is how it looks like now:

uploadArchives {
    repositories {
        mavenDeployer {
            repository(url: "${nexusBase}/ZIP-Releases") {
                authentication(userName: "${nexusUser}", password: "${nexusPassword}")
            } 
        }
    }
}

The Nexus settings are in gradle.properties.


(Sebastian Peters) #2

It feels like the question is so dumb that nobody wants to answer, which I would fully understand. I still need urgent help on this, though, because I wasn’t able to really advance in the last two days.

So far I was able to at least specify which specific artifact I want to upload, but I wasn’t able to exclude the default JARs. It simply uploads both:

def myZip = file("${buildDir}/zip/Project.zip")
artifacts {
    archives myZip
}

uploadArchives {
    repositories {
        mavenDeployer {
            repository(url: "${nexusBase}/ZIP-Releases") {
                authentication(userName: "${nexusUser}", password: "${nexusPassword}")
            }
        }
    }
}

(Sebastian Peters) #3
project.configurations.archives.artifacts.clear();
artifacts {
    archives file: file("${buildDir}/zip/Project.zip")
}

This did the magic. Just gotta clear the artifact list first, then explicitely add every artifact I want to be in there.


(Dimitar Dimitrov) #4

Have you tried configurations.archives.remove(jar) ? The archives is configuration like any other, it is resolved by the upload task, which then uploads the artifacts (I am simplifying a bit).

Another thing you can try is to use the xxx-publish plugins, which require you to explicitly state what you are publishing and give you more control over the descriptors and artifact mapping.