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         jcenter()
     19     }
     20 
     21     dependencies {
     22         classpath 'com.android.tools.build:gradle:2.3.3'
     23     }
     24 }
     25 
     26 apply plugin: 'com.android.application'
     27 
     28 repositories {
     29     jcenter()
     30     maven {
     31         url 'https://maven.google.com'
     32     }
     33 <#if sample.repository?has_content>
     34 <#list sample.repository as rep>
     35     ${rep}
     36 </#list>
     37 </#if>
     38 }
     39 
     40 dependencies {
     41 <#if !sample.auto_add_support_lib?has_content || sample.auto_add_support_lib == "true">
     42   <#if sample.minSdk?matches(r'^\d+$') && sample.minSdk?number < 7>
     43     compile "com.android.support:support-v4:26.1.0"
     44     compile "com.android.support:appcompat-v7:26.1.0"
     45   <#elseif sample.minSdk?matches(r'^\d+$') && sample.minSdk?number < 13>
     46     compile "com.android.support:support-v4:26.1.0"
     47     compile "com.android.support:gridlayout-v7:26.1.0"
     48     compile "com.android.support:cardview-v7:26.1.0"
     49     compile "com.android.support:appcompat-v7:26.1.0"
     50   <#else>
     51     compile "com.android.support:support-v4:26.1.0"
     52     compile "com.android.support:support-v13:26.1.0"
     53     compile "com.android.support:cardview-v7:26.1.0"
     54     compile "com.android.support:appcompat-v7:26.1.0"
     55   </#if>
     56 </#if>
     57 <#list sample.dependency as dep>
     58     <#-- Output dependency after checking if it is a play services depdency and
     59     needs the latest version number attached. -->
     60     <@update_play_services_dependency dep="${dep}" />
     61 </#list>
     62 <#list sample.dependency_external as dep>
     63     compile files(${dep})
     64 </#list>
     65 <#if sample.wearable.has_handheld_app?has_content && sample.wearable.has_handheld_app?lower_case == "true">
     66     compile ${play_services_wearable_dependency}
     67     compile ${android_support_v13_dependency}
     68     wearApp project(':Wearable')
     69 </#if>
     70 }
     71 
     72 // The sample build uses multiple directories to
     73 // keep boilerplate and common code separate from
     74 // the main sample code.
     75 List<String> dirs = [
     76     'main',     // main sample code; look here for the interesting stuff.
     77     'common',   // components that are reused by multiple samples
     78     'template'] // boilerplate code that is generated by the sample template process
     79 
     80 android {
     81      <#-- Note that target SDK is hardcoded in this template. We expect all samples
     82           to always use the most current SDK as their target. -->
     83     
     84      <#if sample.compileSdkVersion?? && sample.compileSdkVersion?has_content>
     85         compileSdkVersion ${sample.compileSdkVersion}
     86       <#else>
     87         compileSdkVersion ${compile_sdk}
     88       </#if>
     89 
     90     buildToolsVersion ${build_tools_version}
     91 
     92     defaultConfig {
     93         minSdkVersion ${min_sdk}
     94       <#if sample.targetSdkVersion?? && sample.targetSdkVersion?has_content>
     95         targetSdkVersion ${sample.targetSdkVersion}
     96       <#else>
     97         targetSdkVersion ${compile_sdk}
     98       </#if>
     99     }
    100 
    101     compileOptions {
    102         sourceCompatibility JavaVersion.VERSION_1_7
    103         targetCompatibility JavaVersion.VERSION_1_7
    104     }
    105 
    106     sourceSets {
    107         main {
    108             dirs.each { dir ->
    109 <#noparse>
    110                 java.srcDirs "src/${dir}/java"
    111                 res.srcDirs "src/${dir}/res"
    112 </#noparse>
    113             }
    114         }
    115         androidTest.setRoot('tests')
    116         androidTest.java.srcDirs = ['tests/src']
    117 
    118 <#if sample.defaultConfig?has_content>
    119         defaultConfig {
    120         ${sample.defaultConfig}
    121         }
    122 <#else>
    123 </#if>
    124     }
    125 
    126 <#if sample.aapt?has_content>
    127     aaptOptions {
    128     <#list sample.aapt.noCompress as noCompress>
    129         noCompress "${noCompress}"
    130     </#list>
    131     }
    132 </#if>
    133 }
    134