diff --git a/build.gradle b/build.gradle index cd38385aa..03948bc62 100644 --- a/build.gradle +++ b/build.gradle @@ -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 { @@ -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/' diff --git a/gradle/publish-android-lib.gradle b/gradle/publish-android-lib.gradle index d7873cb75..8966e61b9 100644 --- a/gradle/publish-android-lib.gradle +++ b/gradle/publish-android-lib.gradle @@ -89,7 +89,7 @@ afterEvaluate { project -> } signing { - required { isReleaseBuild() && gradle.taskGraph.hasTask('uploadArchives') } + required { isValidReleaseState() } sign configurations.archives } @@ -128,4 +128,4 @@ afterEvaluate { project -> } uploadArchives.dependsOn validatePublishing -} \ No newline at end of file +} diff --git a/gradle/publish-java-lib.gradle b/gradle/publish-java-lib.gradle index 2f7ecab1e..dc81ddbc3 100644 --- a/gradle/publish-java-lib.gradle +++ b/gradle/publish-java-lib.gradle @@ -74,7 +74,7 @@ afterEvaluate { project -> } signing { - required { isReleaseBuild() && gradle.taskGraph.hasTask('uploadArchives') } + required { isValidReleaseState() } sign configurations.archives } @@ -100,4 +100,4 @@ afterEvaluate { project -> } uploadArchives.dependsOn validatePublishing -} \ No newline at end of file +}