Ian Ni-Lewis | eb640c0 | 2013-09-09 17:01:04 -0700 | [diff] [blame] | 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 | --> |
| 16 | buildscript { |
| 17 | repositories { |
Chris Banes | ce50b6b | 2014-11-25 11:13:49 +0000 | [diff] [blame] | 18 | jcenter() |
Ian Ni-Lewis | eb640c0 | 2013-09-09 17:01:04 -0700 | [diff] [blame] | 19 | } |
| 20 | |
| 21 | dependencies { |
Jan-Felix Schmakeit | b4bbf96 | 2015-08-11 12:09:32 +1000 | [diff] [blame] | 22 | classpath 'com.android.tools.build:gradle:1.2.3' |
Ian Ni-Lewis | eb640c0 | 2013-09-09 17:01:04 -0700 | [diff] [blame] | 23 | } |
| 24 | } |
| 25 | |
Renato Mangini | 24b63c5 | 2014-08-15 18:41:42 -0700 | [diff] [blame] | 26 | apply plugin: 'com.android.application' |
Ian Ni-Lewis | eb640c0 | 2013-09-09 17:01:04 -0700 | [diff] [blame] | 27 | |
Chris Banes | ce50b6b | 2014-11-25 11:13:49 +0000 | [diff] [blame] | 28 | repositories { |
| 29 | jcenter() |
Jan-Felix Schmakeit | eb3b4f3 | 2014-02-26 15:39:20 +1100 | [diff] [blame] | 30 | <#if sample.repository?has_content> |
Jan-Felix Schmakeit | eb3b4f3 | 2014-02-26 15:39:20 +1100 | [diff] [blame] | 31 | <#list sample.repository as rep> |
| 32 | ${rep} |
| 33 | </#list> |
Jan-Felix Schmakeit | eb3b4f3 | 2014-02-26 15:39:20 +1100 | [diff] [blame] | 34 | </#if> |
Trevor Johns | deaaa10 | 2015-03-11 16:18:57 -0700 | [diff] [blame] | 35 | } |
Jan-Felix Schmakeit | eb3b4f3 | 2014-02-26 15:39:20 +1100 | [diff] [blame] | 36 | |
Ian Ni-Lewis | eb640c0 | 2013-09-09 17:01:04 -0700 | [diff] [blame] | 37 | dependencies { |
Chris Banes | 6b6059a | 2014-02-07 13:57:20 +0000 | [diff] [blame] | 38 | <#if !sample.auto_add_support_lib?has_content || sample.auto_add_support_lib == "true"> |
Trevor Johns | 7fbc4e9 | 2014-10-13 12:23:15 -0700 | [diff] [blame] | 39 | <#if sample.minSdk?matches(r'^\d+$') && sample.minSdk?number < 7> |
Trevor Johns | 5d58bc4 | 2015-08-14 15:05:32 -0700 | [diff] [blame] | 40 | compile "com.android.support:support-v4:23.0.0" |
Trevor Johns | 2bea00f | 2015-08-20 09:28:56 -0700 | [diff] [blame] | 41 | compile "com.android.support:appcompat-v7:23.0.0" |
Trevor Johns | 7fbc4e9 | 2014-10-13 12:23:15 -0700 | [diff] [blame] | 42 | <#elseif sample.minSdk?matches(r'^\d+$') && sample.minSdk?number < 13> |
Trevor Johns | 5d58bc4 | 2015-08-14 15:05:32 -0700 | [diff] [blame] | 43 | compile "com.android.support:support-v4:23.0.0" |
| 44 | compile "com.android.support:gridlayout-v7:23.0.0" |
| 45 | compile "com.android.support:cardview-v7:23.0.0" |
Trevor Johns | 2bea00f | 2015-08-20 09:28:56 -0700 | [diff] [blame] | 46 | compile "com.android.support:appcompat-v7:23.0.0" |
Trevor Johns | 992484c | 2014-06-23 16:06:27 -0700 | [diff] [blame] | 47 | <#else> |
Trevor Johns | 5d58bc4 | 2015-08-14 15:05:32 -0700 | [diff] [blame] | 48 | compile "com.android.support:support-v4:23.0.0" |
| 49 | compile "com.android.support:support-v13:23.0.0" |
| 50 | compile "com.android.support:cardview-v7:23.0.0" |
Trevor Johns | 2bea00f | 2015-08-20 09:28:56 -0700 | [diff] [blame] | 51 | compile "com.android.support:appcompat-v7:23.0.0" |
Chris Banes | 6b6059a | 2014-02-07 13:57:20 +0000 | [diff] [blame] | 52 | </#if> |
Ian Ni-Lewis | eb640c0 | 2013-09-09 17:01:04 -0700 | [diff] [blame] | 53 | </#if> |
Anirudh Dewani | d525e93 | 2013-09-30 17:59:54 -0400 | [diff] [blame] | 54 | <#list sample.dependency as dep> |
Adam Koch | f903b7a | 2015-05-12 12:03:09 +1000 | [diff] [blame] | 55 | <#-- Output dependency after checking if it is a play services depdency and |
| 56 | needs the latest version number attached. --> |
| 57 | <@update_play_services_dependency dep="${dep}" /> |
Anirudh Dewani | d525e93 | 2013-09-30 17:59:54 -0400 | [diff] [blame] | 58 | </#list> |
Hak Matsuda | dc986f3 | 2014-01-30 14:53:35 -0800 | [diff] [blame] | 59 | <#list sample.dependency_external as dep> |
| 60 | compile files(${dep}) |
| 61 | </#list> |
Trevor Johns | deaaa10 | 2015-03-11 16:18:57 -0700 | [diff] [blame] | 62 | <#if sample.wearable.has_handheld_app?has_content && sample.wearable.has_handheld_app?lower_case == "true"> |
| 63 | compile ${play_services_wearable_dependency} |
| 64 | compile ${android_support_v13_dependency} |
| 65 | wearApp project(':Wearable') |
| 66 | </#if> |
Ian Ni-Lewis | eb640c0 | 2013-09-09 17:01:04 -0700 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | // The sample build uses multiple directories to |
| 70 | // keep boilerplate and common code separate from |
| 71 | // the main sample code. |
| 72 | List<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 | |
| 77 | android { |
| 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. --> |
Ian Ni-Lewis | 7516e75 | 2013-09-26 09:04:22 -0700 | [diff] [blame] | 80 | compileSdkVersion ${compile_sdk} |
Trevor Johns | 7fbc4e9 | 2014-10-13 12:23:15 -0700 | [diff] [blame] | 81 | buildToolsVersion ${build_tools_version} |
Ian Ni-Lewis | eb640c0 | 2013-09-09 17:01:04 -0700 | [diff] [blame] | 82 | |
Trevor Johns | 67fdc94 | 2014-10-14 11:45:41 -0700 | [diff] [blame] | 83 | defaultConfig { |
| 84 | minSdkVersion ${min_sdk} |
Jan-Felix Schmakeit | d8fc932 | 2015-05-27 16:55:27 +1000 | [diff] [blame] | 85 | <#if sample.targetSdkVersion?? && sample.targetSdkVersion?has_content> |
| 86 | targetSdkVersion ${sample.targetSdkVersion} |
| 87 | <#else> |
Trevor Johns | 82fbc26 | 2015-05-27 12:59:55 -0700 | [diff] [blame] | 88 | targetSdkVersion ${compile_sdk} |
Jan-Felix Schmakeit | d8fc932 | 2015-05-27 16:55:27 +1000 | [diff] [blame] | 89 | </#if> |
Trevor Johns | 67fdc94 | 2014-10-14 11:45:41 -0700 | [diff] [blame] | 90 | } |
| 91 | |
Takeshi Hagikura | 0eb4ffc | 2015-04-27 13:57:53 +0900 | [diff] [blame] | 92 | compileOptions { |
| 93 | sourceCompatibility JavaVersion.VERSION_1_7 |
| 94 | targetCompatibility JavaVersion.VERSION_1_7 |
| 95 | } |
| 96 | |
Ian Ni-Lewis | eb640c0 | 2013-09-09 17:01:04 -0700 | [diff] [blame] | 97 | sourceSets { |
| 98 | main { |
| 99 | dirs.each { dir -> |
| 100 | <#noparse> |
| 101 | java.srcDirs "src/${dir}/java" |
| 102 | res.srcDirs "src/${dir}/res" |
| 103 | </#noparse> |
| 104 | } |
| 105 | } |
Chris Banes | bb0d7db | 2014-04-04 12:49:34 +0100 | [diff] [blame] | 106 | androidTest.setRoot('tests') |
| 107 | androidTest.java.srcDirs = ['tests/src'] |
Hak Matsuda | dc986f3 | 2014-01-30 14:53:35 -0800 | [diff] [blame] | 108 | |
| 109 | <#if sample.defaultConfig?has_content> |
| 110 | defaultConfig { |
| 111 | ${sample.defaultConfig} |
| 112 | } |
| 113 | <#else> |
| 114 | </#if> |
Ian Ni-Lewis | eb640c0 | 2013-09-09 17:01:04 -0700 | [diff] [blame] | 115 | } |
Yuichi Araki | 75c2880 | 2014-07-15 09:55:50 +0900 | [diff] [blame] | 116 | |
| 117 | <#if sample.aapt?has_content> |
| 118 | aaptOptions { |
| 119 | <#list sample.aapt.noCompress as noCompress> |
| 120 | noCompress "${noCompress}" |
| 121 | </#list> |
| 122 | } |
| 123 | </#if> |
Ian Ni-Lewis | eb640c0 | 2013-09-09 17:01:04 -0700 | [diff] [blame] | 124 | } |
Trevor Johns | f2a47dc | 2013-10-30 04:54:54 -0700 | [diff] [blame] | 125 | // BEGIN_EXCLUDE |
| 126 | // Tasks below this line will be hidden from release output |
Ian Ni-Lewis | eb640c0 | 2013-09-09 17:01:04 -0700 | [diff] [blame] | 127 | |
| 128 | task preflight (dependsOn: parent.preflight) { |
| 129 | project.afterEvaluate { |
| 130 | // Inject a preflight task into each variant so we have a place to hook tasks |
| 131 | // that need to run before any of the android build tasks. |
| 132 | // |
| 133 | android.applicationVariants.each { variant -> |
| 134 | <#noparse> |
| 135 | tasks.getByPath("prepare${variant.name.capitalize()}Dependencies").dependsOn preflight |
| 136 | </#noparse> |
| 137 | } |
| 138 | } |
| 139 | } |
| 140 | |
Trevor Johns | f2a47dc | 2013-10-30 04:54:54 -0700 | [diff] [blame] | 141 | // END_EXCLUDE |