Maven-publish plugin should support snapshot vs release repository semantics

plugins

(wayne) #1

Gradle Version: 2.14

Not including OS information because I don’t think it’s relevant.

Basically, my experience with various tools that publish to maven repositories, including the “uploadArchives” task from the “maven” gradle plugin (which if I understand correctly maven-publish is intended to supplant in the future), supports configuration of different repository policies for “release” vs “snapshot” artifacts.

Since it seems to me like being able to make this distinction is pretty standard behavior for tools that publish to maven repositories, I suspect it would be helpful for users transitioning to Gradle and the maven-publish plugin to be able to do something similar without being required to reinvent the logic (simple as it is) or copy-paste it from examples found in other projects.

It’s possible that I simply missed the “release” vs “snapshot” configurability somewhere in the documentation or API docs, but it doesn’t seem likely. Also, I’m not sure if this should be a “bug” or “feature request” or if I should have signed up for the gradle JIRA to file a ticket directly.


(Chris Beams) #2

Hi Wayne,

I’ve moved this topic to the Help/Discuss category, where non-bug questions and possible feature requests should be posted.

Regarding support for snapshot artifacts, what you’re looking for is possible, but not so easy to find. Please see https://docs.gradle.org/3.0/userguide/userguide_single.html#uploadWithSsh, where you’ll find a sample of customizing the MavenDeployer's repository like this:

uploadArchives {
    repositories.mavenDeployer {
        configuration = configurations.deployerJars
        repository(url: "scp://repos.mycompany.com/releases") {
            authentication(userName: "me", password: "myPassword")
        }
    }
}

You’ll then see below the sample a mention of snapshotRepository property, which can also be customized. Here’s the Javadoc for that property as well: https://docs.gradle.org/current/javadoc/org/gradle/api/artifacts/maven/MavenDeployer.html#setSnapshotRepository(java.lang.Object)

Hope that helps!


(Chris Beams) #3

Wayne, my apologies—I was a bit hasty in my response. I realize now that you’re already aware of the approach I listed above, and you’re asking about its equivalent in the maven-publish plugin.

Unfortunately the answer is that there isn’t a first-class equivalent, meaning that your options are (1) to, as you put it, “re-invent the logic”, e.g. by wrapping conditional blocks around the relevant parts of the DSL, or (2) to continue using the older maven plugin for now.

We are aware of these issues and plan to address them, but that work is not underway yet. I’ve made a note of this post in our plan for that work to remind ourselves about it when we do begin. Thanks.