Skip to content

Instantly share code, notes, and snippets.

@ngengesenior
Created June 12, 2025 15:17
Show Gist options
  • Select an option

  • Save ngengesenior/f6e46e93491287e844456e0176593539 to your computer and use it in GitHub Desktop.

Select an option

Save ngengesenior/f6e46e93491287e844456e0176593539 to your computer and use it in GitHub Desktop.
def isSnapshot = project.hasProperty("publishSnapshot") && project.property("publishSnapshot") == "true"
def version = project.property("version")
def groupId = project.property("groupId")
def artifactId = project.property("artifactId")
afterEvaluate {
publishing {
publications {
if (isSnapshot) {
create("snapshot", MavenPublication) {
from components.release
groupId = groupId // set via ext
artifactId = artifactId
version = "${version}-SNAPSHOT"
}
}
else {
create("release", MavenPublication) {
from components.release
groupId = project.groupId
artifactId = project.name
version = project.version
}
}
}
repositories {
maven {
url = uri(isSnapshot ? project.snapshotRepoUrl : project.releaseRepoUrl)
credentials {
username = project.repoUsername
password = project.repoPassword
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment