1<#--
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        jcenter()
19    }
20
21    dependencies {
22        classpath 'com.android.tools.build:gradle:2.1.2'
23    }
24}
25
26apply plugin: 'com.android.application'
27
28<#if sample.repository?has_content>
29repositories {
30<#list sample.repository as rep>
31    ${rep}
32</#list>
33}
34</#if>
35
36dependencies {
37
38<#if !sample.auto_add_support_lib?has_content || sample.auto_add_support_lib == "true">
39  <#if sample.minSdk?matches(r'^\d+$') && sample.minSdk?number < 7>
40    compile "com.android.support:support-v4:24.0.0-beta1"
41  <#elseif sample.minSdk?matches(r'^\d+$') && sample.minSdk?number < 13>
42    compile "com.android.support:support-v4:24.0.0-beta1"
43    compile "com.android.support:gridlayout-v7:24.0.0-beta1"
44    compile "com.android.support:cardview-v7:24.0.0-beta1"
45  <#else>
46    compile "com.android.support:support-v4:24.0.0-beta1"
47    compile "com.android.support:support-v13:24.0.0-beta1"
48    compile "com.android.support:cardview-v7:24.0.0-beta1"
49  </#if>
50</#if>
51
52<#list sample.dependency as dep>
53    <#-- Output dependency after checking if it is a play services depdency and
54    needs the latest version number attached. -->
55    <@update_play_services_dependency dep="${dep}" />
56</#list>
57<#list sample.dependency_external as dep>
58    compile files(${dep})
59</#list>
60}
61
62// The sample build uses multiple directories to
63// keep boilerplate and common code separate from
64// the main sample code.
65List<String> dirs = [
66    'main',     // main sample code; look here for the interesting stuff.
67    'common',   // components that are reused by multiple samples
68    'template'] // boilerplate code that is generated by the sample template process
69
70android {
71     <#-- Note that target SDK is hardcoded in this template. We expect all samples
72          to always use the most current SDK as their target. -->
73    compileSdkVersion ${compile_sdk}
74    buildToolsVersion ${build_tools_version}
75
76    defaultConfig {
77        minSdkVersion ${min_sdk}
78        targetSdkVersion ${compile_sdk}
79    }
80
81    compileOptions {
82        sourceCompatibility JavaVersion.VERSION_1_7
83        targetCompatibility JavaVersion.VERSION_1_7
84    }
85
86    sourceSets {
87        main {
88            dirs.each { dir ->
89<#noparse>
90                java.srcDirs "src/${dir}/java"
91                res.srcDirs "src/${dir}/res"
92</#noparse>
93            }
94        }
95        androidTest.setRoot('tests')
96        androidTest.java.srcDirs = ['tests/src']
97
98<#if sample.defaultConfig?has_content>
99        defaultConfig {
100        ${sample.defaultConfig}
101        }
102<#else>
103</#if>
104    }
105
106<#if sample.aapt?has_content>
107    aaptOptions {
108    <#list sample.aapt.noCompress as noCompress>
109        noCompress "${noCompress}"
110    </#list>
111    }
112</#if>
113}
114