dependencies.jinja 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. {%- macro AnnotationProcessors(funcName, annotation_processors) -%}
  2. {%- if annotation_processors|length -%}
  3. {%- set lomboks = annotation_processors|select('startsWith', 'contrib/java/org/projectlombok/lombok') -%}
  4. {%- for lombok in lomboks %}
  5. {{ funcName }}(files("$project_root/{{ lombok }}"))
  6. {%- endfor -%}
  7. {%- set annotation_processors = annotation_processors|reject('in', lomboks) -%}
  8. {%- for annotation_processor in annotation_processors %}
  9. {{ funcName }}(files("$project_root/{{ annotation_processor }}"))
  10. {%- endfor -%}
  11. {%- endif -%}
  12. {%- endmacro -%}
  13. {#- empty string #}
  14. dependencies {
  15. {%- for library in target.consumer if library.classpath -%}
  16. {%- if has_errorprone -%}
  17. {%- if library.prebuilt and (library.type != "contrib" or build_contribs) and ("contrib/java/com/google/errorprone/error_prone_annotations" in library.jar) -%}
  18. {%- set errorprone_version = library.jar|replace("contrib/java/com/google/errorprone/error_prone_annotations/", "") -%}
  19. {%- set errorprone_parts = split(errorprone_version, '/', 2) %}
  20. errorprone("com.google.errorprone:error_prone_core:{{ errorprone_parts[0] }}")
  21. {%- endif -%}
  22. {%- endif -%}
  23. {%- if library.prebuilt and library.jar and (library.type != "contrib" or build_contribs) %}
  24. implementation(files("$project_root/{{ library.jar }}"))
  25. {%- else -%}
  26. {%- set classpath = library.classpath -%}
  27. {%- if classpath|replace('"','') == classpath -%}
  28. {%- set classpath = '"' + classpath + '"' -%}
  29. {%- endif -%}
  30. {%- if library.type != "contrib" %}
  31. {%- if library.testdep %}
  32. implementation(project(path = ":{{ library.testdep | replace("/", ":") }}", configuration = "testArtifacts"))
  33. {%- else %}
  34. implementation({{ classpath }})
  35. {%- endif -%}
  36. {%- else %}
  37. api({{ classpath }})
  38. {%- endif -%}
  39. {%- if library.excludes.consumer is defined %} {
  40. {% for exclude in library.excludes.consumer if exclude.classpath -%}
  41. {%- set classpath = exclude.classpath|replace('"','') -%}
  42. {%- set classpath_parts = split(classpath, ':') -%}
  43. exclude(group = "{{ classpath_parts[0] }}", module = "{{ classpath_parts[1] }}")
  44. {% endfor -%}
  45. }
  46. {%- endif -%}
  47. {%- endif -%}
  48. {%- endfor -%}
  49. {{ AnnotationProcessors("annotationProcessor", target.use_annotation_processor) }}
  50. {%- for extra_target in extra_targets -%}
  51. {%- for library in extra_target.consumer if library.classpath -%}
  52. {%- if library.prebuilt and library.jar and (library.type != "contrib" or build_contribs) %}
  53. testImplementation(files("$project_root/{{ library.jar }}"))
  54. {%- else -%}
  55. {%- set classpath = library.classpath -%}
  56. {%- if classpath|replace('"','') == classpath -%}
  57. {%- set classpath = '"' + classpath + '"' -%}
  58. {%- endif %}
  59. {%- if library.type != "contrib" and library.testdep %}
  60. testImplementation(project(path = ":{{ library.testdep | replace("/", ":") }}", configuration = "testArtifacts"))
  61. {%- else %}
  62. testImplementation({{ classpath }})
  63. {%- endif -%}
  64. {%- if library.excludes.consumer is defined %} {
  65. {% for exclude in library.excludes.consumer if exclude.classpath -%}
  66. {%- set classpath = exclude.classpath|replace('"','') -%}
  67. {%- set classpath_parts = split(classpath, ':') -%}
  68. exclude(group = "{{ classpath_parts[0] }}", module = "{{ classpath_parts[1] }}")
  69. {% endfor -%}
  70. }
  71. {%- endif -%}
  72. {%- endif -%}
  73. {%- endfor -%}
  74. {{ AnnotationProcessors("testAnnotationProcessor", extra_target.use_annotation_processor) }}
  75. {%- endfor %}
  76. }