Skip to content

Commit 6d3f6cf

Browse files
committed
gradle fixes
1 parent 7edc330 commit 6d3f6cf

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

build.gradle

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,11 @@ version = resolveProjectVersion()
6161
def resolveProjectVersion() {
6262
def gitDescribe = 'git describe --exact-match HEAD'.execute().text.trim()
6363
def version = file("${rootDir}/version.txt").text.trim()
64-
return gitDescribe ? version : version + '-SNAPSHOT'
64+
def branchName = 'git rev-parse --abbrev-ref HEAD'.execute().text.trim()
65+
return gitDescribe ? version : branchName + '-SNAPSHOT'
6566
}
6667

6768
publishing {
68-
if (System.getenv().getOrDefault('CI_MODE', 'false') != 'true' && !version.contains('SNAPSHOT')) {
69-
throw new GradleException("You are attempting to publish a release from your local environment. Publishing releases is handled by CI")
70-
}
7169
publications {
7270
maven(MavenPublication) {
7371
artifact("build/libs/espresso-${version}.jar") {
@@ -90,3 +88,12 @@ publishing {
9088
}
9189
}
9290
}
91+
92+
tasks.withType(PublishToMavenRepository) {
93+
def predicate = provider {
94+
version.contains('SNAPSHOT') || System.getenv().getOrDefault('CI_MODE', 'false') == 'true'
95+
}
96+
onlyIf("Artifact is a snapshot or running in CI") {
97+
predicate.get()
98+
}
99+
}

0 commit comments

Comments
 (0)