blob: 617861a8fc20a2333fc9a8b8e9f3a9ee537ca7f7 [file] [log] [blame]
Ian Ni-Lewiseb640c02013-09-09 17:01:04 -07001<#--
2 Copyright 2013 The Android Open Source Project
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15-->
16buildscript {
17 repositories {
Chris Banesce50b6b2014-11-25 11:13:49 +000018 jcenter()
Ian Ni-Lewiseb640c02013-09-09 17:01:04 -070019 }
20
21 dependencies {
Jan-Felix Schmakeitb4bbf962015-08-11 12:09:32 +100022 classpath 'com.android.tools.build:gradle:1.2.3'
Ian Ni-Lewiseb640c02013-09-09 17:01:04 -070023 }
24}
25
Renato Mangini24b63c52014-08-15 18:41:42 -070026apply plugin: 'com.android.application'
Ian Ni-Lewiseb640c02013-09-09 17:01:04 -070027
Chris Banesce50b6b2014-11-25 11:13:49 +000028repositories {
29 jcenter()
Jan-Felix Schmakeiteb3b4f32014-02-26 15:39:20 +110030<#if sample.repository?has_content>
Jan-Felix Schmakeiteb3b4f32014-02-26 15:39:20 +110031<#list sample.repository as rep>
32 ${rep}
33</#list>
Jan-Felix Schmakeiteb3b4f32014-02-26 15:39:20 +110034</#if>
Trevor Johnsdeaaa102015-03-11 16:18:57 -070035}
Jan-Felix Schmakeiteb3b4f32014-02-26 15:39:20 +110036
Ian Ni-Lewiseb640c02013-09-09 17:01:04 -070037dependencies {
Chris Banes6b6059a2014-02-07 13:57:20 +000038<#if !sample.auto_add_support_lib?has_content || sample.auto_add_support_lib == "true">
Trevor Johns7fbc4e92014-10-13 12:23:15 -070039 <#if sample.minSdk?matches(r'^\d+$') && sample.minSdk?number < 7>
Trevor Johns5d58bc42015-08-14 15:05:32 -070040 compile "com.android.support:support-v4:23.0.0"
Trevor Johns2bea00f2015-08-20 09:28:56 -070041 compile "com.android.support:appcompat-v7:23.0.0"
Trevor Johns7fbc4e92014-10-13 12:23:15 -070042 <#elseif sample.minSdk?matches(r'^\d+$') && sample.minSdk?number < 13>
Trevor Johns5d58bc42015-08-14 15:05:32 -070043 compile "com.android.support:support-v4:23.0.0"
44 compile "com.android.support:gridlayout-v7:23.0.0"
45 compile "com.android.support:cardview-v7:23.0.0"
Trevor Johns2bea00f2015-08-20 09:28:56 -070046 compile "com.android.support:appcompat-v7:23.0.0"
Trevor Johns992484c2014-06-23 16:06:27 -070047 <#else>
Trevor Johns5d58bc42015-08-14 15:05:32 -070048 compile "com.android.support:support-v4:23.0.0"
49 compile "com.android.support:support-v13:23.0.0"
50 compile "com.android.support:cardview-v7:23.0.0"
Trevor Johns2bea00f2015-08-20 09:28:56 -070051 compile "com.android.support:appcompat-v7:23.0.0"
Chris Banes6b6059a2014-02-07 13:57:20 +000052 </#if>
Ian Ni-Lewiseb640c02013-09-09 17:01:04 -070053</#if>
Anirudh Dewanid525e932013-09-30 17:59:54 -040054<#list sample.dependency as dep>
Adam Kochf903b7a2015-05-12 12:03:09 +100055 <#-- Output dependency after checking if it is a play services depdency and
56 needs the latest version number attached. -->
57 <@update_play_services_dependency dep="${dep}" />
Anirudh Dewanid525e932013-09-30 17:59:54 -040058</#list>
Hak Matsudadc986f32014-01-30 14:53:35 -080059<#list sample.dependency_external as dep>
60 compile files(${dep})
61</#list>
Trevor Johnsdeaaa102015-03-11 16:18:57 -070062<#if sample.wearable.has_handheld_app?has_content && sample.wearable.has_handheld_app?lower_case == "true">
63 compile ${play_services_wearable_dependency}
64 compile ${android_support_v13_dependency}
65 wearApp project(':Wearable')
66</#if>
Ian Ni-Lewiseb640c02013-09-09 17:01:04 -070067}
68
69// The sample build uses multiple directories to
70// keep boilerplate and common code separate from
71// the main sample code.
72List<String> dirs = [
73 'main', // main sample code; look here for the interesting stuff.
74 'common', // components that are reused by multiple samples
75 'template'] // boilerplate code that is generated by the sample template process
76
77android {
78 <#-- Note that target SDK is hardcoded in this template. We expect all samples
79 to always use the most current SDK as their target. -->
Ian Ni-Lewis7516e752013-09-26 09:04:22 -070080 compileSdkVersion ${compile_sdk}
Trevor Johns7fbc4e92014-10-13 12:23:15 -070081 buildToolsVersion ${build_tools_version}
Ian Ni-Lewiseb640c02013-09-09 17:01:04 -070082
Trevor Johns67fdc942014-10-14 11:45:41 -070083 defaultConfig {
84 minSdkVersion ${min_sdk}
Jan-Felix Schmakeitd8fc9322015-05-27 16:55:27 +100085 <#if sample.targetSdkVersion?? && sample.targetSdkVersion?has_content>
86 targetSdkVersion ${sample.targetSdkVersion}
87 <#else>
Trevor Johns82fbc262015-05-27 12:59:55 -070088 targetSdkVersion ${compile_sdk}
Jan-Felix Schmakeitd8fc9322015-05-27 16:55:27 +100089 </#if>
Trevor Johns67fdc942014-10-14 11:45:41 -070090 }
91
Takeshi Hagikura0eb4ffc2015-04-27 13:57:53 +090092 compileOptions {
93 sourceCompatibility JavaVersion.VERSION_1_7
94 targetCompatibility JavaVersion.VERSION_1_7
95 }
96
Ian Ni-Lewiseb640c02013-09-09 17:01:04 -070097 sourceSets {
98 main {
99 dirs.each { dir ->
100<#noparse>
101 java.srcDirs "src/${dir}/java"
102 res.srcDirs "src/${dir}/res"
103</#noparse>
104 }
105 }
Chris Banesbb0d7db2014-04-04 12:49:34 +0100106 androidTest.setRoot('tests')
107 androidTest.java.srcDirs = ['tests/src']
Hak Matsudadc986f32014-01-30 14:53:35 -0800108
109<#if sample.defaultConfig?has_content>
110 defaultConfig {
111 ${sample.defaultConfig}
112 }
113<#else>
114</#if>
Ian Ni-Lewiseb640c02013-09-09 17:01:04 -0700115 }
Yuichi Araki75c28802014-07-15 09:55:50 +0900116
117<#if sample.aapt?has_content>
118 aaptOptions {
119 <#list sample.aapt.noCompress as noCompress>
120 noCompress "${noCompress}"
121 </#list>
122 }
123</#if>
Ian Ni-Lewiseb640c02013-09-09 17:01:04 -0700124}
Trevor Johnsf2a47dc2013-10-30 04:54:54 -0700125// BEGIN_EXCLUDE
126// Tasks below this line will be hidden from release output
Ian Ni-Lewiseb640c02013-09-09 17:01:04 -0700127
128task preflight (dependsOn: parent.preflight) {
129 project.afterEvaluate {
130 // Inject a preflight task into each variant so we have a place to hook tasks
131 // that need to run before any of the android build tasks.
132 //
133 android.applicationVariants.each { variant ->
134 <#noparse>
135 tasks.getByPath("prepare${variant.name.capitalize()}Dependencies").dependsOn preflight
136 </#noparse>
137 }
138 }
139}
140
Trevor Johnsf2a47dc2013-10-30 04:54:54 -0700141// END_EXCLUDE