apply plugin: 'com.android.library' apply plugin: 'maven' apply plugin: 'signing' android { compileSdkVersion 26 buildToolsVersion "26.0.2" defaultConfig { minSdkVersion 14 targetSdkVersion 26 testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' } } } dependencies { testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support:support-annotations:27.1.0' androidTestImplementation 'com.android.support.test:runner:1.0.1' androidTestImplementation 'commons-net:commons-net:3.6' androidTestImplementation 'org.apache.commons:commons-lang3:3.7' } group = "com.hoho.android" 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.artifactId = 'usb-serial-for-android' 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' } } } } }