• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1{# Copyright 2016 The Chromium Authors #}
2{# Use of this source code is governed by a BSD-style license that can be #}
3{# found in the LICENSE file. #}
4{% macro expand_sourceset(variables, prefix) %}
5{% if variables is defined %}
6        {{ prefix }} {
7{% if variables.android_manifest is defined %}
8            manifest.srcFile "{{ variables.android_manifest }}"
9{% endif %}
10{% if variables.java_dirs is defined %}
11            java.srcDirs = [
12{% for path in variables.java_dirs %}
13                "{{ path }}",
14{% endfor %}
15            ]
16{% endif %}
17{% if variables.java_excludes is defined %}
18            java.filter.exclude([
19{% for path in variables.java_excludes %}
20                "{{ path }}",
21{% endfor %}
22            ])
23{% endif %}
24{% if variables.jni_libs is defined %}
25            jniLibs.srcDirs = [
26{% for path in variables.jni_libs %}
27                "{{ path }}",
28{% endfor %}
29            ]
30{% endif %}
31{% if variables.res_dirs is defined %}
32            res.srcDirs = [
33{% for path in variables.res_dirs %}
34                "{{ path }}",
35{% endfor %}
36            ]
37{% endif %}
38        }
39{% endif %}
40{% endmacro %}
41// Generated by //build/android/generate_gradle.py
42
43{% if template_type in ('android_library', 'android_junit') %}
44apply plugin: "com.android.library"
45{% elif template_type == 'android_apk' %}
46apply plugin: "com.android.application"
47{% endif %}
48
49android {
50    compileSdkVersion "{{ compile_sdk_version }}"
51
52    defaultConfig {
53        vectorDrawables.useSupportLibrary = true
54        minSdkVersion {{ min_sdk_version }}
55        targetSdkVersion {{ target_sdk_version }}
56    }
57
58    compileOptions {
59        sourceCompatibility JavaVersion.VERSION_17
60        targetCompatibility JavaVersion.VERSION_17
61    }
62
63{% if native is defined %}
64    externalNativeBuild {
65        cmake {
66            path "CMakeLists.txt"
67        }
68    }
69{% endif %}
70
71    sourceSets {
72{% for name in ['main', 'test', 'androidTest', 'debug', 'release'] %}
73        {{ name }} {
74            aidl.srcDirs = []
75            assets.srcDirs = []
76            java.srcDirs = []
77            jni.srcDirs = []
78            renderscript.srcDirs = []
79            res.srcDirs = []
80            resources.srcDirs = []
81        }
82{% endfor %}
83
84{{ expand_sourceset(main, 'main') }}
85{{ expand_sourceset(test, 'test') }}
86{% if android_test is defined %}
87{% for t in android_test %}
88{{ expand_sourceset(t, 'androidTest') }}
89{% endfor %}
90{% endif %}
91    }
92}
93
94{% include 'dependencies.jinja' %}
95
96afterEvaluate {
97    def tasksToDisable = tasks.findAll {
98        return (it.name.equals('generateDebugSources')  // causes unwanted AndroidManifest.java
99                || it.name.equals('generateReleaseSources')
100                || it.name.endsWith('BuildConfig')  // causes unwanted BuildConfig.java
101                || it.name.equals('preDebugAndroidTestBuild')
102{% if not use_gradle_process_resources %}
103                || it.name.endsWith('Assets')
104                || it.name.endsWith('Resources')
105                || it.name.endsWith('ResValues')
106{% endif %}
107                || it.name.endsWith('Aidl')
108                || it.name.endsWith('Renderscript')
109                || it.name.endsWith('Shaders'))
110    }
111    tasksToDisable.each { Task task ->
112      task.enabled = false
113    }
114}
115