OLD | NEW |
1 {# Copyright 2016 The Chromium Authors. All rights reserved. #} | 1 {# Copyright 2016 The Chromium Authors. All rights reserved. #} |
2 {# Use of this source code is governed by a BSD-style license that can be #} | 2 {# Use of this source code is governed by a BSD-style license that can be #} |
3 {# found in the LICENSE file. #} | 3 {# found in the LICENSE file. #} |
4 // Generated by //build/android/generate_gradle.py | 4 // Generated by //build/android/generate_gradle.py |
5 {% if template_type == 'root' %} | 5 {% if template_type == 'root' %} |
6 | 6 |
7 buildscript { | 7 buildscript { |
8 repositories { | 8 repositories { |
9 jcenter() | 9 jcenter() |
10 } | 10 } |
11 dependencies { | 11 dependencies { |
12 classpath "com.android.tools.build:gradle:2.2.0" | 12 classpath "com.android.tools.build:gradle:2.2.0" |
13 } | 13 } |
14 } | 14 } |
15 | 15 |
16 {% elif template_type == 'java_library' %} | 16 {% elif template_type in ('java_library', 'java_binary') %} |
17 | 17 |
18 apply plugin: "java" | 18 apply plugin: "java" |
| 19 {% if template_type == 'java_binary' %} |
| 20 apply plugin: "application" |
| 21 {% endif %} |
19 | 22 |
20 sourceSets { | 23 sourceSets { |
21 main { | 24 main { |
22 java.srcDirs = [ | 25 java.srcDirs = [ |
23 {% for path in java_dirs %} | 26 {% for path in java_dirs %} |
24 "{{ path }}", | 27 "{{ path }}", |
25 {% endfor %} | 28 {% endfor %} |
26 ] | 29 ] |
27 } | 30 } |
28 } | 31 } |
29 | 32 |
30 sourceCompatibility = JavaVersion.VERSION_1_7 | 33 sourceCompatibility = JavaVersion.VERSION_1_7 |
31 targetCompatibility = JavaVersion.VERSION_1_7 | 34 targetCompatibility = JavaVersion.VERSION_1_7 |
32 | 35 |
| 36 {% if template_type == 'java_binary' %} |
| 37 mainClassName = "{{ main_class }}" |
| 38 applicationName = "{{ target_name }}" |
| 39 {% endif %} |
| 40 {% if template_type in ('java_binary', 'java_library') %} |
| 41 archivesBaseName = "{{ target_name }}" |
| 42 {% endif %} |
| 43 |
33 {% else %} | 44 {% else %} |
34 | 45 |
35 {% if template_type == 'android_library' %} | 46 {% if template_type in ('android_library', 'android_junit') %} |
36 apply plugin: "com.android.library" | 47 apply plugin: "com.android.library" |
37 {% elif template_type == 'android_apk' %} | 48 {% elif template_type == 'android_apk' %} |
38 apply plugin: "com.android.application" | 49 apply plugin: "com.android.application" |
39 {% endif %} | 50 {% endif %} |
40 | 51 |
41 android { | 52 android { |
42 compileSdkVersion {{ compile_sdk_version }} | 53 compileSdkVersion {{ compile_sdk_version }} |
43 buildToolsVersion "{{ build_tools_version }}" | 54 buildToolsVersion "{{ build_tools_version }}" |
44 publishNonDefault true | 55 publishNonDefault true |
45 | 56 |
46 compileOptions { | 57 compileOptions { |
47 sourceCompatibility JavaVersion.VERSION_1_7 | 58 sourceCompatibility JavaVersion.VERSION_1_7 |
48 targetCompatibility JavaVersion.VERSION_1_7 | 59 targetCompatibility JavaVersion.VERSION_1_7 |
49 } | 60 } |
50 | 61 |
51 sourceSets { | 62 sourceSets { |
| 63 {% for name in ['main', 'test', 'androidTest', 'debug', 'release'] %} |
| 64 {{ name }} { |
| 65 aidl.srcDirs = [] |
| 66 assets.srcDirs = [] |
| 67 java.srcDirs = [] |
| 68 jni.srcDirs = [] |
| 69 renderscript.srcDirs = [] |
| 70 res.srcDirs = [] |
| 71 resources.srcDirs = [] |
| 72 } |
| 73 {% endfor %} |
| 74 |
| 75 main.manifest.srcFile "{{ android_manifest }}" |
| 76 |
| 77 {% if template_type == 'android_library' %} |
52 main { | 78 main { |
53 manifest.srcFile "{{ android_manifest }}" | 79 {% else %} |
| 80 test { |
| 81 {% endif %} |
54 java.srcDirs = [ | 82 java.srcDirs = [ |
55 {% for path in java_dirs %} | 83 {% for path in java_dirs %} |
56 "{{ path }}", | 84 "{{ path }}", |
57 {% endfor %} | 85 {% endfor %} |
58 ] | 86 ] |
59 resources.srcDirs = [] | |
60 aidl.srcDirs = [] | |
61 renderscript.srcDirs = [] | |
62 res.srcDirs = [] | |
63 assets.srcDirs = [] | |
64 } | 87 } |
65 } | 88 } |
66 } | 89 } |
| 90 |
67 {% endif %} | 91 {% endif %} |
68 {% if template_type != 'root' %} | 92 {% if template_type != 'root' %} |
69 | 93 |
70 dependencies { | 94 dependencies { |
71 {% for path in prebuilts %} | 95 {% for path in prebuilts %} |
72 compile files("{{ path }}") | 96 {{ depCompileName }} files("{{ path }}") |
73 {% endfor %} | 97 {% endfor %} |
74 {% for proj in java_project_deps %} | 98 {% for proj in java_project_deps %} |
75 compile project(":{{ proj }}") | 99 {{ depCompileName }} project(":{{ proj }}") |
76 {% endfor %} | 100 {% endfor %} |
77 {% for proj in android_project_deps %} | 101 {% for proj in android_project_deps %} |
78 debugCompile project(path: ":{{ proj }}", configuration: "debug") | 102 {{ depCompileName }} project(path: ":{{ proj }}", configuration: "debug") |
79 releaseCompile project(path: ":{{ proj }}", configuration: "release") | |
80 {% endfor %} | 103 {% endfor %} |
81 } | 104 } |
82 | 105 |
| 106 {% if template_type.startswith('android') %} |
| 107 android.variantFilter { variant -> |
| 108 if (variant.buildType.name.equals('release')) { |
| 109 variant.setIgnore(true); |
| 110 } |
| 111 } |
| 112 |
83 afterEvaluate { | 113 afterEvaluate { |
84 def tasksToDisable = tasks.findAll { | 114 def tasksToDisable = tasks.findAll { |
85 return (it.name.equals('generateDebugSources') // causes unwanted Andro
idManifest.java | 115 return (it.name.equals('generateDebugSources') // causes unwanted Andro
idManifest.java |
86 || it.name.equals('generateReleaseSources') | 116 || it.name.equals('generateReleaseSources') |
87 || it.name.endsWith('Assets') | 117 || it.name.endsWith('Assets') |
88 || it.name.endsWith('BuildConfig') // causes unwanted BuildConf
ig.java | 118 || it.name.endsWith('BuildConfig') // causes unwanted BuildConf
ig.java |
89 {% if not use_gradle_process_resources %} | 119 {% if not use_gradle_process_resources %} |
90 || it.name.endsWith('Resources') | 120 || it.name.endsWith('Resources') |
91 || it.name.endsWith('ResValues') | 121 || it.name.endsWith('ResValues') |
92 {% endif %} | 122 {% endif %} |
93 || it.name.endsWith('Aidl') | 123 || it.name.endsWith('Aidl') |
94 || it.name.endsWith('Renderscript') | 124 || it.name.endsWith('Renderscript') |
95 || it.name.endsWith('Shaders')) | 125 || it.name.endsWith('Shaders')) |
96 } | 126 } |
97 tasksToDisable.each { Task task -> | 127 tasksToDisable.each { Task task -> |
98 task.enabled = false | 128 task.enabled = false |
99 } | 129 } |
100 } | 130 } |
101 | 131 |
102 {% endif %} | 132 {% endif %} |
| 133 {% endif %} |
OLD | NEW |