From 4c534de1c0239e6d63c2e16aa42c426d735ffc3c Mon Sep 17 00:00:00 2001 From: Hernan Zalazar Date: Wed, 23 Nov 2016 16:44:34 -0300 Subject: [PATCH] Add release scripts for jcenter --- build.gradle | 7 +-- guardian/build.gradle | 6 ++- scripts/bintray.gradle | 32 ++++++++++++ scripts/maven.gradle | 64 ++++++++++++++++++++++++ version.gradle => scripts/version.gradle | 2 + 5 files changed, 106 insertions(+), 5 deletions(-) create mode 100644 scripts/bintray.gradle create mode 100644 scripts/maven.gradle rename version.gradle => scripts/version.gradle (93%) diff --git a/build.gradle b/build.gradle index 5a3b1c1..d376c99 100644 --- a/build.gradle +++ b/build.gradle @@ -7,13 +7,14 @@ buildscript { dependencies { classpath 'com.android.tools.build:gradle:2.2.2' classpath 'com.dicedmelon.gradle:jacoco-android:0.1.1' - - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files + classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7' + classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' } } allprojects { + group = 'com.auth0.android' + repositories { jcenter() } diff --git a/guardian/build.gradle b/guardian/build.gradle index 05b7002..5c7bcab 100644 --- a/guardian/build.gradle +++ b/guardian/build.gradle @@ -1,5 +1,6 @@ apply plugin: 'com.android.library' apply plugin: 'jacoco-android' +apply from: '../scripts/version.gradle' android { compileSdkVersion 25 @@ -9,7 +10,7 @@ android { minSdkVersion 15 targetSdkVersion 25 versionCode 1 - versionName "0.1.0" + versionName project.version } buildTypes { release { @@ -52,4 +53,5 @@ dependencies { testCompile 'junit:junit:4.12' } -apply from: '../version.gradle' +apply from: '../scripts/maven.gradle' +apply from: '../scripts/bintray.gradle' \ No newline at end of file diff --git a/scripts/bintray.gradle b/scripts/bintray.gradle new file mode 100644 index 0000000..ce33d25 --- /dev/null +++ b/scripts/bintray.gradle @@ -0,0 +1,32 @@ +if (hasProperty('bintray.user') && hasProperty('bintray.key') && hasProperty('bintray.gpg.password')) { + def bintrayUser = getProperty('bintray.user') + def bintrayApiKey = getProperty('bintray.key') + def bintrayPassphrase = getProperty('bintray.gpg.password') + apply plugin: 'com.jfrog.bintray' + bintray { + user = bintrayUser + key = bintrayApiKey + configurations = ['archives'] + dryRun = project.version.endsWith("-SNAPSHOT") + publish = false + pkg { + repo = 'android' + name = 'Guardian.Android' + desc = 'Android toolkit for Auth0 Guardian API' + websiteUrl = 'https://github.com/auth0/guardian.android' + vcsUrl = 'scm:git@github.com:auth0/guardian.android.git' + licenses = ["MIT"] + userOrg = 'auth0' + publish = false + version { + gpg { + sign = true + passphrase = bintrayPassphrase + } + vcsTag = project.version + name = project.version + released = new Date() + } + } + } +} \ No newline at end of file diff --git a/scripts/maven.gradle b/scripts/maven.gradle new file mode 100644 index 0000000..82b4339 --- /dev/null +++ b/scripts/maven.gradle @@ -0,0 +1,64 @@ +apply plugin: 'com.github.dcendents.android-maven' + +install { + repositories.mavenInstaller { + pom { + project { + packaging 'aar' + artifactId 'guardian' + + name 'Guardian-Android' + description 'Android toolkit for Auth0 Guardian API' + url 'https://github.com/auth0/Guardian.Android' + + licenses { + license { + name 'The MIT License (MIT)' + url 'https://raw.githubusercontent.com/auth0/guardian.android/master/LICENSE' + distribution 'repo' + } + } + developers { + developer { + id 'hzalaz' + name 'Hernan Zalazar' + email 'hernan@auth0.com' + } + } + scm { + connection 'scm:git@github.com:auth0/Guardian.Android.git' + developerConnection 'scm:git@github.com:auth0/guardian.android.git' + url 'https://github.com/auth0/guardian.android' + + } + } + } + } +} + +task sourcesJar(type: Jar) { + from android.sourceSets.main.java.srcDirs + classifier = 'sources' +} + +task javadoc(type: Javadoc) { + source = android.sourceSets.main.java.srcDirs + classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) + exclude '**/BuildConfig.java' + exclude '**/R.java' + failOnError false +} + +afterEvaluate { + javadoc.classpath += project.android.libraryVariants.toList().first().javaCompile.classpath +} + +task javadocJar(type: Jar, dependsOn: javadoc) { + classifier = 'javadoc' + from javadoc.destinationDir +} + +artifacts { + archives javadocJar + archives sourcesJar +} \ No newline at end of file diff --git a/version.gradle b/scripts/version.gradle similarity index 93% rename from version.gradle rename to scripts/version.gradle index 3feb40f..3abd578 100644 --- a/version.gradle +++ b/scripts/version.gradle @@ -16,12 +16,14 @@ def describeGit(boolean snapshot, String defaultValue = null) { def arguments = ['describe', '--tags'] arguments.add(snapshot ? '--abbrev=0' : '--exact-match') def stdout = new ByteArrayOutputStream() + def errout = new ByteArrayOutputStream() def string = defaultValue try { def result = project.exec { executable = 'git' args = arguments standardOutput = stdout + errorOutput = errout } result.assertNormalExitValue()