Maven-publish - specify a repo as being a "snapshot" repo


(Patrick Wong) #1

Something like this?

publishing {
    repositories {
        maven {
            url "${artifactRepoBase}/libs-release-local"
            credentials(standardCredentials)
        }
        maven {
            url "${artifactRepoBase}/libs-snapshot-local"
            credentials(standardCredentials)
            snapshot true
        }
    }
}

Then, if you have previously specified the project version as being a “-SNAPSHOT” version, Gradle would prefer to upload to a snapshot repo first.


(Luke Daley) #2

Hi Patrick,

We aren’t very keen on adding specific handling for snapshots, even though Maven has this (we don’t aim to replicate every Maven feature).

The primary reason is that the differentiating on snapshots is somewhat arbitrary. For example, some people want to push release candidates to specific repositories.

If you want to simular this kind of behaviour yourself, it’s quite easy…

publishing {
    repositories {
        maven {
            url "${artifactRepoBase}/libs-${project.version.endsWith('-SNAPSHOT') ? 'snapshot' : 'release' }-local"
            credentials(standardCredentials)
        }
    }
}

Thanks for taking the time to submit your idea.


(Ben Fagin) #3

This works great for me. Thanks!