2016-10-05 18:25:09 +02:00
|
|
|
import org.apache.tools.ant.taskdefs.condition.Os
|
|
|
|
|
|
|
|
apply plugin: 'com.android.library'
|
|
|
|
|
|
|
|
android {
|
2018-06-26 10:39:33 +02:00
|
|
|
compileSdkVersion 27
|
|
|
|
buildToolsVersion '27.0.3'
|
2016-10-05 18:25:09 +02:00
|
|
|
|
|
|
|
defaultConfig {
|
|
|
|
minSdkVersion 11
|
|
|
|
targetSdkVersion 21
|
2018-07-04 21:24:44 +02:00
|
|
|
versionCode 230
|
|
|
|
versionName "2.3.0"
|
|
|
|
version "2.3.0"
|
2016-10-05 18:25:09 +02:00
|
|
|
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
|
|
|
}
|
|
|
|
buildTypes {
|
2017-01-09 16:39:54 +01:00
|
|
|
debug {
|
|
|
|
resValue "string", "git_olm_revision", "\"${gitRevision()}\""
|
|
|
|
resValue "string", "git_olm_revision_unix_date", "\"${gitRevisionUnixDate()}\""
|
|
|
|
resValue "string", "git_olm_revision_date", "\"${gitRevisionDate()}\""
|
|
|
|
}
|
|
|
|
|
2016-10-05 18:25:09 +02:00
|
|
|
release {
|
2017-01-09 16:39:54 +01:00
|
|
|
resValue "string", "git_olm_revision", "\"${gitRevision()}\""
|
|
|
|
resValue "string", "git_olm_revision_unix_date", "\"${gitRevisionUnixDate()}\""
|
|
|
|
resValue "string", "git_olm_revision_date", "\"${gitRevisionDate()}\""
|
|
|
|
|
2016-10-05 18:25:09 +02:00
|
|
|
minifyEnabled false
|
|
|
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sourceSets.main {
|
|
|
|
jniLibs.srcDir 'src/main/libs'
|
|
|
|
jni.srcDirs = []
|
|
|
|
}
|
|
|
|
|
2016-10-26 18:15:37 +02:00
|
|
|
task buildJavaDoc(type: Javadoc) {
|
|
|
|
source = android.sourceSets.main.java.srcDirs
|
|
|
|
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
|
|
|
|
destinationDir = file("./doc/")
|
2016-11-07 11:00:01 +01:00
|
|
|
options.memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PRIVATE
|
2016-10-26 18:15:37 +02:00
|
|
|
failOnError false
|
|
|
|
}
|
|
|
|
|
2016-10-06 19:55:03 +02:00
|
|
|
task ndkBuildNativeRelease(type: Exec, description: 'NDK building..') {
|
|
|
|
println 'ndkBuildNativeRelease starts..'
|
2016-10-05 18:25:09 +02:00
|
|
|
workingDir file('src/main')
|
2016-10-06 19:55:03 +02:00
|
|
|
commandLine getNdkBuildCmd(), 'NDK_DEBUG=0'
|
|
|
|
}
|
|
|
|
|
|
|
|
task ndkBuildNativeDebug(type: Exec, description: 'NDK building..') {
|
|
|
|
println 'ndkBuildNativeDebug starts..'
|
|
|
|
workingDir file('src/main')
|
|
|
|
commandLine getNdkBuildCmd(), 'NDK_DEBUG=1'
|
2016-10-05 18:25:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
task cleanNative(type: Exec, description: 'Clean NDK build') {
|
|
|
|
workingDir file('src/main')
|
|
|
|
commandLine getNdkBuildCmd(), 'clean'
|
|
|
|
}
|
|
|
|
|
2016-10-06 19:55:03 +02:00
|
|
|
tasks.withType(JavaCompile) {
|
|
|
|
compileTask -> if (compileTask.name.startsWith('compileDebugJava')) {
|
|
|
|
println 'test compile: Debug'
|
|
|
|
compileTask.dependsOn ndkBuildNativeDebug
|
|
|
|
} else if (compileTask.name.startsWith('compileReleaseJava')) {
|
|
|
|
println 'test compile: Release'
|
|
|
|
compileTask.dependsOn ndkBuildNativeRelease
|
|
|
|
}
|
2016-10-26 18:15:37 +02:00
|
|
|
compileTask.dependsOn buildJavaDoc
|
2016-10-05 18:25:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
clean.dependsOn cleanNative
|
2016-11-23 00:01:34 +01:00
|
|
|
|
|
|
|
|
|
|
|
libraryVariants.all { variant ->
|
|
|
|
variant.outputs.each { output ->
|
2018-06-26 10:39:33 +02:00
|
|
|
def outputFile = output.outputFileName
|
|
|
|
if (outputFile != null && outputFile.endsWith('.aar')) {
|
|
|
|
output.outputFileName = outputFile.replace(".aar", "-${version}.aar")
|
2016-11-23 00:01:34 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-10-05 18:25:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
def getNdkFolder() {
|
|
|
|
Properties properties = new Properties()
|
|
|
|
properties.load(project.rootProject.file('local.properties').newDataInputStream())
|
|
|
|
def ndkFolder = properties.getProperty('ndk.dir', null)
|
|
|
|
if (ndkFolder == null)
|
|
|
|
throw new GradleException("NDK location missing. Define it with ndk.dir in the local.properties file")
|
|
|
|
|
|
|
|
return ndkFolder
|
|
|
|
}
|
|
|
|
|
|
|
|
def getNdkBuildCmd() {
|
|
|
|
def ndkBuildCmd = getNdkFolder() + "/ndk-build"
|
|
|
|
if (Os.isFamily(Os.FAMILY_WINDOWS))
|
|
|
|
ndkBuildCmd += ".cmd"
|
|
|
|
|
|
|
|
return ndkBuildCmd
|
|
|
|
}
|
|
|
|
|
2017-01-09 16:39:54 +01:00
|
|
|
def gitRevision() {
|
|
|
|
def cmd = "git rev-parse --short HEAD"
|
|
|
|
return cmd.execute().text.trim()
|
|
|
|
}
|
|
|
|
|
|
|
|
def gitRevisionUnixDate() {
|
|
|
|
def cmd = "git show -s --format=%ct HEAD^{commit}"
|
|
|
|
return cmd.execute().text.trim()
|
|
|
|
}
|
|
|
|
|
|
|
|
def gitRevisionDate() {
|
|
|
|
def cmd = "git show -s --format=%ci HEAD^{commit}"
|
|
|
|
return cmd.execute().text.trim()
|
|
|
|
}
|
|
|
|
|
2016-10-05 18:25:09 +02:00
|
|
|
dependencies {
|
2018-06-26 10:39:33 +02:00
|
|
|
testImplementation 'junit:junit:4.12'
|
|
|
|
androidTestImplementation 'junit:junit:4.12'
|
|
|
|
androidTestImplementation 'com.android.support:support-annotations:27.1.1'
|
|
|
|
androidTestImplementation 'com.android.support.test:runner:1.0.2'
|
|
|
|
androidTestImplementation 'com.android.support.test:rules:1.0.2'
|
2016-10-05 18:25:09 +02:00
|
|
|
}
|