Aidan Follestad пре 4 година
родитељ
комит
f49016bd43

+ 0 - 1
build.gradle

@@ -10,7 +10,6 @@ buildscript {
 
   dependencies {
     classpath deps.gradle_plugins.android
-    classpath deps.gradle_plugins.bintray_release
     classpath deps.gradle_plugins.kotlin
     classpath deps.gradle_plugins.spotless
     classpath deps.gradle_plugins.versions

+ 2 - 3
dependencies.gradle

@@ -8,11 +8,10 @@ ext.versions = [
 
 ext.deps = [
     gradle_plugins: [
-        android: "com.android.tools.build:gradle:3.5.3",
+        android: "com.android.tools.build:gradle:4.1.2",
         kotlin: "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.61",
         spotless: "com.diffplug.spotless:spotless-plugin-gradle:3.27.1",
-        versions: "com.github.ben-manes:gradle-versions-plugin:0.27.0",
-        bintray_release: "com.novoda:bintray-release:0.9.2",
+        versions: "com.github.ben-manes:gradle-versions-plugin:0.27.0"
     ],
 
     androidx: [

+ 1 - 0
gradle.properties

@@ -13,3 +13,4 @@ org.gradle.jvmargs=-Xmx1536m
 # This option should only be used with decoupled projects. More details, visit
 # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
 # org.gradle.parallel=true
+android.useAndroidX=true

+ 1 - 1
gradle/android_application_config.gradle

@@ -5,4 +5,4 @@ if (module_package_id == null) {
   throw new IllegalStateException("module_package_id is missing!")
 }
 
-android.defaultConfig.applicationId = module_package_id.replace('-', '')
+android.defaultConfig.applicationId = module_package_id.replace('-', '')

+ 0 - 48
gradle/android_bintray_config.gradle

@@ -1,48 +0,0 @@
-if (!project.rootProject.file('local.properties').exists()) {
-  logger.warn("local.properties not found. Skipping Bintray Release setup.")
-  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 (versions == null || versions.publish_version == null) {
-  throw new IllegalStateException("Unable to reference publish_version!")
-} else if (module_group == null || module_name == null) {
-  throw new IllegalStateException("Must provide module_group and module_name!")
-}
-
-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.")
-    }
-  }
-}
-
-afterEvaluate {
-  bintrayUpload.dependsOn checkBintrayConfig
-}
-
-def (user, key) = getBintrayUserAndKey()
-publish {
-  bintrayUser = user
-  bintrayKey = key
-  userOrg = "drummer-aidan"
-  groupId = module_group
-  uploadName = "material-dialogs:$module_name"
-  artifactId = module_name
-  publishVersion = versions.publish_version
-  desc = "A beautiful, fluid, and customizable dialogs API."
-  website = "https://github.com/afollestad/material-dialogs"
-  dryRun = false
-}

+ 1 - 1
gradle/android_library_config.gradle

@@ -1,4 +1,4 @@
 apply plugin: "com.android.library"
 
 apply from: rootProject.file("gradle/android_common_config.gradle")
-apply from: rootProject.file("gradle/android_bintray_config.gradle")
+apply from: rootProject.file("gradle/android_publish_mavencentral.gradle")

+ 130 - 0
gradle/android_publish_mavencentral.gradle

@@ -0,0 +1,130 @@
+if (versions == null || versions.publish_version == null) {
+  throw new IllegalStateException("Unable to reference publish_version!")
+} else if (module_group == null || module_name == null) {
+  throw new IllegalStateException("Must provide module_group and module_name!")
+}
+
+apply plugin: 'maven-publish'
+apply plugin: 'signing'
+
+task androidSourcesJar(type: Jar) {
+  archiveClassifier.set('sources')
+  if (project.plugins.findPlugin("com.android.library")) {
+    // For Android libraries
+    from android.sourceSets.main.java.srcDirs
+    from android.sourceSets.main.kotlin.srcDirs
+  } else {
+    // For pure Kotlin libraries, in case you have them
+    from sourceSets.main.java.srcDirs
+    from sourceSets.main.kotlin.srcDirs
+  }
+}
+
+artifacts {
+  archives androidSourcesJar
+}
+
+group = module_group
+version = versions.publish_version
+
+// Default values
+ext["signing.keyId"] = ''
+ext["signing.password"] = ''
+ext["signing.secretKeyRingFile"] = ''
+ext["ossrhUsername"] = ''
+ext["ossrhPassword"] = ''
+ext["sonatypeStagingProfileId"] = ''
+
+File secretPropsFile = project.rootProject.file('local.properties')
+if (secretPropsFile.exists()) {
+  Properties p = new Properties()
+  new FileInputStream(secretPropsFile).withCloseable { is -> p.load(is) }
+  p.each { name, value -> ext[name] = value }
+} else {
+  ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID')
+  ext["signing.password"] = System.getenv('SIGNING_PASSWORD')
+  ext["signing.secretKeyRingFile"] = System.getenv('SIGNING_SECRET_KEY_RING_FILE')
+  ext["ossrhUsername"] = System.getenv('OSSRH_USERNAME')
+  ext["ossrhPassword"] = System.getenv('OSSRH_PASSWORD')
+  ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID')
+}
+
+publishing {
+  publications {
+    release(MavenPublication) {
+      // The coordinates of the library, being set from variables that
+      // we'll set up later
+      groupId module_group
+      artifactId module_name
+      version versions.publish_version
+
+      // Two artifacts, the `aar` (or `jar`) and the sources
+      if (project.plugins.findPlugin("com.android.library")) {
+        artifact("$buildDir/outputs/aar/${project.getName()}-release.aar")
+      } else {
+        artifact("$buildDir/libs/${project.getName()}-${version}.jar")
+      }
+      artifact androidSourcesJar
+
+      // Mostly self-explanatory metadata
+      pom {
+        packaging 'aar'
+        name = module_name
+        description = '😍 A beautiful, fluid, and extensible dialogs API for Kotlin & Android.'
+        url = 'https://github.com/afollestad/material-dialogs'
+        licenses {
+          license {
+            name = 'Apache 2.0 License'
+            url = 'https://github.com/afollestad/material-dialogs/blob/main/LICENSE.md'
+          }
+        }
+        developers {
+          developer {
+            id = 'afollestad'
+            name = 'Aidan Follestad'
+            email = 'dont-email-me@af.codes'
+          }
+          // Add all other devs here...
+        }
+        // Version control info - if you're using GitHub, follow the format as seen here
+        scm {
+          connection = 'scm:git:github.com/afollestad/material-dialogs.git'
+          developerConnection = 'scm:git:ssh://github.com/afollestad/material-dialogs.git'
+          url = 'https://github.com/afollestad/material-dialogs/tree/main'
+        }
+        // A slightly hacky fix so that your POM will include any transitive dependencies
+        // that your library builds upon
+        withXml {
+          def dependenciesNode = asNode().appendNode('dependencies')
+          project.configurations.implementation.allDependencies.each {
+            def dependencyNode = dependenciesNode.appendNode('dependency')
+            dependencyNode.appendNode('groupId', it.group)
+            dependencyNode.appendNode('artifactId', it.name)
+            dependencyNode.appendNode('version', it.version)
+          }
+        }
+      }
+    }
+  }
+  // The repository to publish to, Sonatype/MavenCentral
+  repositories {
+    maven {
+      // This is an arbitrary name, you may also use "mavencentral" or
+      // any other name that's descriptive for you
+      name = "sonatype"
+      url = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
+      credentials {
+        username ossrhUsername
+        password ossrhPassword
+      }
+    }
+  }
+}
+
+signing {
+  sign publishing.publications
+}
+
+afterEvaluate {
+  publishReleasePublicationToSonatypeRepository.dependsOn assembleRelease
+}

+ 1 - 1
gradle/wrapper/gradle-wrapper.properties

@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
 zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.2-bin.zip