Skip to content

Commit b8720ed

Browse files
committed
Fix too many dependencies by jar-file deps from lists
Fix too many dependencies by deps from lists commit_hash:0b9cf288487c8391e51e360187ceadea04e87674
1 parent 440827c commit b8720ed

File tree

2 files changed

+74
-61
lines changed

2 files changed

+74
-61
lines changed

build/export_generators/ide-gradle/dependencies.jinja

Lines changed: 73 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -5,81 +5,94 @@
55
{{ funcName }}(files("$arcadia_root/{{ lombok }}"))
66
{%- endfor -%}
77
{%- 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 %}
910
{{ 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 -%}
2112
{%- endif -%}
2213
{%- endif -%}
14+
{%- endmacro -%}
2315

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 -%}
5521

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 -%}
6226
{%- if classpath|replace('"','') == classpath -%}
6327
{%- set classpath = '"' + classpath + '"' -%}
64-
{%- endif %}
28+
{%- endif -%}
6529
{%- 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 -%}
7038
{%- else %}
71-
testImplementation({{ classpath }})
39+
{{ apiFunc }}({{ classpath }})
7240
{%- 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 -%}
7543
{%- set classpath = exclude.classpath|replace('"','') -%}
76-
{%- set classpath_parts = split(classpath, ':') -%}
44+
{%- set classpath_parts = split(classpath, ':') %}
7745
exclude(group = "{{ classpath_parts[0] }}", module = "{{ classpath_parts[1] }}")
78-
{% endfor -%}
46+
{%- endfor %}
7947
}
8048
{%- endif -%}
8149
{%- endif -%}
8250
{%- 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 -%}
8379
{{ 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 %}
8598
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{%- if common_dir_classpath -%}
2-
{%- set classpath = classpath|replace(common_dir_classpath, '"') -%}
2+
{%- set classpath = classpath|replace(common_dir_classpath, '"')|replace('""', '":"') -%}
33
{%- endif -%}

0 commit comments

Comments
 (0)