Index: build/android/gradle/build.gradle.jinja |
diff --git a/build/android/gradle/build.gradle.jinja b/build/android/gradle/build.gradle.jinja |
index 98359046dea1058f5b6f30bf820546b96d7020d5..0ef038200591362bd13da688649d72fcda349e06 100644 |
--- a/build/android/gradle/build.gradle.jinja |
+++ b/build/android/gradle/build.gradle.jinja |
@@ -13,9 +13,12 @@ buildscript { |
} |
} |
-{% elif template_type == 'java_library' %} |
+{% elif template_type in ('java_library', 'java_binary') %} |
apply plugin: "java" |
+{% if template_type == 'java_binary' %} |
+apply plugin: "application" |
+{% endif %} |
sourceSets { |
main { |
@@ -30,9 +33,17 @@ sourceSets { |
sourceCompatibility = JavaVersion.VERSION_1_7 |
targetCompatibility = JavaVersion.VERSION_1_7 |
+{% if template_type == 'java_binary' %} |
+mainClassName = "{{ main_class }}" |
+applicationName = "{{ target_name }}" |
+{% endif %} |
+{% if template_type in ('java_binary', 'java_library') %} |
+archivesBaseName = "{{ target_name }}" |
+{% endif %} |
+ |
{% else %} |
-{% if template_type == 'android_library' %} |
+{% if template_type in ('android_library', 'android_junit') %} |
apply plugin: "com.android.library" |
{% elif template_type == 'android_apk' %} |
apply plugin: "com.android.application" |
@@ -49,37 +60,56 @@ android { |
} |
sourceSets { |
+{% for name in ['main', 'test', 'androidTest', 'debug', 'release'] %} |
+ {{ name }} { |
+ aidl.srcDirs = [] |
+ assets.srcDirs = [] |
+ java.srcDirs = [] |
+ jni.srcDirs = [] |
+ renderscript.srcDirs = [] |
+ res.srcDirs = [] |
+ resources.srcDirs = [] |
+ } |
+{% endfor %} |
+ |
+ main.manifest.srcFile "{{ android_manifest }}" |
+ |
+{% if template_type == 'android_library' %} |
main { |
- manifest.srcFile "{{ android_manifest }}" |
+{% else %} |
+ test { |
+{% endif %} |
java.srcDirs = [ |
{% for path in java_dirs %} |
"{{ path }}", |
{% endfor %} |
] |
- resources.srcDirs = [] |
- aidl.srcDirs = [] |
- renderscript.srcDirs = [] |
- res.srcDirs = [] |
- assets.srcDirs = [] |
} |
} |
} |
+ |
{% endif %} |
{% if template_type != 'root' %} |
dependencies { |
{% for path in prebuilts %} |
- compile files("{{ path }}") |
+ {{ depCompileName }} files("{{ path }}") |
{% endfor %} |
{% for proj in java_project_deps %} |
- compile project(":{{ proj }}") |
+ {{ depCompileName }} project(":{{ proj }}") |
{% endfor %} |
{% for proj in android_project_deps %} |
- debugCompile project(path: ":{{ proj }}", configuration: "debug") |
- releaseCompile project(path: ":{{ proj }}", configuration: "release") |
+ {{ depCompileName }} project(path: ":{{ proj }}", configuration: "debug") |
{% endfor %} |
} |
+{% if template_type.startswith('android') %} |
+android.variantFilter { variant -> |
+ if (variant.buildType.name.equals('release')) { |
+ variant.setIgnore(true); |
+ } |
+} |
+ |
afterEvaluate { |
def tasksToDisable = tasks.findAll { |
return (it.name.equals('generateDebugSources') // causes unwanted AndroidManifest.java |
@@ -100,3 +130,4 @@ afterEvaluate { |
} |
{% endif %} |
+{% endif %} |