blob: 1475cea39ee026926fff0915aec2d8ceca608493 [file] [log] [blame]
{# Copyright 2016 The Chromium Authors. All rights reserved. #}
{# Use of this source code is governed by a BSD-style license that can be #}
{# found in the LICENSE file. #}
// Generated by //build/android/generate_gradle.py
{% if template_type == 'root' %}
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:2.2.3"
}
}
{% elif template_type in ('java_library', 'java_binary') %}
apply plugin: "java"
{% if template_type == 'java_binary' %}
apply plugin: "application"
{% endif %}
sourceSets {
main {
java.srcDirs = [
{% for path in java_dirs %}
"{{ path }}",
{% endfor %}
]
}
}
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
{% if template_type == 'java_binary' %}
mainClassName = "{{ main_class }}"
applicationName = "{{ target_name }}"
{% endif %}
{% if template_type in ('java_binary', 'java_library') %}
archivesBaseName = "{{ target_name }}"
{% endif %}
{% else %}
{% if template_type in ('android_library', 'android_junit') %}
apply plugin: "com.android.library"
{% elif template_type == 'android_apk' %}
apply plugin: "com.android.application"
{% endif %}
android {
compileSdkVersion {{ compile_sdk_version }}
buildToolsVersion "{{ build_tools_version }}"
publishNonDefault true
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
sourceSets {
{% for name in ['main', 'test', 'androidTest', 'debug', 'release'] %}
{{ name }} {
aidl.srcDirs = []
assets.srcDirs = []
java.srcDirs = []
jni.srcDirs = []
renderscript.srcDirs = []
res.srcDirs = []
resources.srcDirs = []
}
{% endfor %}
main.manifest.srcFile "{{ android_manifest }}"
{{ sourceSetName }} {
java.srcDirs = [
{% for path in java_dirs %}
"{{ path }}",
{% endfor %}
]
jniLibs.srcDirs = [
{% for path in jni_libs %}
"{{ path }}",
{% endfor %}
]
}
}
}
{% endif %}
{% if template_type != 'root' %}
dependencies {
{% for path in prebuilts %}
{{ depCompileName }} files("{{ path }}")
{% endfor %}
{% for proj in java_project_deps %}
{{ depCompileName }} project(":{{ proj }}")
{% endfor %}
{% for proj in android_project_deps %}
{{ depCompileName }} project(path: ":{{ proj }}", configuration: "debug")
{% endfor %}
}
{% if template_type.startswith('android') %}
android.variantFilter { variant ->
if (variant.buildType.name.equals('release')) {
variant.setIgnore(true);
}
}
afterEvaluate {
def tasksToDisable = tasks.findAll {
return (it.name.equals('generateDebugSources') // causes unwanted AndroidManifest.java
|| it.name.equals('generateReleaseSources')
|| it.name.endsWith('Assets')
|| it.name.endsWith('BuildConfig') // causes unwanted BuildConfig.java
{% if not use_gradle_process_resources %}
|| it.name.endsWith('Resources')
|| it.name.endsWith('ResValues')
{% endif %}
|| it.name.endsWith('Aidl')
|| it.name.endsWith('Renderscript')
|| it.name.endsWith('Shaders'))
}
tasksToDisable.each { Task task ->
task.enabled = false
}
}
{% endif %}
{% endif %}