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