Skip to content

Commit

Permalink
Fix build signing after update to Gradle 4. (#832)
Browse files Browse the repository at this point in the history
* Fix build signing after update to Gradle 4.

* Remove old isReleaseBuild function.
  • Loading branch information
artem-zinnatullin authored Oct 16, 2017
1 parent a50b2f3 commit a978d97
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
17 changes: 13 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,19 @@ def validateTagAndVersion() {
if (projectVersion().isEmpty()) {
throw new IllegalStateException('Publishing is not allowed because current projectVersion is empty')
}

if ('development'.equals(projectVersion())) {
throw new IllegalStateException('Publishing is not allowed because current projectVersion is "development"')
}
}

def isValidReleaseState() {
try {
validateTagAndVersion()
return true
} catch (Exception e) {
return false
}
}

allprojects {
Expand All @@ -187,10 +200,6 @@ allprojects {

ext.VERSION_NAME = projectVersion()

def isReleaseBuild() {
return !projectVersion().equals('development')
}

def getReleaseRepositoryUrl() {
return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL
: 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
Expand Down
4 changes: 2 additions & 2 deletions gradle/publish-android-lib.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ afterEvaluate { project ->
}

signing {
required { isReleaseBuild() && gradle.taskGraph.hasTask('uploadArchives') }
required { isValidReleaseState() }
sign configurations.archives
}

Expand Down Expand Up @@ -128,4 +128,4 @@ afterEvaluate { project ->
}

uploadArchives.dependsOn validatePublishing
}
}
4 changes: 2 additions & 2 deletions gradle/publish-java-lib.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ afterEvaluate { project ->
}

signing {
required { isReleaseBuild() && gradle.taskGraph.hasTask('uploadArchives') }
required { isValidReleaseState() }
sign configurations.archives
}

Expand All @@ -100,4 +100,4 @@ afterEvaluate { project ->
}

uploadArchives.dependsOn validatePublishing
}
}

0 comments on commit a978d97

Please sign in to comment.