| allprojects { |
| plugins.withType(JavaPlugin).whenPluginAdded { |
| sourceCompatibility = 1.7 |
| targetCompatibility = 1.7 |
| } |
| } |
| |
| def build(String buildType) { |
| def check = task("check-${buildType}") << { |
| if (System.getenv('MOJO_SDK') == null) { |
| throw new GradleException('MOJO_SDK not set') |
| } |
| } |
| def zip = task("zipMojo-${buildType}", type: Zip, dependsOn: [check, ':app:build']) { |
| destinationDir = file("${temporaryDir}/tmp") |
| archiveName = "${project.name}-${buildType}.zip" |
| |
| from('Manifest.txt') { |
| into('META-INF') |
| rename { fileName -> |
| fileName = 'MANIFEST.MF' |
| } |
| } |
| |
| from(zipTree("${project(':app').buildDir}/outputs/apk/app-${buildType}.apk")) { |
| include 'classes*.dex' |
| include 'lib/armeabi-v7a/libv23.so' |
| into('.') |
| eachFile { file -> |
| file.path = file.name |
| } |
| } |
| } |
| def gen = task("buildMojo-${buildType}", dependsOn: [zip]) << { |
| if (System.getenv('OUT_DIR') == null) { |
| throw new GradleException('OUT_DIR not set') |
| } |
| |
| def dst = new File("${System.getenv('OUT_DIR')}/${project.name}.mojo") |
| dst.parentFile.mkdirs() |
| dst.withOutputStream { out -> |
| out << "#!mojo mojo:java_handler\n" |
| out << file(zip.archivePath).bytes |
| } |
| } |
| } |
| |
| task buildMojo(dependsOn: build('release-unsigned')) |
| task buildMojoDebug(dependsOn: build('debug')) |
| |
| configure(buildMojo) { |
| group = 'Mojo build' |
| description = 'Builds mojo binaries with release apk' |
| } |
| |
| configure(buildMojoDebug) { |
| group = 'Mojo build' |
| description = 'Builds mojo binaries with debug apk' |
| } |
| |
| defaultTasks 'buildMojo' |