• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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        jcenter()
19    }
20
21    dependencies {
22        classpath 'com.android.tools.build:gradle:1.0.0'
23    }
24}
25
26apply plugin: 'com.android.application'
27
28repositories {
29    jcenter()
30}
31
32<#if sample.repository?has_content>
33repositories {
34<#list sample.repository as rep>
35    ${rep}
36</#list>
37}
38</#if>
39
40dependencies {
41
42<#if !sample.auto_add_support_lib?has_content || sample.auto_add_support_lib == "true">
43  <#if sample.minSdk?matches(r'^\d+$') && sample.minSdk?number < 7>
44    compile "com.android.support:support-v4:21.0.2"
45  <#elseif sample.minSdk?matches(r'^\d+$') && sample.minSdk?number < 13>
46    compile "com.android.support:support-v4:21.0.2"
47    compile "com.android.support:gridlayout-v7:21.0.2"
48    compile "com.android.support:cardview-v7:21.0.2"
49  <#else>
50    compile "com.android.support:support-v4:21.0.2"
51    compile "com.android.support:support-v13:21.0.2"
52    compile "com.android.support:cardview-v7:21.0.2"
53  </#if>
54</#if>
55
56<#list sample.dependency as dep>
57    compile "${dep}"
58</#list>
59<#list sample.dependency_external as dep>
60    compile files(${dep})
61</#list>
62}
63
64// The sample build uses multiple directories to
65// keep boilerplate and common code separate from
66// the main sample code.
67List<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
72android {
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. -->
75    compileSdkVersion ${compile_sdk}
76    buildToolsVersion ${build_tools_version}
77
78    defaultConfig {
79        minSdkVersion ${min_sdk}
80        targetSdkVersion ${compile_sdk}
81    }
82
83    sourceSets {
84        main {
85            dirs.each { dir ->
86<#noparse>
87                java.srcDirs "src/${dir}/java"
88                res.srcDirs "src/${dir}/res"
89</#noparse>
90            }
91        }
92        androidTest.setRoot('tests')
93        androidTest.java.srcDirs = ['tests/src']
94
95<#if sample.defaultConfig?has_content>
96        defaultConfig {
97        ${sample.defaultConfig}
98        }
99<#else>
100</#if>
101    }
102
103<#if sample.aapt?has_content>
104    aaptOptions {
105    <#list sample.aapt.noCompress as noCompress>
106        noCompress "${noCompress}"
107    </#list>
108    }
109</#if>
110}
111// BEGIN_EXCLUDE
112// Tasks below this line will be hidden from release output
113
114task preflight (dependsOn: parent.preflight) {
115    project.afterEvaluate {
116        // Inject a preflight task into each variant so we have a place to hook tasks
117        // that need to run before any of the android build tasks.
118        //
119        android.applicationVariants.each { variant ->
120        <#noparse>
121            tasks.getByPath("prepare${variant.name.capitalize()}Dependencies").dependsOn preflight
122        </#noparse>
123        }
124    }
125}
126
127// END_EXCLUDE
128