blob: 3eb366125cc28b0bc0c0870ddc4815594bed5a73 [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 {
18 mavenCentral()
19 }
20
21 dependencies {
Chris Banesbb0d7db2014-04-04 12:49:34 +010022 classpath 'com.android.tools.build:gradle:0.9.+'
Ian Ni-Lewiseb640c02013-09-09 17:01:04 -070023 }
24}
25
26apply plugin: 'android'
27
Jan-Felix Schmakeiteb3b4f32014-02-26 15:39:20 +110028<#if sample.repository?has_content>
29repositories {
30<#list sample.repository as rep>
31 ${rep}
32</#list>
33}
34</#if>
35
Ian Ni-Lewiseb640c02013-09-09 17:01:04 -070036dependencies {
Jan-Felix Schmakeitd6c24852014-01-29 15:04:52 +110037
Chris Banes6b6059a2014-02-07 13:57:20 +000038<#if !sample.auto_add_support_lib?has_content || sample.auto_add_support_lib == "true">
Ian Ni-Lewiseb640c02013-09-09 17:01:04 -070039 // Add the support lib that is appropriate for SDK ${sample.minSdk}
Chris Banes6b6059a2014-02-07 13:57:20 +000040 <#if sample.minSdk?number < 7>
Chris Banesf0478aa2014-04-03 10:45:34 +010041 compile "com.android.support:support-v4:19.1.+"
Chris Banes6b6059a2014-02-07 13:57:20 +000042 <#elseif sample.minSdk?number < 13>
Chris Banesf0478aa2014-04-03 10:45:34 +010043 compile "com.android.support:support-v4:19.1.+"
44 compile "com.android.support:gridlayout-v7:19.1.+"
Chris Banes6b6059a2014-02-07 13:57:20 +000045 <#else>
Chris Banesf0478aa2014-04-03 10:45:34 +010046 compile "com.android.support:support-v13:19.1.+"
Chris Banes6b6059a2014-02-07 13:57:20 +000047 </#if>
Jan-Felix Schmakeitd6c24852014-01-29 15:04:52 +110048
Ian Ni-Lewiseb640c02013-09-09 17:01:04 -070049</#if>
Chris Banes6b6059a2014-02-07 13:57:20 +000050
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>
Ian Ni-Lewiseb640c02013-09-09 17:01:04 -070057}
58
59// The sample build uses multiple directories to
60// keep boilerplate and common code separate from
61// the main sample code.
62List<String> dirs = [
63 'main', // main sample code; look here for the interesting stuff.
64 'common', // components that are reused by multiple samples
65 'template'] // boilerplate code that is generated by the sample template process
66
67android {
68 <#-- Note that target SDK is hardcoded in this template. We expect all samples
69 to always use the most current SDK as their target. -->
Ian Ni-Lewis7516e752013-09-26 09:04:22 -070070 compileSdkVersion ${compile_sdk}
Jan-Felix Schmakeitd6c24852014-01-29 15:04:52 +110071
Jan-Felix Schmakeited3e7302014-01-29 15:04:52 +110072 buildToolsVersion "19.0.1"
Ian Ni-Lewiseb640c02013-09-09 17:01:04 -070073
Ian Ni-Lewiseb640c02013-09-09 17:01:04 -070074 sourceSets {
75 main {
76 dirs.each { dir ->
77<#noparse>
78 java.srcDirs "src/${dir}/java"
79 res.srcDirs "src/${dir}/res"
80</#noparse>
81 }
82 }
Chris Banesbb0d7db2014-04-04 12:49:34 +010083 androidTest.setRoot('tests')
84 androidTest.java.srcDirs = ['tests/src']
Hak Matsudadc986f32014-01-30 14:53:35 -080085
86<#if sample.defaultConfig?has_content>
87 defaultConfig {
88 ${sample.defaultConfig}
89 }
90<#else>
91</#if>
Ian Ni-Lewiseb640c02013-09-09 17:01:04 -070092 }
Ian Ni-Lewiseb640c02013-09-09 17:01:04 -070093}
Trevor Johnsf2a47dc2013-10-30 04:54:54 -070094// BEGIN_EXCLUDE
95// Tasks below this line will be hidden from release output
Ian Ni-Lewiseb640c02013-09-09 17:01:04 -070096
97task preflight (dependsOn: parent.preflight) {
98 project.afterEvaluate {
99 // Inject a preflight task into each variant so we have a place to hook tasks
100 // that need to run before any of the android build tasks.
101 //
102 android.applicationVariants.each { variant ->
103 <#noparse>
104 tasks.getByPath("prepare${variant.name.capitalize()}Dependencies").dependsOn preflight
105 </#noparse>
106 }
107 }
108}
109
Trevor Johnsf2a47dc2013-10-30 04:54:54 -0700110// END_EXCLUDE