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 44 <#if !sample.auto_add_support_lib?has_content || sample.auto_add_support_lib == "true"> 45 <#if sample.minSdk?matches(r'^\d+$') && sample.minSdk?number < 7> 46 implementation "com.android.support:support-v4:28.0.0" 47 implementation "com.android.support:appcompat-v7:28.0.0" 48 <#elseif sample.minSdk?matches(r'^\d+$') && sample.minSdk?number < 13> 49 implementation "com.android.support:support-v4:28.0.0" 50 implementation "com.android.support:gridlayout-v7:28.0.0" 51 implementation "com.android.support:cardview-v7:28.0.0" 52 implementation "com.android.support:appcompat-v7:28.0.0" 53 <#else> 54 implementation "com.android.support:support-v4:28.0.0" 55 implementation "com.android.support:support-v13:28.0.0" 56 implementation "com.android.support:cardview-v7:28.0.0" 57 implementation "com.android.support:appcompat-v7:28.0.0" 58 </#if> 59 </#if> 60 61 </#if> 62 63<#list sample.dependency as dep> 64 <#-- Output dependency after checking if it is a play services depdency and 65 needs the latest version number attached. --> 66 <@update_play_services_dependency dep="${dep}" /> 67</#list> 68 69<#list sample.dependency_external as dep> 70 implementation files(${dep}) 71</#list> 72 73<#list sample.annotationProcessor as ap> 74 annotationProcessor "${ap}" 75</#list> 76 77<#if sample.wearable.has_handheld_app?has_content && sample.wearable.has_handheld_app?lower_case == "true"> 78 implementation ${play_services_wearable_dependency} 79 80 <#-- TODO (jewalker): Revise once androidX is released to production. --> 81 <#if !sample.androidX?? || !sample.androidX?has_content || sample.androidX == "false"> 82 implementation ${android_support_v13_dependency} 83 </#if> 84 85 wearApp project(':Wearable') 86</#if> 87 88} 89 90// The sample build uses multiple directories to 91// keep boilerplate and common code separate from 92// the main sample code. 93List<String> dirs = [ 94 'main', // main sample code; look here for the interesting stuff. 95 'common', // components that are reused by multiple samples 96 'template'] // boilerplate code that is generated by the sample template process 97 98android { 99 <#-- Note that target SDK is hardcoded in this template. We expect all samples 100 to always use the most current SDK as their target. --> 101 <#if sample.compileSdkVersion?? && sample.compileSdkVersion?has_content> 102 compileSdkVersion ${sample.compileSdkVersion} 103 <#else> 104 compileSdkVersion ${compile_sdk} 105 </#if> 106 107 defaultConfig { 108 minSdkVersion ${min_sdk} 109 <#if sample.targetSdkVersion?? && sample.targetSdkVersion?has_content> 110 targetSdkVersion ${sample.targetSdkVersion} 111 <#else> 112 targetSdkVersion ${compile_sdk} 113 </#if> 114<#if sample.defaultConfig?has_content> 115 ${sample.defaultConfig} 116<#else> 117 } 118 119 compileOptions { 120 sourceCompatibility JavaVersion.VERSION_1_7 121 targetCompatibility JavaVersion.VERSION_1_7 122 } 123 124 sourceSets { 125 main { 126 dirs.each { dir -> 127<#noparse> 128 java.srcDirs "src/${dir}/java" 129 res.srcDirs "src/${dir}/res" 130</#noparse> 131 } 132 } 133 androidTest.setRoot('tests') 134 androidTest.java.srcDirs = ['tests/src'] 135 136</#if> 137 } 138 139<#if sample.aapt?has_content> 140 aaptOptions { 141 <#list sample.aapt.noCompress as noCompress> 142 noCompress "${noCompress}" 143 </#list> 144 } 145</#if> 146} 147