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 { |
| 18 | mavenCentral() |
| 19 | } |
| 20 | |
| 21 | dependencies { |
Chris Banes | bb0d7db | 2014-04-04 12:49:34 +0100 | [diff] [blame^] | 22 | classpath 'com.android.tools.build:gradle:0.9.+' |
Ian Ni-Lewis | eb640c0 | 2013-09-09 17:01:04 -0700 | [diff] [blame] | 23 | } |
| 24 | } |
| 25 | |
| 26 | apply plugin: 'android' |
| 27 | |
Jan-Felix Schmakeit | eb3b4f3 | 2014-02-26 15:39:20 +1100 | [diff] [blame] | 28 | <#if sample.repository?has_content> |
| 29 | repositories { |
| 30 | <#list sample.repository as rep> |
| 31 | ${rep} |
| 32 | </#list> |
| 33 | } |
| 34 | </#if> |
| 35 | |
Ian Ni-Lewis | eb640c0 | 2013-09-09 17:01:04 -0700 | [diff] [blame] | 36 | dependencies { |
Jan-Felix Schmakeit | d6c2485 | 2014-01-29 15:04:52 +1100 | [diff] [blame] | 37 | |
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"> |
Ian Ni-Lewis | eb640c0 | 2013-09-09 17:01:04 -0700 | [diff] [blame] | 39 | // Add the support lib that is appropriate for SDK ${sample.minSdk} |
Chris Banes | 6b6059a | 2014-02-07 13:57:20 +0000 | [diff] [blame] | 40 | <#if sample.minSdk?number < 7> |
Chris Banes | f0478aa | 2014-04-03 10:45:34 +0100 | [diff] [blame] | 41 | compile "com.android.support:support-v4:19.1.+" |
Chris Banes | 6b6059a | 2014-02-07 13:57:20 +0000 | [diff] [blame] | 42 | <#elseif sample.minSdk?number < 13> |
Chris Banes | f0478aa | 2014-04-03 10:45:34 +0100 | [diff] [blame] | 43 | compile "com.android.support:support-v4:19.1.+" |
| 44 | compile "com.android.support:gridlayout-v7:19.1.+" |
Chris Banes | 6b6059a | 2014-02-07 13:57:20 +0000 | [diff] [blame] | 45 | <#else> |
Chris Banes | f0478aa | 2014-04-03 10:45:34 +0100 | [diff] [blame] | 46 | compile "com.android.support:support-v13:19.1.+" |
Chris Banes | 6b6059a | 2014-02-07 13:57:20 +0000 | [diff] [blame] | 47 | </#if> |
Jan-Felix Schmakeit | d6c2485 | 2014-01-29 15:04:52 +1100 | [diff] [blame] | 48 | |
Ian Ni-Lewis | eb640c0 | 2013-09-09 17:01:04 -0700 | [diff] [blame] | 49 | </#if> |
Chris Banes | 6b6059a | 2014-02-07 13:57:20 +0000 | [diff] [blame] | 50 | |
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> |
Ian Ni-Lewis | eb640c0 | 2013-09-09 17:01:04 -0700 | [diff] [blame] | 57 | } |
| 58 | |
| 59 | // The sample build uses multiple directories to |
| 60 | // keep boilerplate and common code separate from |
| 61 | // the main sample code. |
| 62 | List<String> dirs = [ |
| 63 | 'main', // main sample code; look here for the interesting stuff. |
| 64 | 'common', // components that are reused by multiple samples |
| 65 | 'template'] // boilerplate code that is generated by the sample template process |
| 66 | |
| 67 | android { |
| 68 | <#-- Note that target SDK is hardcoded in this template. We expect all samples |
| 69 | to always use the most current SDK as their target. --> |
Ian Ni-Lewis | 7516e75 | 2013-09-26 09:04:22 -0700 | [diff] [blame] | 70 | compileSdkVersion ${compile_sdk} |
Jan-Felix Schmakeit | d6c2485 | 2014-01-29 15:04:52 +1100 | [diff] [blame] | 71 | |
Jan-Felix Schmakeit | ed3e730 | 2014-01-29 15:04:52 +1100 | [diff] [blame] | 72 | buildToolsVersion "19.0.1" |
Ian Ni-Lewis | eb640c0 | 2013-09-09 17:01:04 -0700 | [diff] [blame] | 73 | |
Ian Ni-Lewis | eb640c0 | 2013-09-09 17:01:04 -0700 | [diff] [blame] | 74 | sourceSets { |
| 75 | main { |
| 76 | dirs.each { dir -> |
| 77 | <#noparse> |
| 78 | java.srcDirs "src/${dir}/java" |
| 79 | res.srcDirs "src/${dir}/res" |
| 80 | </#noparse> |
| 81 | } |
| 82 | } |
Chris Banes | bb0d7db | 2014-04-04 12:49:34 +0100 | [diff] [blame^] | 83 | androidTest.setRoot('tests') |
| 84 | androidTest.java.srcDirs = ['tests/src'] |
Hak Matsuda | dc986f3 | 2014-01-30 14:53:35 -0800 | [diff] [blame] | 85 | |
| 86 | <#if sample.defaultConfig?has_content> |
| 87 | defaultConfig { |
| 88 | ${sample.defaultConfig} |
| 89 | } |
| 90 | <#else> |
| 91 | </#if> |
Ian Ni-Lewis | eb640c0 | 2013-09-09 17:01:04 -0700 | [diff] [blame] | 92 | } |
Ian Ni-Lewis | eb640c0 | 2013-09-09 17:01:04 -0700 | [diff] [blame] | 93 | } |
Trevor Johns | f2a47dc | 2013-10-30 04:54:54 -0700 | [diff] [blame] | 94 | // BEGIN_EXCLUDE |
| 95 | // Tasks below this line will be hidden from release output |
Ian Ni-Lewis | eb640c0 | 2013-09-09 17:01:04 -0700 | [diff] [blame] | 96 | |
| 97 | task preflight (dependsOn: parent.preflight) { |
| 98 | project.afterEvaluate { |
| 99 | // Inject a preflight task into each variant so we have a place to hook tasks |
| 100 | // that need to run before any of the android build tasks. |
| 101 | // |
| 102 | android.applicationVariants.each { variant -> |
| 103 | <#noparse> |
| 104 | tasks.getByPath("prepare${variant.name.capitalize()}Dependencies").dependsOn preflight |
| 105 | </#noparse> |
| 106 | } |
| 107 | } |
| 108 | } |
| 109 | |
Trevor Johns | f2a47dc | 2013-10-30 04:54:54 -0700 | [diff] [blame] | 110 | // END_EXCLUDE |