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