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        google()
19        jcenter()
20    }
21
22    dependencies {
23        classpath 'com.android.tools.build:gradle:3.4.2'
24    }
25}
26
27apply plugin: 'com.android.application'
28
29repositories {
30    google()
31    jcenter()
32<#if sample.repository?has_content>
33    <#list sample.repository as rep>
34    ${rep}
35    </#list>
36</#if>
37}
38
39dependencies {
40
41  <#-- TODO (jewalker): Revise once androidX is released to production. -->
42  <#if !sample.androidX?? || !sample.androidX?has_content || sample.androidX == "false">
43    <#if !sample.auto_add_support_lib?has_content || sample.auto_add_support_lib == "true">
44      <#if sample.minSdk?matches(r'^\d+$') && sample.minSdk?number < 7>
45    implementation "com.android.support:support-v4:28.0.0"
46      <#elseif sample.minSdk?matches(r'^\d+$') && sample.minSdk?number < 13>
47    implementation "com.android.support:support-v4:28.0.0"
48    implementation "com.android.support:gridlayout-v7:28.0.0"
49    implementation "com.android.support:cardview-v7:28.0.0"
50      <#else>
51    implementation "com.android.support:support-v4:28.0.0"
52    implementation "com.android.support:support-v13:28.0.0"
53    implementation "com.android.support:cardview-v7:28.0.0"
54      </#if>
55    </#if>
56  </#if>
57
58<#list sample.dependency as dep>
59    <#-- Output dependency after checking if it is a play services depdency and
60    needs the latest version number attached. -->
61    <@update_play_services_dependency dep="${dep}" />
62</#list>
63
64<#list sample.dependency_external as dep>
65    implementation files(${dep})
66</#list>
67}
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. -->
80 <#if sample.compileSdkVersion?? && sample.compileSdkVersion?has_content>
81    compileSdkVersion ${sample.compileSdkVersion}
82  <#else>
83    compileSdkVersion ${compile_sdk}
84  </#if>
85
86    buildToolsVersion ${build_tools_version}
87
88    defaultConfig {
89        minSdkVersion ${min_sdk}
90        targetSdkVersion ${compile_sdk}
91
92<#if sample.use_support_library_vector_drawables?has_content && sample.use_support_library_vector_drawables == "true">
93        vectorDrawables.useSupportLibrary = true
94</#if>
95    }
96
97    compileOptions {
98        sourceCompatibility JavaVersion.VERSION_1_7
99        targetCompatibility JavaVersion.VERSION_1_7
100    }
101
102    sourceSets {
103        main {
104            dirs.each { dir ->
105<#noparse>
106                java.srcDirs "src/${dir}/java"
107                res.srcDirs "src/${dir}/res"
108</#noparse>
109            }
110        }
111        androidTest.setRoot('tests')
112        androidTest.java.srcDirs = ['tests/src']
113
114<#if sample.defaultConfig?has_content>
115        defaultConfig {
116        ${sample.defaultConfig}
117        }
118<#else>
119</#if>
120    }
121
122<#if sample.aapt?has_content>
123    aaptOptions {
124    <#list sample.aapt.noCompress as noCompress>
125        noCompress "${noCompress}"
126    </#list>
127    }
128</#if>
129}
130