blob: 0b89e4b9aa7c02a1142f34a632a13a8872b4626f [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 {
Takeshi Hagikura0eb4ffc2015-04-27 13:57:53 +090022 classpath 'com.android.tools.build:gradle:1.1.0'
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 Johnse8872062014-12-08 15:42:33 -080040 compile "com.android.support:support-v4:21.0.2"
Trevor Johns7fbc4e92014-10-13 12:23:15 -070041 <#elseif sample.minSdk?matches(r'^\d+$') && sample.minSdk?number < 13>
Trevor Johnse8872062014-12-08 15:42:33 -080042 compile "com.android.support:support-v4:21.0.2"
43 compile "com.android.support:gridlayout-v7:21.0.2"
44 compile "com.android.support:cardview-v7:21.0.2"
Trevor Johns992484c2014-06-23 16:06:27 -070045 <#else>
Trevor Johnse8872062014-12-08 15:42:33 -080046 compile "com.android.support:support-v4:21.0.2"
47 compile "com.android.support:support-v13:21.0.2"
48 compile "com.android.support:cardview-v7:21.0.2"
Chris Banes6b6059a2014-02-07 13:57:20 +000049 </#if>
Ian Ni-Lewiseb640c02013-09-09 17:01:04 -070050</#if>
Anirudh Dewanid525e932013-09-30 17:59:54 -040051<#list sample.dependency as dep>
52 compile "${dep}"
53</#list>
Hak Matsudadc986f32014-01-30 14:53:35 -080054<#list sample.dependency_external as dep>
55 compile files(${dep})
56</#list>
Trevor Johnsdeaaa102015-03-11 16:18:57 -070057<#if sample.wearable.has_handheld_app?has_content && sample.wearable.has_handheld_app?lower_case == "true">
58 compile ${play_services_wearable_dependency}
59 compile ${android_support_v13_dependency}
60 wearApp project(':Wearable')
61</#if>
Ian Ni-Lewiseb640c02013-09-09 17:01:04 -070062}
63
64// The sample build uses multiple directories to
65// keep boilerplate and common code separate from
66// the main sample code.
67List<String> dirs = [
68 'main', // main sample code; look here for the interesting stuff.
69 'common', // components that are reused by multiple samples
70 'template'] // boilerplate code that is generated by the sample template process
71
72android {
73 <#-- Note that target SDK is hardcoded in this template. We expect all samples
74 to always use the most current SDK as their target. -->
Ian Ni-Lewis7516e752013-09-26 09:04:22 -070075 compileSdkVersion ${compile_sdk}
Trevor Johns7fbc4e92014-10-13 12:23:15 -070076 buildToolsVersion ${build_tools_version}
Ian Ni-Lewiseb640c02013-09-09 17:01:04 -070077
Trevor Johns67fdc942014-10-14 11:45:41 -070078 defaultConfig {
79 minSdkVersion ${min_sdk}
80 targetSdkVersion ${compile_sdk}
81 }
82
Takeshi Hagikura0eb4ffc2015-04-27 13:57:53 +090083 compileOptions {
84 sourceCompatibility JavaVersion.VERSION_1_7
85 targetCompatibility JavaVersion.VERSION_1_7
86 }
87
Ian Ni-Lewiseb640c02013-09-09 17:01:04 -070088 sourceSets {
89 main {
90 dirs.each { dir ->
91<#noparse>
92 java.srcDirs "src/${dir}/java"
93 res.srcDirs "src/${dir}/res"
94</#noparse>
95 }
96 }
Chris Banesbb0d7db2014-04-04 12:49:34 +010097 androidTest.setRoot('tests')
98 androidTest.java.srcDirs = ['tests/src']
Hak Matsudadc986f32014-01-30 14:53:35 -080099
100<#if sample.defaultConfig?has_content>
101 defaultConfig {
102 ${sample.defaultConfig}
103 }
104<#else>
105</#if>
Ian Ni-Lewiseb640c02013-09-09 17:01:04 -0700106 }
Yuichi Araki75c28802014-07-15 09:55:50 +0900107
108<#if sample.aapt?has_content>
109 aaptOptions {
110 <#list sample.aapt.noCompress as noCompress>
111 noCompress "${noCompress}"
112 </#list>
113 }
114</#if>
Ian Ni-Lewiseb640c02013-09-09 17:01:04 -0700115}
Trevor Johnsf2a47dc2013-10-30 04:54:54 -0700116// BEGIN_EXCLUDE
117// Tasks below this line will be hidden from release output
Ian Ni-Lewiseb640c02013-09-09 17:01:04 -0700118
119task preflight (dependsOn: parent.preflight) {
120 project.afterEvaluate {
121 // Inject a preflight task into each variant so we have a place to hook tasks
122 // that need to run before any of the android build tasks.
123 //
124 android.applicationVariants.each { variant ->
125 <#noparse>
126 tasks.getByPath("prepare${variant.name.capitalize()}Dependencies").dependsOn preflight
127 </#noparse>
128 }
129 }
130}
131
Trevor Johnsf2a47dc2013-10-30 04:54:54 -0700132// END_EXCLUDE