diff --git a/build.gradle b/build.gradle index 2545b16..45ba66b 100644 --- a/build.gradle +++ b/build.gradle @@ -1,4 +1,5 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. +// Top-level gradle script. + buildscript { repositories { mavenCentral() diff --git a/usbSerialForAndroid/build.gradle b/usbSerialForAndroid/build.gradle index ed38c0f..b5cdc1a 100644 --- a/usbSerialForAndroid/build.gradle +++ b/usbSerialForAndroid/build.gradle @@ -1,4 +1,6 @@ apply plugin: 'android-library' +apply plugin: 'maven' +apply plugin: 'signing' android { compileSdkVersion 19 @@ -16,3 +18,81 @@ android { } } } + +group = "com.hoho" +version = "0.2.0-SNAPSHOT" + +configurations { + archives { + extendsFrom configurations.default + } +} + +signing { + required { has("release") && gradle.taskGraph.hasTask("uploadArchives") } + sign configurations.archives +} + +def getRepositoryUsername() { + return hasProperty('sonatypeUsername') ? sonatypeUsername : "" +} + +def getRepositoryPassword() { + return hasProperty('sonatypePassword') ? sonatypePassword : "" +} + +def isReleaseBuild() { + return version.contains("SNAPSHOT") == false +} + +uploadArchives { + def sonatypeRepositoryUrl + if (isReleaseBuild()) { + println 'RELEASE BUILD' + sonatypeRepositoryUrl = hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL + : "https://oss.sonatype.org/service/local/staging/deploy/maven2/" + } else { + println 'SNAPSHOT BUILD' + sonatypeRepositoryUrl = hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL + : "https://oss.sonatype.org/content/repositories/snapshots/" + } + + configuration = configurations.archives + repositories.mavenDeployer { + beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } + + repository(url: sonatypeRepositoryUrl) { + authentication(userName: getRepositoryUsername(), + password: getRepositoryPassword()) + } + + pom.project { + name 'usb-serial-for-android' + packaging 'aar' + description 'USB Serial Driver Library for Android' + url 'https://github.com/mik3y/usb-serial-for-android' + + scm { + url 'scm:git@github.com:mik3y/usb-serial-for-android.git' + connection 'scm:git@github.com:mik3y/usb-serial-for-android.git' + developerConnection 'scm:git@github.com:mik3y/usb-serial-for-android.git' + } + + licenses { + license { + name 'GNU LGPL v2.1' + url 'http://www.gnu.org/licenses/lgpl-2.1.txt' + distribution 'repo' + } + } + + developers { + developer { + id 'mik3y' + name 'mik3y' + email 'opensource@hoho.com' + } + } + } + } +}