aboutsummaryrefslogtreecommitdiff
path: root/android/olm-sdk/build.gradle
diff options
context:
space:
mode:
authorYannick LE COLLEN <yannick@matrix.org>2017-01-10 16:09:18 +0100
committerGitHub <noreply@github.com>2017-01-10 16:09:18 +0100
commit14c30da0e2bdff675c8af97e3c6ee49fba82af8d (patch)
treed1cc8cbe276b36bd80e9933f2c9c5532ae3a448f /android/olm-sdk/build.gradle
parentbd6ab72ca40e0484be2a39734ba135437e820d63 (diff)
parentccbb9606b725b8f1d7eeccf14c358b146aeee491 (diff)
Merge pull request #43 from matrix-org/pedroc/android_e2e_dev
Android wrappers for olm library
Diffstat (limited to 'android/olm-sdk/build.gradle')
-rw-r--r--android/olm-sdk/build.gradle130
1 files changed, 130 insertions, 0 deletions
diff --git a/android/olm-sdk/build.gradle b/android/olm-sdk/build.gradle
new file mode 100644
index 0000000..9ce4d37
--- /dev/null
+++ b/android/olm-sdk/build.gradle
@@ -0,0 +1,130 @@
+import org.apache.tools.ant.taskdefs.condition.Os
+
+apply plugin: 'com.android.library'
+
+android {
+ compileSdkVersion 21
+ buildToolsVersion '21.1.2'
+
+ defaultConfig {
+ minSdkVersion 11
+ targetSdkVersion 21
+ versionCode 1
+ versionName "1.0"
+ version "0.2.0"
+ testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+ }
+ buildTypes {
+ debug {
+ resValue "string", "git_olm_revision", "\"${gitRevision()}\""
+ resValue "string", "git_olm_revision_unix_date", "\"${gitRevisionUnixDate()}\""
+ resValue "string", "git_olm_revision_date", "\"${gitRevisionDate()}\""
+ }
+
+ release {
+ resValue "string", "git_olm_revision", "\"${gitRevision()}\""
+ resValue "string", "git_olm_revision_unix_date", "\"${gitRevisionUnixDate()}\""
+ resValue "string", "git_olm_revision_date", "\"${gitRevisionDate()}\""
+
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ }
+ }
+ sourceSets.main {
+ jniLibs.srcDir 'src/main/libs'
+ jni.srcDirs = []
+ }
+
+ task buildJavaDoc(type: Javadoc) {
+ source = android.sourceSets.main.java.srcDirs
+ classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
+ destinationDir = file("./doc/")
+ options.memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PRIVATE
+ failOnError false
+ }
+
+ task ndkBuildNativeRelease(type: Exec, description: 'NDK building..') {
+ println 'ndkBuildNativeRelease starts..'
+ workingDir file('src/main')
+ commandLine getNdkBuildCmd(), 'NDK_DEBUG=0'
+ }
+
+ task ndkBuildNativeDebug(type: Exec, description: 'NDK building..') {
+ println 'ndkBuildNativeDebug starts..'
+ workingDir file('src/main')
+ commandLine getNdkBuildCmd(), 'NDK_DEBUG=1'
+ }
+
+ task cleanNative(type: Exec, description: 'Clean NDK build') {
+ workingDir file('src/main')
+ commandLine getNdkBuildCmd(), 'clean'
+ }
+
+ 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
+ }
+ compileTask.dependsOn buildJavaDoc
+ }
+
+ clean.dependsOn cleanNative
+
+
+ libraryVariants.all { variant ->
+ variant.outputs.each { output ->
+ def outputFile = output.outputFile
+ if (outputFile != null && outputFile.name.endsWith('.aar')) {
+ def fileName = outputFile.name.replace(".aar", "-${version}.aar")
+ output.outputFile = new File(outputFile.parent, fileName)
+ }
+ }
+ }
+}
+
+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
+}
+
+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()
+}
+
+dependencies {
+ compile fileTree(include: ['*.jar'], dir: 'libs')
+ compile 'com.android.support:appcompat-v7:21.+'
+
+ testCompile 'junit:junit:4.12'
+ androidTestCompile 'junit:junit:4.12'
+ androidTestCompile 'com.android.support:support-annotations:21.0.0'
+ androidTestCompile 'com.android.support.test:runner:0.5'
+ androidTestCompile 'com.android.support.test:rules:0.5'
+}