Is it possible using new maven-publish plugin to select repository to publish to based on version (release vs snapshot)


(Doug Lethin) #1

I’m continuing my POC to convert one of our projects maven build to gradle.

I’m now at the point where I’m exploring the new incubating maven-publish plugin.

My org defines separate repositories for snapshots and releases. Is it possible in my publishing/repositories block to define two different repositories and mark which one is to be used for snapshots and which can be used for releases.

If it is possible, can someone provide an example or suggest a workaround if its not possible.

Thanks.

Doug


(Doug Lethin) #2

Never mind. This appears to be rather brain-dead simple.

Looks like I just need to do this –

publishing {
    publications {
      repositories {
        if (version.endsWith("-SNAPSHOT")) {
          maven {
            url 'http://myrepo.com/snapshots'
          }
        } else {
          maven {
            url 'http://myrepo.com/release'
          }
        }
      }