108 lines
2.8 KiB
Groovy
108 lines
2.8 KiB
Groovy
buildscript {
|
|
repositories { mavenCentral() }
|
|
dependencies { classpath 'com.android.tools.build:gradle:1.3.1' }
|
|
}
|
|
|
|
apply plugin: 'com.android.application'
|
|
|
|
dependencies {
|
|
compile propAndroidSupportLibrary
|
|
compile project(':3rdparty:play_licensing')
|
|
compile project(':3rdparty:api-android:lib')
|
|
compile project(':3rdparty:expansion_downloader')
|
|
}
|
|
|
|
android {
|
|
compileSdkVersion propTargetSdkVersion.toInteger()
|
|
buildToolsVersion propBuildToolsVersion
|
|
project.archivesBaseName = GWMapk + "_" + GWMvn + "_" + GWMvc
|
|
|
|
signingConfigs {
|
|
|
|
guidewithme {
|
|
storeFile file("debug.keystore")
|
|
storePassword "android"
|
|
keyAlias "androiddebugkey"
|
|
keyPassword "android"
|
|
}
|
|
}
|
|
|
|
buildTypes {
|
|
|
|
debug {
|
|
jniDebuggable true
|
|
applicationIdSuffix ".debug"
|
|
}
|
|
|
|
release {
|
|
signingConfig signingConfigs.guidewithme
|
|
}
|
|
}
|
|
|
|
defaultConfig {
|
|
versionCode = Integer.valueOf(GWMvc)
|
|
versionName = GWMvn
|
|
applicationId = GWMpn
|
|
minSdkVersion propMinSdkVersion.toInteger()
|
|
targetSdkVersion propTargetSdkVersion.toInteger()
|
|
}
|
|
|
|
sourceSets {
|
|
main {
|
|
manifest.srcFile 'AndroidManifest.xml'
|
|
java.srcDirs = ['src']
|
|
resources.srcDirs = ['src']
|
|
aidl.srcDirs = ['src']
|
|
renderscript.srcDirs = ['src']
|
|
res.srcDirs = ['res']
|
|
assets.srcDirs = ['assets']
|
|
}
|
|
}
|
|
}
|
|
|
|
// replace app name
|
|
android.applicationVariants.all { variant ->
|
|
variant.mergeResources.doLast {
|
|
File valuesFile = file("${buildDir}/intermediates/res/merged/${variant.dirName}/values/values.xml")
|
|
println "Replacing app name in " + valuesFile
|
|
println "App name = " + GWMappName
|
|
|
|
String content = valuesFile.getText('UTF-8')
|
|
content = content.replaceAll(/\(app_name\)/, GWMappName)
|
|
valuesFile.write(content, 'UTF-8')
|
|
|
|
}
|
|
}
|
|
|
|
// need it for :clean
|
|
apply plugin:'base'
|
|
|
|
Properties properties = new Properties()
|
|
properties.load(project.rootProject.file('local.properties').newDataInputStream())
|
|
def NDK_BUILD = properties.getProperty('ndk.dir') + '/ndk-build'
|
|
|
|
task ndkBuild(type:Exec) {
|
|
def clParts = ([NDK_BUILD, '-j' + (Runtime.runtime.availableProcessors() + 1)] + GWMndkFlags.split(' ')).flatten()
|
|
println(clParts.join(" "))
|
|
commandLine clParts
|
|
}
|
|
|
|
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(JavaCompile) { compileTask -> compileTask.dependsOn ndkBuild }
|
|
tasks.withType(JavaCompile) { compileTask -> compileTask.dependsOn copyNativeLibs }
|
|
|
|
clean.dependsOn 'cleanCopyNativeLibs'
|
|
clean.dependsOn 'ndkBuildClean'
|
|
|
|
tasks.withType(com.android.build.gradle.tasks.PackageApplication) { pkgTask ->
|
|
pkgTask.jniFolders = new HashSet<File>()
|
|
pkgTask.jniFolders.add(new File(buildDir, 'native-libs'))
|
|
}
|