From 50a48cc791d428cad53d08a77936c364270372bb Mon Sep 17 00:00:00 2001 From: d-kunin Date: Fri, 16 Aug 2013 13:41:37 +0300 Subject: [PATCH] [and, build] Gradle build files. --- 3rdparty/android-mwm/build.gradle | 34 ++++++ .../expansion_downloader/build.gradle | 35 ++++++ android/3rdparty/play_licensing/build.gradle | 34 ++++++ android/build.gradle | 111 ++++++++++++++++++ android/gradle.properties | 4 + android/settings.gradle | 4 + 6 files changed, 222 insertions(+) create mode 100644 3rdparty/android-mwm/build.gradle create mode 100644 android/3rdparty/expansion_downloader/build.gradle create mode 100644 android/3rdparty/play_licensing/build.gradle create mode 100644 android/build.gradle create mode 100644 android/gradle.properties create mode 100644 android/settings.gradle diff --git a/3rdparty/android-mwm/build.gradle b/3rdparty/android-mwm/build.gradle new file mode 100644 index 0000000..bcacd9e --- /dev/null +++ b/3rdparty/android-mwm/build.gradle @@ -0,0 +1,34 @@ +apply plugin: 'android-library' + +dependencies { + compile fileTree(dir: 'libs', include: '*.jar') +} + +android { + compileSdkVersion 17 + buildToolsVersion "18.0.1" + + sourceSets { + main { + manifest.srcFile 'AndroidManifest.xml' + java.srcDirs = ['src'] + resources.srcDirs = ['src'] + aidl.srcDirs = ['src'] + renderscript.srcDirs = ['src'] + res.srcDirs = ['res'] + assets.srcDirs = ['assets'] + } + + // Move the tests to tests/java, tests/res, etc... + instrumentTest.setRoot('tests') + + // Move the build types to build-types/ + // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ... + // This moves them out of them default location under src//... which would + // conflict with src/ being used by the main source set. + // Adding new build types or product flavors should be accompanied + // by a similar customization. + debug.setRoot('build-types/debug') + release.setRoot('build-types/release') + } +} diff --git a/android/3rdparty/expansion_downloader/build.gradle b/android/3rdparty/expansion_downloader/build.gradle new file mode 100644 index 0000000..34e2d52 --- /dev/null +++ b/android/3rdparty/expansion_downloader/build.gradle @@ -0,0 +1,35 @@ +apply plugin: 'android-library' + +dependencies { + compile fileTree(dir: 'libs', include: '*.jar') + compile project(':3rdparty:play_licensing') +} + +android { + compileSdkVersion 18 + buildToolsVersion "18.0.1" + + sourceSets { + main { + manifest.srcFile 'AndroidManifest.xml' + java.srcDirs = ['src'] + resources.srcDirs = ['src'] + aidl.srcDirs = ['src'] + renderscript.srcDirs = ['src'] + res.srcDirs = ['res'] + assets.srcDirs = ['assets'] + } + + // Move the tests to tests/java, tests/res, etc... + instrumentTest.setRoot('tests') + + // Move the build types to build-types/ + // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ... + // This moves them out of them default location under src//... which would + // conflict with src/ being used by the main source set. + // Adding new build types or product flavors should be accompanied + // by a similar customization. + debug.setRoot('build-types/debug') + release.setRoot('build-types/release') + } +} diff --git a/android/3rdparty/play_licensing/build.gradle b/android/3rdparty/play_licensing/build.gradle new file mode 100644 index 0000000..219fea5 --- /dev/null +++ b/android/3rdparty/play_licensing/build.gradle @@ -0,0 +1,34 @@ +apply plugin: 'android-library' + +dependencies { + compile fileTree(dir: 'libs', include: '*.jar') +} + +android { + compileSdkVersion 18 + buildToolsVersion "18.0.1" + + sourceSets { + main { + manifest.srcFile 'AndroidManifest.xml' + java.srcDirs = ['src'] + resources.srcDirs = ['src'] + aidl.srcDirs = ['src'] + renderscript.srcDirs = ['src'] + res.srcDirs = ['res'] + assets.srcDirs = ['assets'] + } + + // Move the tests to tests/java, tests/res, etc... + instrumentTest.setRoot('tests') + + // Move the build types to build-types/ + // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ... + // This moves them out of them default location under src//... which would + // conflict with src/ being used by the main source set. + // Adding new build types or product flavors should be accompanied + // by a similar customization. + debug.setRoot('build-types/debug') + release.setRoot('build-types/release') + } +} diff --git a/android/build.gradle b/android/build.gradle new file mode 100644 index 0000000..d9b7ffc --- /dev/null +++ b/android/build.gradle @@ -0,0 +1,111 @@ +buildscript { + repositories { mavenCentral() } + + dependencies { classpath 'com.android.tools.build:gradle:0.5.+' } +} + +// need it for :clean +apply plugin:'base' + +task ndkBuild(type:Exec) { + // TODO: add NDK_DEBUG=1 + commandLine 'ndk-build', '-j', Runtime.runtime.availableProcessors(), 'V=1' +} + +task ndkBuildClean(type:Exec) { + commandLine 'ndk-build','clean' +} + +task copyNativeLibs(type: Copy, dependsOn: 'ndkBuild') { + from(new File('libs')) { include '**/*.so' } + into new File(buildDir, 'native-libs') +} + +tasks.withType(Compile) { compileTask -> compileTask.dependsOn ndkBuild } +tasks.withType(Compile) { compileTask -> compileTask.dependsOn copyNativeLibs } + +clean.dependsOn 'cleanCopyNativeLibs' +clean.dependsOn 'ndkBuildClean' + +tasks.withType(com.android.build.gradle.tasks.PackageApplication) { pkgTask -> + pkgTask.jniDir new File(buildDir, 'native-libs') +} + +apply plugin: 'android' + +dependencies { + compile fileTree(dir: 'libs', include: '*.jar') + compile project(':android-mwm') + compile project(':3rdparty:expansion_downloader') +} + +def getVersionName() { + propVersionName +} + +def getVersionCode() { + propVersionCode +} + +def getPackageName() { + propPackageName +} + +def getBaseName() { + propApkName + '_' + getVersionName() +} + +android { + compileSdkVersion 18 + buildToolsVersion "18.0.1" + project.archivesBaseName = getBaseName() + + signingConfigs { + + guidewithme { + storeFile file("debug.keystore") + storePassword "android" + keyAlias "androiddebugkey" + keyPassword "android" + } + } + + buildTypes { + + debug { jniDebugBuild true } + + release { signingConfig signingConfigs.guidewithme } + } + + defaultConfig { + versionCode getVersionCode() + versionName getVersionName() + minSdkVersion 9 + targetSdkVersion 18 + } + + sourceSets { + + main { + manifest.srcFile 'AndroidManifest.xml' + java.srcDirs = ['src'] + resources.srcDirs = ['src'] + aidl.srcDirs = ['src'] + renderscript.srcDirs = ['src'] + res.srcDirs = ['res'] + assets.srcDirs = ['assets'] + } + + // Move the tests to tests/java, tests/res, etc... + instrumentTest.setRoot('tests') + + // Move the build types to build-types/ + // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ... + // This moves them out of them default location under src//... which would + // conflict with src/ being used by the main source set. + // Adding new build types or product flavors should be accompanied + // by a similar customization. + debug.setRoot('build-types/debug') + release.setRoot('build-types/release') + } +} diff --git a/android/gradle.properties b/android/gradle.properties new file mode 100644 index 0000000..c15c274 --- /dev/null +++ b/android/gradle.properties @@ -0,0 +1,4 @@ +propVersionCode=3 +propVersionName=1.0.2 +propPackageName=com.guidewithme.uk +propApkName=UK_GuideWithMe diff --git a/android/settings.gradle b/android/settings.gradle new file mode 100644 index 0000000..ea77448 --- /dev/null +++ b/android/settings.gradle @@ -0,0 +1,4 @@ +include ':3rdparty:play_licensing' +include ':3rdparty:expansion_downloader' +include ':android-mwm' +project(':android-mwm').projectDir = new File(settingsDir, '../3rdparty/android-mwm')