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