|
5 | 5 | {{ funcName }}(files("$arcadia_root/{{ lombok }}"))
|
6 | 6 | {%- endfor -%}
|
7 | 7 | {%- set annotation_processors = annotation_processors|reject('in', lomboks) -%}
|
8 |
| -{%- for annotation_processor in annotation_processors %} |
| 8 | +{%- if annotation_processors|length -%} |
| 9 | +{%- for annotation_processor in annotation_processors %} |
9 | 10 | {{ funcName }}(files("$arcadia_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] }}") |
| 11 | +{%- endfor -%} |
21 | 12 | {%- endif -%}
|
22 | 13 | {%- endif -%}
|
| 14 | +{%- endmacro -%} |
23 | 15 |
|
24 |
| -{%- if library.prebuilt and library.jar and (library.type != "contrib" or build_contribs) %} |
25 |
| - implementation(files("$arcadia_root/{{ library.jar }}")) |
26 |
| -{%- else -%} |
27 |
| -{%- set classpath = library.classpath -%} |
28 |
| -{%- if classpath|replace('"','') == classpath -%} |
29 |
| -{%- set classpath = '"' + classpath + '"' -%} |
30 |
| -{%- endif -%} |
31 |
| -{%- include "[generator]/patch_classpath.jinja" -%} |
32 |
| -{%- if library.type != "contrib" %} |
33 |
| -{%- if library.testdep -%} |
34 |
| -{%- set classpath = '":' + library.testdep | replace("/", ":") + '"' -%} |
35 |
| -{%- include "[generator]/patch_classpath.jinja" %} |
36 |
| - implementation(project(path = {{ classpath }}, configuration = "testArtifacts")) |
37 |
| -{%- else %} |
38 |
| - implementation({{ classpath }}) |
39 |
| -{%- endif -%} |
40 |
| -{%- else %} |
41 |
| - api({{ classpath }}) |
42 |
| -{%- endif -%} |
43 |
| -{%- if library.excludes.consumer is defined %} { |
44 |
| -{% for exclude in library.excludes.consumer if exclude.classpath -%} |
45 |
| -{%- set classpath = exclude.classpath|replace('"','') -%} |
46 |
| -{%- set classpath_parts = split(classpath, ':') -%} |
47 |
| - exclude(group = "{{ classpath_parts[0] }}", module = "{{ classpath_parts[1] }}") |
48 |
| -{% endfor -%} |
49 |
| - } |
50 |
| -{%- endif -%} |
51 |
| -{%- endif -%} |
52 |
| -{%- endfor -%} |
53 |
| - |
54 |
| -{{ AnnotationProcessors("annotationProcessor", target.use_annotation_processor) }} |
| 16 | +{%- macro AddFileDeps(file_deps) -%} |
| 17 | +{%- for file_dep in file_deps %} |
| 18 | + "$arcadia_root/{{ file_dep.jar }}"{%- if not loop.last -%},{%- endif -%} |
| 19 | +{%- endfor -%} |
| 20 | +{%- endmacro -%} |
55 | 21 |
|
56 |
| -{%- for extra_target in extra_targets -%} |
57 |
| -{%- for library in extra_target.consumer if library.classpath -%} |
58 |
| -{%- if library.prebuilt and library.jar and (library.type != "contrib" or build_contribs) %} |
59 |
| - testImplementation(files("$arcadia_root/{{ library.jar }}")) |
60 |
| -{%- else -%} |
61 |
| -{%- set classpath = library.classpath -%} |
| 22 | +{%- macro AddNonFileDeps(current_target, file_classpaths, implementationFunc, apiFunc) -%} |
| 23 | +{%- for library in current_target.consumer if library.classpath -%} |
| 24 | +{%- set classpath = library.classpath -%} |
| 25 | +{%- if file_classpaths|select('eq', classpath)|length == 0 -%} |
62 | 26 | {%- if classpath|replace('"','') == classpath -%}
|
63 | 27 | {%- set classpath = '"' + classpath + '"' -%}
|
64 |
| -{%- endif %} |
| 28 | +{%- endif -%} |
65 | 29 | {%- include "[generator]/patch_classpath.jinja" -%}
|
66 |
| -{%- if library.type != "contrib" and library.testdep -%} |
67 |
| -{%- set classpath = '":' + library.testdep | replace("/", ":") + '"' -%} |
68 |
| -{%- include "[generator]/patch_classpath.jinja" %} |
69 |
| - testImplementation(project(path = {{ classpath }}, configuration = "testArtifacts")) |
| 30 | +{%- if library.type != "contrib" -%} |
| 31 | +{%- if library.testdep -%} |
| 32 | +{%- set classpath = '":' + library.testdep | replace("/", ":") + '"' -%} |
| 33 | +{%- include "[generator]/patch_classpath.jinja" %} |
| 34 | + {{ implementationFunc }}(project(path = {{ classpath }}, configuration = "testArtifacts")) |
| 35 | +{%- else %} |
| 36 | + {{ implementationFunc }}({{ classpath }}) |
| 37 | +{%- endif -%} |
70 | 38 | {%- else %}
|
71 |
| - testImplementation({{ classpath }}) |
| 39 | + {{ apiFunc }}({{ classpath }}) |
72 | 40 | {%- endif -%}
|
73 |
| -{%- if library.excludes.consumer is defined %} { |
74 |
| -{% for exclude in library.excludes.consumer if exclude.classpath -%} |
| 41 | +{%- if library.excludes.consumer|length -%} { |
| 42 | +{%- for exclude in library.excludes.consumer if exclude.classpath -%} |
75 | 43 | {%- set classpath = exclude.classpath|replace('"','') -%}
|
76 |
| -{%- set classpath_parts = split(classpath, ':') -%} |
| 44 | +{%- set classpath_parts = split(classpath, ':') %} |
77 | 45 | exclude(group = "{{ classpath_parts[0] }}", module = "{{ classpath_parts[1] }}")
|
78 |
| -{% endfor -%} |
| 46 | +{%- endfor %} |
79 | 47 | }
|
80 | 48 | {%- endif -%}
|
81 | 49 | {%- endif -%}
|
82 | 50 | {%- endfor -%}
|
| 51 | +{%- endmacro -%} |
| 52 | + |
| 53 | +{%- set file_deps = target.consumer|selectattr('classpath')|selectattr('jar')|selectattr('prebuilt', 'eq', true) -%} |
| 54 | +{%- if not build_contribs -%} |
| 55 | +{%- set file_deps = file_deps|selectattr('type', 'ne', 'contrib') -%} |
| 56 | +{%- endif -%} |
| 57 | +{%- set file_classpaths = file_deps|map(attribute='classpath') -%} |
| 58 | + |
| 59 | +{%- set test_file_deps = extra_targets|selectattr('consumer')|map(attribute='consumer')|sum|selectattr('classpath')|selectattr('jar')|selectattr('prebuilt', 'eq', true) -%} |
| 60 | +{%- if not build_contribs -%} |
| 61 | +{%- set test_file_deps = test_file_deps|selectattr('type', 'ne', 'contrib') -%} |
| 62 | +{%- endif -%} |
| 63 | +{%- set test_file_classpaths = test_file_deps|map(attribute='classpath') -%} |
| 64 | + |
| 65 | +dependencies { |
| 66 | +{%- if has_errorprone -%} |
| 67 | +{%- set errorprones = target.consumer|selectattr('classpath')|selectattr('jar', 'startsWith', 'contrib/java/com/google/errorprone/error_prone_annotations') -%} |
| 68 | +{%- if errorprones|length -%} |
| 69 | +{%- for errorprone in errorprones -%} |
| 70 | +{%- set errorprone_version = library.jar|replace("contrib/java/com/google/errorprone/error_prone_annotations/", "") -%} |
| 71 | +{%- set errorprone_parts = split(errorprone_version, '/', 2) %} |
| 72 | + errorprone("com.google.errorprone:error_prone_core:{{ errorprone_parts[0] }}") |
| 73 | +{%- endfor -%} |
| 74 | +{%- endif -%} |
| 75 | +{%- endif -%} |
| 76 | +{#- glue -#} |
| 77 | +{{ AnnotationProcessors("annotationProcessor", target.use_annotation_processor) }} |
| 78 | +{%- for extra_target in extra_targets -%} |
83 | 79 | {{ AnnotationProcessors("testAnnotationProcessor", extra_target.use_annotation_processor) }}
|
84 |
| -{%- endfor %} |
| 80 | +{%- endfor -%} |
| 81 | +{#- glue -#} |
| 82 | +{{ AddNonFileDeps(target, file_classpaths, "implementation", "api") }} |
| 83 | +{%- for extra_target in extra_targets -%} |
| 84 | +{{ AddNonFileDeps(extra_target, test_file_classpaths, "testImplementation", "testImplementation") }} |
| 85 | +{%- endfor -%} |
| 86 | + |
| 87 | +{%- if file_deps|length %} |
| 88 | + implementation(files(listOf({#- glue -#} |
| 89 | +{{ AddFileDeps(file_deps) }} |
| 90 | + ))) |
| 91 | +{%- endif -%} |
| 92 | + |
| 93 | +{%- if test_file_deps|length %} |
| 94 | + testImplementation(files(listOf({#- glue -#} |
| 95 | +{{ AddFileDeps(test_file_deps) }} |
| 96 | + ))) |
| 97 | +{%- endif %} |
85 | 98 | }
|
0 commit comments