File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -61,13 +61,11 @@ version = resolveProjectVersion()
6161def 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
6768publishing {
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+ }
You can’t perform that action at this time.
0 commit comments