import org.apache.tools.ant.taskdefs.condition.Os apply plugin: 'com.android.library' apply plugin: 'com.github.dcendents.android-maven' apply plugin: 'com.jfrog.bintray' Properties properties = new Properties() properties.load(project.rootProject.file('local.properties').newDataInputStream()) android { compileSdkVersion 23 buildToolsVersion "23.0.3" defaultConfig { minSdkVersion 15 targetSdkVersion 22 versionCode 1 versionName "1.0" proguardFiles 'proguard-rules.pro' consumerProguardFiles 'proguard-rules.pro' } sourceSets { main { manifest.srcFile 'AndroidManifest.xml' java.srcDirs = ['src'] res.srcDirs = ['res'] jni.srcDirs = [] jniLibs.srcDirs = ['libs'] } } // Call external ndk-build(.cmd) script to build the native code task ndkBuild(type: Exec) { def ndkDirProperty = properties.getProperty('ndk.dir') def ndkDirPrefix = ndkDirProperty != null ? ndkDirProperty + '/' : '' def ndkBuildExt = Os.isFamily(Os.FAMILY_WINDOWS) ? ".cmd" : "" commandLine "${ndkDirPrefix}ndk-build${ndkBuildExt}", '-C', file('.').absolutePath, '-j', Runtime.runtime.availableProcessors() } tasks.withType(JavaCompile) { compileTask -> compileTask.dependsOn ndkBuild } // Cleanup task to remove previously generated binaries task ndkClean(type: Exec) { def ndkDirProperty = properties.getProperty('ndk.dir') def ndkDirPrefix = ndkDirProperty != null ? ndkDirProperty + '/' : '' def ndkBuildExt = Os.isFamily(Os.FAMILY_WINDOWS) ? ".cmd" : "" commandLine "${ndkDirPrefix}ndk-build${ndkBuildExt}", '-C', file('.').absolutePath, 'clean' } tasks.withType(Delete) { cleanTask -> cleanTask.dependsOn ndkClean } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) } // Settings for uploading module AAR to Bintray for library distribution task sourcesJar(type: Jar) { from android.sourceSets.main.java.srcDirs classifier = 'sources' } task javadoc(type: Javadoc) { failOnError = false source = android.sourceSets.main.java.srcDirs classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) options { links "http://docs.oracle.com/javase/7/docs/api/" linksOffline "http://d.android.com/reference","${android.sdkDirectory}/docs/reference" } } task javadocJar(type: Jar, dependsOn: javadoc) { classifier = 'javadoc' from javadoc.destinationDir } artifacts { archives javadocJar archives sourcesJar } install { repositories.mavenInstaller { pom.project { name = 'tess-two' packaging = 'aar' groupId = 'com.rmtheis' artifactId = 'tess-two' developers { developer { id = 'rmtheis' name = 'Robert Theis' email = 'robert.m.theis@gmail.com' } } licenses { license { name = 'The Apache Software License, Version 2.0' url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' distribution = 'repo' } } scm { url 'https://github.com/rmtheis/tess-two' } } } } bintray { user = properties.getProperty("bintray.user") key = properties.getProperty("bintray.apikey") configurations = ['archives'] pkg { repo = 'maven' name = 'tess-two' userOrg = user publish = true } }