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 { |
Takeshi Hagikura | 0eb4ffc | 2015-04-27 13:57:53 +0900 | [diff] [blame^] | 22 | classpath 'com.android.tools.build:gradle:1.1.0' |
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 | e887206 | 2014-12-08 15:42:33 -0800 | [diff] [blame] | 40 | compile "com.android.support:support-v4:21.0.2" |
Trevor Johns | 7fbc4e9 | 2014-10-13 12:23:15 -0700 | [diff] [blame] | 41 | <#elseif sample.minSdk?matches(r'^\d+$') && sample.minSdk?number < 13> |
Trevor Johns | e887206 | 2014-12-08 15:42:33 -0800 | [diff] [blame] | 42 | compile "com.android.support:support-v4:21.0.2" |
| 43 | compile "com.android.support:gridlayout-v7:21.0.2" |
| 44 | compile "com.android.support:cardview-v7:21.0.2" |
Trevor Johns | 992484c | 2014-06-23 16:06:27 -0700 | [diff] [blame] | 45 | <#else> |
Trevor Johns | e887206 | 2014-12-08 15:42:33 -0800 | [diff] [blame] | 46 | compile "com.android.support:support-v4:21.0.2" |
| 47 | compile "com.android.support:support-v13:21.0.2" |
| 48 | compile "com.android.support:cardview-v7:21.0.2" |
Chris Banes | 6b6059a | 2014-02-07 13:57:20 +0000 | [diff] [blame] | 49 | </#if> |
Ian Ni-Lewis | eb640c0 | 2013-09-09 17:01:04 -0700 | [diff] [blame] | 50 | </#if> |
Anirudh Dewani | d525e93 | 2013-09-30 17:59:54 -0400 | [diff] [blame] | 51 | <#list sample.dependency as dep> |
| 52 | compile "${dep}" |
| 53 | </#list> |
Hak Matsuda | dc986f3 | 2014-01-30 14:53:35 -0800 | [diff] [blame] | 54 | <#list sample.dependency_external as dep> |
| 55 | compile files(${dep}) |
| 56 | </#list> |
Trevor Johns | deaaa10 | 2015-03-11 16:18:57 -0700 | [diff] [blame] | 57 | <#if sample.wearable.has_handheld_app?has_content && sample.wearable.has_handheld_app?lower_case == "true"> |
| 58 | compile ${play_services_wearable_dependency} |
| 59 | compile ${android_support_v13_dependency} |
| 60 | wearApp project(':Wearable') |
| 61 | </#if> |
Ian Ni-Lewis | eb640c0 | 2013-09-09 17:01:04 -0700 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | // The sample build uses multiple directories to |
| 65 | // keep boilerplate and common code separate from |
| 66 | // the main sample code. |
| 67 | List<String> dirs = [ |
| 68 | 'main', // main sample code; look here for the interesting stuff. |
| 69 | 'common', // components that are reused by multiple samples |
| 70 | 'template'] // boilerplate code that is generated by the sample template process |
| 71 | |
| 72 | android { |
| 73 | <#-- Note that target SDK is hardcoded in this template. We expect all samples |
| 74 | to always use the most current SDK as their target. --> |
Ian Ni-Lewis | 7516e75 | 2013-09-26 09:04:22 -0700 | [diff] [blame] | 75 | compileSdkVersion ${compile_sdk} |
Trevor Johns | 7fbc4e9 | 2014-10-13 12:23:15 -0700 | [diff] [blame] | 76 | buildToolsVersion ${build_tools_version} |
Ian Ni-Lewis | eb640c0 | 2013-09-09 17:01:04 -0700 | [diff] [blame] | 77 | |
Trevor Johns | 67fdc94 | 2014-10-14 11:45:41 -0700 | [diff] [blame] | 78 | defaultConfig { |
| 79 | minSdkVersion ${min_sdk} |
| 80 | targetSdkVersion ${compile_sdk} |
| 81 | } |
| 82 | |
Takeshi Hagikura | 0eb4ffc | 2015-04-27 13:57:53 +0900 | [diff] [blame^] | 83 | compileOptions { |
| 84 | sourceCompatibility JavaVersion.VERSION_1_7 |
| 85 | targetCompatibility JavaVersion.VERSION_1_7 |
| 86 | } |
| 87 | |
Ian Ni-Lewis | eb640c0 | 2013-09-09 17:01:04 -0700 | [diff] [blame] | 88 | sourceSets { |
| 89 | main { |
| 90 | dirs.each { dir -> |
| 91 | <#noparse> |
| 92 | java.srcDirs "src/${dir}/java" |
| 93 | res.srcDirs "src/${dir}/res" |
| 94 | </#noparse> |
| 95 | } |
| 96 | } |
Chris Banes | bb0d7db | 2014-04-04 12:49:34 +0100 | [diff] [blame] | 97 | androidTest.setRoot('tests') |
| 98 | androidTest.java.srcDirs = ['tests/src'] |
Hak Matsuda | dc986f3 | 2014-01-30 14:53:35 -0800 | [diff] [blame] | 99 | |
| 100 | <#if sample.defaultConfig?has_content> |
| 101 | defaultConfig { |
| 102 | ${sample.defaultConfig} |
| 103 | } |
| 104 | <#else> |
| 105 | </#if> |
Ian Ni-Lewis | eb640c0 | 2013-09-09 17:01:04 -0700 | [diff] [blame] | 106 | } |
Yuichi Araki | 75c2880 | 2014-07-15 09:55:50 +0900 | [diff] [blame] | 107 | |
| 108 | <#if sample.aapt?has_content> |
| 109 | aaptOptions { |
| 110 | <#list sample.aapt.noCompress as noCompress> |
| 111 | noCompress "${noCompress}" |
| 112 | </#list> |
| 113 | } |
| 114 | </#if> |
Ian Ni-Lewis | eb640c0 | 2013-09-09 17:01:04 -0700 | [diff] [blame] | 115 | } |
Trevor Johns | f2a47dc | 2013-10-30 04:54:54 -0700 | [diff] [blame] | 116 | // BEGIN_EXCLUDE |
| 117 | // Tasks below this line will be hidden from release output |
Ian Ni-Lewis | eb640c0 | 2013-09-09 17:01:04 -0700 | [diff] [blame] | 118 | |
| 119 | task preflight (dependsOn: parent.preflight) { |
| 120 | project.afterEvaluate { |
| 121 | // Inject a preflight task into each variant so we have a place to hook tasks |
| 122 | // that need to run before any of the android build tasks. |
| 123 | // |
| 124 | android.applicationVariants.each { variant -> |
| 125 | <#noparse> |
| 126 | tasks.getByPath("prepare${variant.name.capitalize()}Dependencies").dependsOn preflight |
| 127 | </#noparse> |
| 128 | } |
| 129 | } |
| 130 | } |
| 131 | |
Trevor Johns | f2a47dc | 2013-10-30 04:54:54 -0700 | [diff] [blame] | 132 | // END_EXCLUDE |