Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3377)

Unified Diff: build/android/gradle/build.gradle.jinja

Issue 2508553002: generate_gradle.py: Add support for junit and java_binary targets (Closed)
Patch Set: update docs/android_studio.md to no long say junit doesn't work Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | build/android/gradle/generate_gradle.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 %}
« no previous file with comments | « no previous file | build/android/gradle/generate_gradle.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698