android.jinja 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. {# Copyright 2016 The Chromium Authors. All rights reserved. #}
  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. {% if template_type in ('android_library', 'android_junit') %}
  43. apply plugin: "com.android.library"
  44. {% elif template_type == 'android_apk' %}
  45. apply plugin: "com.android.application"
  46. {% endif %}
  47. android {
  48. compileSdkVersion "{{ compile_sdk_version }}"
  49. defaultConfig {
  50. vectorDrawables.useSupportLibrary = true
  51. minSdkVersion {{ min_sdk_version }}
  52. targetSdkVersion {{ target_sdk_version }}
  53. }
  54. compileOptions {
  55. sourceCompatibility JavaVersion.VERSION_11
  56. targetCompatibility JavaVersion.VERSION_11
  57. }
  58. {% if native is defined %}
  59. externalNativeBuild {
  60. cmake {
  61. path "CMakeLists.txt"
  62. }
  63. }
  64. {% endif %}
  65. sourceSets {
  66. {% for name in ['main', 'test', 'androidTest', 'debug', 'release'] %}
  67. {{ name }} {
  68. aidl.srcDirs = []
  69. assets.srcDirs = []
  70. java.srcDirs = []
  71. jni.srcDirs = []
  72. renderscript.srcDirs = []
  73. res.srcDirs = []
  74. resources.srcDirs = []
  75. }
  76. {% endfor %}
  77. {{ expand_sourceset(main, 'main') }}
  78. {{ expand_sourceset(test, 'test') }}
  79. {% if android_test is defined %}
  80. {% for t in android_test %}
  81. {{ expand_sourceset(t, 'androidTest') }}
  82. {% endfor %}
  83. {% endif %}
  84. }
  85. }
  86. {% include 'dependencies.jinja' %}
  87. afterEvaluate {
  88. def tasksToDisable = tasks.findAll {
  89. return (it.name.equals('generateDebugSources') // causes unwanted AndroidManifest.java
  90. || it.name.equals('generateReleaseSources')
  91. || it.name.endsWith('BuildConfig') // causes unwanted BuildConfig.java
  92. || it.name.equals('preDebugAndroidTestBuild')
  93. {% if not use_gradle_process_resources %}
  94. || it.name.endsWith('Assets')
  95. || it.name.endsWith('Resources')
  96. || it.name.endsWith('ResValues')
  97. {% endif %}
  98. || it.name.endsWith('Aidl')
  99. || it.name.endsWith('Renderscript')
  100. || it.name.endsWith('Shaders'))
  101. }
  102. tasksToDisable.each { Task task ->
  103. task.enabled = false
  104. }
  105. }