Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save creativepsyco/10664971 to your computer and use it in GitHub Desktop.

Select an option

Save creativepsyco/10664971 to your computer and use it in GitHub Desktop.
buildscript {
repositories {
// rather than hit central each time with this:
// mavenCentral()
// we hit our company Nexus server ont he public group
// which includes the Central Repository
// and is local, so more performant
maven {
url "http://localhost:8081/nexus/content/groups/public"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4.2'
}
}
apply plugin: 'maven'
repositories {
// we also hit Nexus for all other dependencies!
maven {
url 'http://localhost:8081/nexus/content/groups/public'
}
}
uploadArchives {
repositories {
// the maven plugin features this deployer
mavenDeployer {
// we deploy to the release repository in this case
repository(url: "http://localhost:8081/nexus/content/repositories/releases") {
authentication(userName: 'admin', password: 'admin123gi')
}
}
}
}
android {
....
}
//////////////
// NDK Support
//////////////
// If using this, Android studio will fail run the following to set the environment variable for android studio:
// launchctl setenv ANDROID_NDK_HOME /Users/boos_patrick/Development/Android/android-ndk-r8e
// otherwise remove the dependsOn part and run ./gradlew buildNative from the command line
task copyNativeLibs(type: Copy, dependsOn: 'buildNative') {
dependsOn 'buildNative'
from(new File('libs')) { include '**/*.so' }
into new File(buildDir, 'native-libs')
}
tasks.withType(Compile) { compileTask -> compileTask.dependsOn copyNativeLibs }
clean.dependsOn 'cleanCopyNativeLibs'
tasks.withType(com.android.build.gradle.tasks.PackageApplication) { pkgTask ->
pkgTask.jniDir new File(buildDir, 'native-libs')
}
task buildNative(type: Exec) {
if (System.env.ANDROID_NDK_HOME != null) {
def ndkBuild = new File(System.env.ANDROID_NDK_HOME, 'ndk-build')
commandLine ndkBuild
} else {
doLast {
println '##################'
println 'Skipping NDK build'
println 'Reason: ANDROID_NDK_HOME not set.'
println '##################'
}
}
}
signingConfigs {
release {
def env = System.getenv()
if (env['GRADLE_KEYSTORE_FILE'] != null) {
storeFile file(env['GRADLE_KEYSTORE_FILE'])
storePassword env['GRADLE_KEYSTORE_PASSWORD']
keyAlias env['GRADLE_KEYSTORE_KEY_ALIAS']
keyPassword env['GRADLE_KEYSTORE_KEY_PASSWORD']
} else {
println ("##################")
println ("No keystore for release set.")
println ("Set GRADLE_KEYSTORE_FILE, GRADLE_KEYSTORE_PASSWORD,"
+ "GRADLE_KEYSTORE_KEY_ALIAS and GRADLE_KEYSTORE_KEY_PASSWORD")
println ("##################")
}
}
}
task spoon(type: JavaExec, dependsOn: ["assembleDebug", "assembleTest"]) {
main = "-jar"
args relativePath("../spoon-runner-1.0.6-SNAPSHOT-jar-with-dependencies.jar")
args "--apk"
args relativePath("build/apk/sample-app-debug-unaligned.apk")
args "--test-apk"
args relativePath("build/apk/sample-app-test-unaligned.apk")
args "--output"
args "build/spoon"
logger.info "main=${main},classpath=${classpath},args=${args}"
}
// UTF-8
tasks.withType(Compile) {
options.encoding = 'UTF-8'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment