Skip to content

Instantly share code, notes, and snippets.

@MarkMjw
Last active August 29, 2015 13:56
Show Gist options
  • Save MarkMjw/9131476 to your computer and use it in GitHub Desktop.
Save MarkMjw/9131476 to your computer and use it in GitHub Desktop.
A gradle script for android jni.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.8.+'
}
}
apply plugin: 'android'
import org.apache.tools.ant.taskdefs.condition.Os
repositories {
mavenCentral();
maven {
url "http://www.bugsense.com/gradle/"
}
}
dependencies {
compile 'com.android.support:support-v4:18.0.+'
compile 'com.bugsense.trace:bugsense:3.6'
compile 'commons-io:commons-io:2.4'
compile 'com.google.android.gms:play-services:3.2.+'
compile 'com.github.gabrielemariotti.changeloglib:library:1.4.0'
compile fileTree(dir: 'jars', include: '*.jar')
}
android {
compileSdkVersion 19
buildToolsVersion "19.0.1"
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
}
Properties signingProperties = new Properties()
if (file("signing.properties").exists()) {
signingProperties.load(new FileInputStream(file("signing.properties")))
signingConfigs {
release {
storeFile file(signingProperties['signing.release.storeFile'])
storePassword signingProperties['signing.release.storePassword']
keyAlias signingProperties['signing.release.keyAlias']
keyPassword signingProperties['signing.release.keyPassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
beta {
signingConfig signingConfigs.release
}
}
}
buildTypes {
release {
buildConfigField "boolean", "USE_BUGSENSE", "true"
}
beta {
buildConfigField "boolean", "USE_BUGSENSE", "true"
}
debug {
buildConfigField "boolean", "USE_BUGSENSE", "false"
}
jnidebug.initWith(buildTypes.debug)
jnidebug {
jniDebugBuild true
}
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src/Java']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... 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.
beta.setRoot('build-types/beta')
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
// Create ZIP of CorsixTH Lua files
task createGameZip(type: Zip) {
destinationDir = file('assets')
archiveName = 'game.zip'
from('jni/src/CorsixTH') {
include 'Levels/**'
include 'Lua/**'
include 'CorsixTH.lua'
include 'Bitmap/aux_ui.*'
include 'Bitmap/tree_ctrl.*'
include 'Bitmap/mainmenu1080.dat'
include 'Bitmap/mainmenu1080.pal'
}
}
task ndkBuild(type: Exec) {
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
commandLine 'ndk-build.cmd', '-j'
} else {
commandLine 'ndk-build', '-j'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment