Browse Source

bintrayUpload task will fail if local.properties variables are missing

Aidan Follestad 6 years ago
parent
commit
5af7b0a18a
5 changed files with 36 additions and 38 deletions
  1. 24 10
      bintrayconfig.gradle
  2. 3 7
      color/build.gradle
  3. 3 7
      core/build.gradle
  4. 3 7
      files/build.gradle
  5. 3 7
      input/build.gradle

+ 24 - 10
bintrayconfig.gradle

@@ -2,6 +2,16 @@ if (!project.rootProject.file('local.properties').exists()) {
   println "Not applying install.gradle"
   return
 }
+apply plugin: 'com.novoda.bintray-release'
+
+def getBintrayUserAndKey() {
+  Properties properties = new Properties()
+  properties.load(project.rootProject.file('local.properties').newDataInputStream())
+  return [
+      properties.getProperty("bintray.user"),
+      properties.getProperty("bintray.apikey")
+  ]
+}
 
 if (shard == null) {
   throw new IllegalStateException("Must specify a shard in module's build.gradle")
@@ -9,20 +19,24 @@ if (shard == null) {
   throw new IllegalStateException("Unable to reference publishVersion")
 }
 
-Properties properties = new Properties()
-properties.load(project.rootProject.file('local.properties').newDataInputStream())
-
-String publishUser = properties.getProperty("bintray.user")
-String publishKey = properties.getProperty("bintray.apikey")
+task checkBintrayConfig {
+  doLast {
+    def (user, key) = getBintrayUserAndKey()
+    if (user == null || user.isEmpty() ||
+        key == null || key.isEmpty()) {
+      throw new IllegalStateException("Must specify Bintray user/API key in your local.properties.")
+    }
+  }
+}
 
-if (publishUser == null || publishUser.isEmpty() ||
-    publishKey == null || publishKey.isEmpty()) {
-  throw new IllegalStateException("Must specify Bintray user/API key in your local.properties.")
+afterEvaluate {
+  bintrayUpload.dependsOn checkBintrayConfig
 }
 
+def (user, key) = getBintrayUserAndKey()
 publish {
-  bintrayUser = publishUser
-  bintrayKey = publishKey
+  bintrayUser = user
+  bintrayKey = key
   userOrg = 'drummer-aidan'
   groupId = 'com.afollestad.material-dialogs'
   uploadName = "material-dialogs:$shard"

+ 3 - 7
color/build.gradle

@@ -3,9 +3,8 @@ apply plugin: 'kotlin-android'
 apply from: '../dependencies.gradle'
 apply plugin: "com.github.ben-manes.versions"
 
-if (project.rootProject.file('local.properties').exists()) {
-  apply plugin: 'com.novoda.bintray-release'
-}
+ext.shard = 'color'
+apply from: '../bintrayconfig.gradle'
 
 android {
   compileSdkVersion versions.compileSdk
@@ -32,7 +31,4 @@ dependencies {
   implementation project(':core')
 }
 
-apply from: '../spotless.gradle'
-
-ext.shard = 'color'
-apply from: '../bintrayconfig.gradle'
+apply from: '../spotless.gradle'

+ 3 - 7
core/build.gradle

@@ -3,9 +3,8 @@ apply plugin: 'kotlin-android'
 apply from: '../dependencies.gradle'
 apply plugin: "com.github.ben-manes.versions"
 
-if (project.rootProject.file('local.properties').exists()) {
-  apply plugin: 'com.novoda.bintray-release'
-}
+ext.shard = 'color'
+apply from: '../bintrayconfig.gradle'
 
 android {
   compileSdkVersion versions.compileSdk
@@ -34,7 +33,4 @@ dependencies {
   implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:' + versions.kotlin
 }
 
-apply from: '../spotless.gradle'
-
-ext.shard = 'core'
-apply from: '../bintrayconfig.gradle'
+apply from: '../spotless.gradle'

+ 3 - 7
files/build.gradle

@@ -3,9 +3,8 @@ apply plugin: 'kotlin-android'
 apply from: '../dependencies.gradle'
 apply plugin: "com.github.ben-manes.versions"
 
-if (project.rootProject.file('local.properties').exists()) {
-  apply plugin: 'com.novoda.bintray-release'
-}
+ext.shard = 'color'
+apply from: '../bintrayconfig.gradle'
 
 android {
   compileSdkVersion versions.compileSdk
@@ -32,7 +31,4 @@ dependencies {
   implementation project(':core')
 }
 
-apply from: '../spotless.gradle'
-
-ext.shard = 'files'
-apply from: '../bintrayconfig.gradle'
+apply from: '../spotless.gradle'

+ 3 - 7
input/build.gradle

@@ -3,9 +3,8 @@ apply plugin: 'kotlin-android'
 apply from: '../dependencies.gradle'
 apply plugin: "com.github.ben-manes.versions"
 
-if (project.rootProject.file('local.properties').exists()) {
-  apply plugin: 'com.novoda.bintray-release'
-}
+ext.shard = 'color'
+apply from: '../bintrayconfig.gradle'
 
 android {
   compileSdkVersion versions.compileSdk
@@ -32,7 +31,4 @@ dependencies {
   implementation project(':core')
 }
 
-apply from: '../spotless.gradle'
-
-ext.shard = 'input'
-apply from: '../bintrayconfig.gradle'
+apply from: '../spotless.gradle'