From bebd5e6dfcef29dcedd4255a41bbdc115bbee0b2 Mon Sep 17 00:00:00 2001 From: skydoves Date: Wed, 28 Oct 2020 00:18:07 +0900 Subject: [PATCH] Update gradle maven publising tasks --- build.gradle | 2 +- dependencies.gradle | 6 +- publish.gradle | 138 ++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 132 insertions(+), 14 deletions(-) diff --git a/build.gradle b/build.gradle index 852fcd3..47c16fc 100644 --- a/build.gradle +++ b/build.gradle @@ -9,7 +9,7 @@ buildscript { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$versions.kotlin" classpath "com.diffplug.spotless:spotless-plugin-gradle:$versions.spotlessGradle" classpath "org.jetbrains.dokka:dokka-android-gradle-plugin:$versions.dokkaGradle" - classpath "com.novoda:bintray-release:$versions.bintrayRelease" + classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$versions.bintrayPlugin" } } diff --git a/dependencies.gradle b/dependencies.gradle index 0727fb8..bb85c7a 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -5,12 +5,12 @@ ext.versions = [ versionName : '1.0.6', gradleBuildTool : '3.6.3', - spotlessGradle : '5.6.1', + spotlessGradle : '5.7.0', ktlintGradle : '0.39.0', dokkaGradle : '0.9.17', - bintrayRelease : '0.9.2', + bintrayPlugin : '1.8.5', - kotlin : '1.4.0', + kotlin : '1.4.10', androidxAppcompat: '1.2.0', // for demo diff --git a/publish.gradle b/publish.gradle index c4ce761..2cb6143 100644 --- a/publish.gradle +++ b/publish.gradle @@ -1,13 +1,131 @@ -apply plugin: 'com.novoda.bintray-release' +apply plugin: 'com.jfrog.bintray' +apply plugin: 'maven-publish' apply from: '../dependencies.gradle' -publish { - userOrg = 'devmagician' - groupId = 'com.github.skydoves' - artifactId = 'expandablelayout' - publishVersion = versions.versionName - desc = 'An expandable layout that shows a two-level layout with an indicator. ' - website = '/~https://github.com/skydoves/ExpandableLayout' - issueTracker = "${website}/issues" - repository = "${website}.git" +ext.repository = [ + name : "expandablelayout", + description: "An expandable layout that shows a two-level layout with an indicator.", + websiteUrl : "/~https://github.com/skydoves/ExpandableLayout", + scm : 'scm:git@github.com/skydoves/ExpandableLayout.git' +] + +def (property_user, property_key) = getBintrayProperties() +bintray { + user = property_user + key = property_key + + publications = ["release"] + publish = true + override = true + dryRun = false + + pkg { + repo = "maven" + name = repository.name + userOrg = "devmagician" + desc = repository.description + websiteUrl = repository.websiteUrl + vcsUrl = "${websiteUrl}.git" + issueTrackerUrl = "${websiteUrl}/issues" + licenses = ["Apache-2.0"] + labels = ["android"] + publicDownloadNumbers = false + + githubRepo = websiteUrl + githubReleaseNotesFile = "${websiteUrl}/releases" + + version { + desc = repository.description + name = versions.versionName + vcsTag = versions.versionName + released = new Date() + gpg { sign = true } + } + } +} + +afterEvaluate { + publishing { + publications { + release(MavenPublication) { + from components.release + + group = "com.github.skydoves" + artifactId = repository.name + version = versions.versionName + + artifact androidJavadocsJar + artifact(sourceJar) + + pom { + name = repository.name + description = repository.description + url = repository.websiteUrl + licenses { + license { + name = "The Apache License, Version 2.0" + url = "http://www.apache.org/licenses/LICENSE-2.0.txt" + } + } + developers { + developer { + id = "skydoves" + name = "Jaewoong Eum" + } + } + scm { + connection = repository.scm + developerConnection = repository.scm + url = repository.websiteUrl + } + } + } + } + } } + +def getBintrayProperties() { + def filename = "local.properties" + def propsFile = rootProject.file(filename) + if (propsFile.exists()) { + Properties properties = new Properties() + properties.load(project.rootProject.file(filename).newDataInputStream()) + return [ + properties.getProperty("bintray.user"), + properties.getProperty("bintray.key") + ] + } else { + print(filename + " does not exist!") + return ["", ""] + } +} + +task checkBintrayConfig { + doLast { + def (user, key) = getBintrayProperties() + if (user == null || user.isEmpty() || key == null || key.isEmpty()) { + throw new IllegalArgumentException("Must specify Bintray information! Check your local.properties file.") + } + } +} + +task androidJavadocs(type: Javadoc) { + source = android.sourceSets.main.java.srcDirs + classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) + android.libraryVariants.all { variant -> + if (variant.name == 'release') { + owner.classpath += variant.javaCompileProvider.get().classpath + } + } + exclude '**/R.html', '**/R.*.html', '**/index.html' +} + +task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) { + archiveClassifier.set('javadoc') + from androidJavadocs.destinationDir +} + +task sourceJar(type: Jar) { + from android.sourceSets.main.java.srcDirs + classifier "sources" +} \ No newline at end of file