Home | History | Annotate | Download | only in _MODULE_
      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 {
     22         classpath 'com.android.tools.build:gradle:0.8.+'
     23     }
     24 }
     25 
     26 apply plugin: 'android'
     27 
     28 <#if sample.repository?has_content>
     29 repositories {
     30 <#list sample.repository as rep>
     31     ${rep}
     32 </#list>
     33 }
     34 </#if>
     35 
     36 dependencies {
     37 <#if !sample.auto_add_support_lib?has_content || sample.auto_add_support_lib == "true">
     38     // Add the support lib that is appropriate for SDK ${sample.minSdk}
     39   <#if sample.minSdk?number < 7>
     40     compile "com.android.support:support-v4:19.0.+"
     41   <#elseif sample.minSdk?number < 13>
     42     compile "com.android.support:support-v4:19.0.+"
     43     compile "com.android.support:gridlayout-v7:19.0.+"
     44   <#else>
     45     compile "com.android.support:support-v13:19.0.+"
     46   </#if>
     47 </#if>
     48 
     49 <#list sample.dependency as dep>
     50     compile "${dep}"
     51 </#list>
     52 <#list sample.dependency_external as dep>
     53     compile files(${dep})
     54 </#list>
     55 }
     56 
     57 // The sample build uses multiple directories to
     58 // keep boilerplate and common code separate from
     59 // the main sample code.
     60 List<String> dirs = [
     61     'main',     // main sample code; look here for the interesting stuff.
     62     'common',   // components that are reused by multiple samples
     63     'template'] // boilerplate code that is generated by the sample template process
     64 
     65 android {
     66      <#-- Note that target SDK is hardcoded in this template. We expect all samples
     67           to always use the most current SDK as their target. -->
     68     compileSdkVersion ${compile_sdk}
     69     buildToolsVersion "19.0.1"
     70 
     71     sourceSets {
     72         main {
     73             dirs.each { dir ->
     74 <#noparse>
     75                 java.srcDirs "src/${dir}/java"
     76                 res.srcDirs "src/${dir}/res"
     77 </#noparse>
     78             }
     79         }
     80         instrumentTest.setRoot('tests')
     81         instrumentTest.java.srcDirs = ['tests/src']
     82 
     83 <#if sample.defaultConfig?has_content>
     84         defaultConfig {
     85         ${sample.defaultConfig}
     86         }
     87 <#else>
     88 </#if>
     89     }
     90 }
     91 // BEGIN_EXCLUDE
     92 // Tasks below this line will be hidden from release output
     93 
     94 task preflight (dependsOn: parent.preflight) {
     95     project.afterEvaluate {
     96         // Inject a preflight task into each variant so we have a place to hook tasks
     97         // that need to run before any of the android build tasks.
     98         //
     99         android.applicationVariants.each { variant ->
    100         <#noparse>
    101             tasks.getByPath("prepare${variant.name.capitalize()}Dependencies").dependsOn preflight
    102         </#noparse>
    103         }
    104     }
    105 }
    106 
    107 // END_EXCLUDE
    108