|
1 | 1 | {%- macro AnnotationProcessors(func, annotation_processors) -%} |
2 | 2 | {%- if annotation_processors|length -%} |
3 | 3 | {%- set first_ap = annotation_processors|first -%} |
4 | | -{%- if first_ap.jar is defined -%} |
5 | | -{#- Objects in list - new format -#} |
6 | | -{%- set annotation_processors = annotation_processors|unique|sort -%} |
7 | | -{%- set lomboks = annotation_processors|selectattr('jar', 'startsWith', LOMBOK_PATH) -%} |
8 | | -{%- set nolomboks = annotation_processors|rejectattr('jar', 'startsWith', LOMBOK_PATH) -%} |
9 | | -{%- if lomboks|length -%} |
10 | | -{%- for annotation_processor in lomboks -%} |
11 | | -{%- set parts = rsplit(annotation_processor.jar, "/", 4) %} |
| 4 | +{%- set annotation_processors = annotation_processors|unique|sort -%} |
| 5 | +{%- set lomboks = annotation_processors|selectattr('jar', 'startsWith', LOMBOK_PATH) -%} |
| 6 | +{%- set nolomboks = annotation_processors|rejectattr('jar', 'startsWith', LOMBOK_PATH) -%} |
| 7 | +{%- if lomboks|length -%} |
| 8 | +{%- for annotation_processor in lomboks -%} |
| 9 | +{%- set parts = rsplit(annotation_processor.jar, "/", 4) %} |
12 | 10 | {{ func }}("{{ parts[0]|replace("contrib/java/", "")|replace("/", ".") }}:{{ parts[1] }}:{{ parts[2] }}") |
13 | | -{%- endfor -%} |
14 | | -{%- endif -%} |
15 | | -{%- if nolomboks|length -%} |
16 | | -{%- for annotation_processor in nolomboks -%} |
17 | | -{%- if [annotation_processor.jar]|select('startsWith', 'contrib/java/')|length -%} |
| 11 | +{%- endfor -%} |
| 12 | +{%- endif -%} |
| 13 | +{%- if nolomboks|length -%} |
| 14 | +{%- for annotation_processor in nolomboks -%} |
| 15 | +{%- if [annotation_processor.jar]|select('startsWith', 'contrib/java/')|length -%} |
18 | 16 | {#- Contrib AP, use by classpath -#} |
19 | | -{%- set parts = rsplit(annotation_processor.jar, "/", 4) %} |
| 17 | +{%- set parts = rsplit(annotation_processor.jar, "/", 4) %} |
20 | 18 | {{ func }}("{{ parts[0]|replace("contrib/java/", "")|replace("/", ".") }}:{{ parts[1] }}:{{ parts[2] }}") |
21 | | -{%- else -%} |
| 19 | +{%- else -%} |
22 | 20 | {#- Has handmade AP, put all APs as jars in one list #} |
23 | 21 | {{ func }}(files(listOf( |
24 | | -{%- if annotation_processor.deps|length -%} |
25 | | -{%- for annotation_processor_dep in annotation_processor.deps %} |
| 22 | +{%- if annotation_processor.deps|length -%} |
| 23 | +{%- for annotation_processor_dep in annotation_processor.deps %} |
26 | 24 | {{ PatchRoots(output_root + "/" + annotation_processor_dep, false, "", true) }}, |
27 | | -{%- endfor -%} |
28 | | -{%- endif %} |
29 | | - {{ PatchRoots(output_root + "/" + annotation_processor.jar, false, "", true) }}, |
30 | | - ))) |
| 25 | +{%- endfor -%} |
31 | 26 | {%- endif %} |
32 | | -{%- endfor %} |
33 | | -{%- endif -%} |
34 | | -{%- else -%} |
35 | | -{#- Strings in list - old format -#} |
36 | | -{%- set annotation_processors = annotation_processors|unique|sort -%} |
37 | | -{%- set lomboks = annotation_processors|select('startsWith', LOMBOK_PATH) -%} |
38 | | -{%- set nolomboks = annotation_processors|reject('startsWith', LOMBOK_PATH) -%} |
39 | | -{%- if lomboks|length -%} |
40 | | -{%- for annotation_processor in lomboks -%} |
41 | | -{%- set parts = rsplit(annotation_processor, "/", 4) %} |
42 | | - {{ func }}("{{ parts[0]|replace("contrib/java/", "")|replace("/", ".") }}:{{ parts[1] }}:{{ parts[2] }}") |
43 | | -{%- endfor -%} |
44 | | -{%- endif -%} |
45 | | -{%- if nolomboks|length -%} |
46 | | -{%- if nolomboks|reject('startsWith', 'contrib/java/')|length -%} |
47 | | -{#- Has handmade AP, put all APs as jars in one list #} |
48 | | - {{ func }}(files(listOf( |
49 | | -{%- for annotation_processor in nolomboks %} |
50 | | - {{ PatchRoots(output_root + "/" + annotation_processor, false, "", true) }}, |
51 | | -{%- endfor %} |
| 27 | + {{ PatchRoots(output_root + "/" + annotation_processor.jar, false, "", true) }}, |
52 | 28 | ))) |
53 | | -{%- else -%} |
54 | | -{%- for annotation_processor in nolomboks -%} |
55 | | -{%- set parts = rsplit(annotation_processor, "/", 4) %} |
56 | | - {{ func }}("{{ parts[0]|replace("contrib/java/", "")|replace("/", ".") }}:{{ parts[1] }}:{{ parts[2] }}") |
57 | | -{%- endfor -%} |
58 | | -{%- endif -%} |
59 | | -{%- endif -%} |
| 29 | +{%- endif %} |
| 30 | +{%- endfor %} |
60 | 31 | {%- endif -%} |
61 | 32 | {%- endif -%} |
62 | 33 | {%- endmacro -%} |
63 | 34 |
|
64 | 35 | {%- macro Kapts(func, kapts, file_jars, test_file_jars) -%} |
65 | 36 | {%- if kapts|length -%} |
66 | 37 | {%- set kapt_first = kapts|first -%} |
67 | | -{%- if kapt_first.jar is defined -%} |
68 | | -{#- Objects list, new format-#} |
69 | | -{%- set kapt_jars = kapts|map(attribute='jar')|unique|sort -%} |
70 | | -{%- for kapt_jar in kapt_jars -%} |
71 | | -{%- set kapt = kapts|selectattr('jar', 'eq', kapt_jar)|first -%} |
72 | | -{%- if (kapt_jar in file_jars) or (kapt_jar in test_file_jars) -%} |
73 | | -{#- found KAPT jar in depends => use kapt as jar #} |
| 38 | +{%- set kapt_jars = kapts|map(attribute='jar')|unique|sort -%} |
| 39 | +{%- for kapt_jar in kapt_jars -%} |
| 40 | +{%- set kapt = kapts|selectattr('jar', 'eq', kapt_jar)|first -%} |
| 41 | +{%- if (kapt_jar in file_jars) or (kapt_jar in test_file_jars) -%} |
| 42 | +{#- found KAPT jar in depends => use kapt as jar #} |
74 | 43 | {{ func }}(files(listOf( |
75 | | -{%- if kapt.deps|length -%} |
76 | | -{%- for kapt_dep in kapt.deps %} |
| 44 | +{%- if kapt.deps|length -%} |
| 45 | +{%- for kapt_dep in kapt.deps %} |
77 | 46 | "$output_root/{{ kapt_dep }}", |
78 | | -{%- endfor -%} |
79 | | -{%- endif %} |
| 47 | +{%- endfor -%} |
| 48 | +{%- endif %} |
80 | 49 | "$output_root/{{ kapt_jar }}", |
81 | 50 | ))) |
82 | | -{%- else -%} |
83 | | -{#- no in depends jar => use KAPT as project() -#} |
84 | | -{%- set path_and_jar = rsplit(kapt_jar, "/", 2) -%} |
85 | | -{%- set classpath = 'project(":' + path_and_jar[0]|replace("/", ":") + '")' -%} |
86 | | -{%- include "[generator]/patch_classpath.jinja" %} |
87 | | - {{ func }}({{ classpath }}) |
88 | | -{%- endif -%} |
89 | | -{%- endfor -%} |
90 | | -{%- else -%} |
91 | | -{#- Strings list, old format-#} |
92 | | -{%- set srt_kapts = kapts|unique|sort -%} |
93 | | -{%- set jar_kapts = [] -%} |
94 | | -{%- set cls_kapts = srt_kapts -%} |
95 | | -{%- if file_jars|length -%} |
96 | | -{%- set jar_kapts = jar_kapts + srt_kapts|select('in', file_jars) -%} |
97 | | -{%- set cls_kapts = cls_kapts|reject('in', file_jars) -%} |
98 | | -{%- endif -%} |
99 | | -{%- if test_file_jars|length -%} |
100 | | -{%- set jar_kapts = jar_kapts + srt_kapts|select('in', test_file_jars) -%} |
101 | | -{%- set cls_kapts = cls_kapts|reject('in', test_file_jars) -%} |
102 | | -{%- endif -%} |
103 | | -{%- if jar_kapts|length %} |
104 | | - {{ func }}(files(listOf( |
105 | | -{%- for kapt in jar_kapts %} |
106 | | - "$output_root/{{ kapt }}", |
107 | | -{%- endfor %} |
108 | | - ))) |
109 | | -{%- endif -%} |
110 | | -{%- if cls_kapts|length -%} |
111 | | -{%- for kapt in cls_kapts -%} |
112 | | -{%- set path_and_jar = rsplit(kapt, "/", 2) -%} |
113 | | -{%- set classpath = 'project(":' + path_and_jar[0]|replace("/", ":") + '")' -%} |
114 | | -{%- include "[generator]/patch_classpath.jinja" %} |
| 51 | +{%- else -%} |
| 52 | +{#- no in depends jar => use KAPT as project() -#} |
| 53 | +{%- set path_and_jar = rsplit(kapt_jar, "/", 2) -%} |
| 54 | +{%- set classpath = 'project(":' + path_and_jar[0]|replace("/", ":") + '")' -%} |
| 55 | +{%- include "[generator]/patch_classpath.jinja" %} |
115 | 56 | {{ func }}({{ classpath }}) |
116 | | -{%- endfor -%} |
117 | 57 | {%- endif -%} |
118 | | -{%- endif -%} |
| 58 | +{%- endfor -%} |
119 | 59 | {%- endif -%} |
120 | 60 | {%- endmacro -%} |
121 | 61 |
|
@@ -189,22 +129,14 @@ dependencies { |
189 | 129 | {%- endfor -%} |
190 | 130 | {%- endif -%} |
191 | 131 | {#- glue -#} |
192 | | -{{ AnnotationProcessors("annotationProcessor", target.use_annotation_processor) }} |
193 | | -{#- glue -#} |
194 | 132 | {{ AnnotationProcessors("annotationProcessor", target.use_annotation_processors) }} |
195 | | -{%- set test_annotation_processors = extra_targets|selectattr('use_annotation_processor')|map(attribute='use_annotation_processor')|sum -%} |
196 | | -{{ AnnotationProcessors("testAnnotationProcessor", test_annotation_processors) }} |
197 | 133 | {%- set test_annotation_processors = extra_targets|selectattr('use_annotation_processors')|map(attribute='use_annotation_processors')|sum -%} |
198 | 134 | {{ AnnotationProcessors("testAnnotationProcessor", test_annotation_processors) }} |
199 | 135 | {%- if with_kapt -%} |
200 | | -{{ Kapts("kapt", target.kapt.classpaths, file_jars, test_file_jars) }} |
201 | | -{#- glue -#} |
202 | 136 | {{ Kapts("kapt", target.kapt.kapts, file_jars, test_file_jars) }} |
203 | 137 | {%- endif -%} |
204 | 138 | {%- if with_test_kapt -%} |
205 | 139 | {%- for extra_target in extra_targets -%} |
206 | | -{{ Kapts("kaptTest", extra_target.kapt.classpaths, file_jars, test_file_jars) }} |
207 | | -{#- glue -#} |
208 | 140 | {{ Kapts("kaptTest", extra_target.kapt.kapts, file_jars, test_file_jars) }} |
209 | 141 | {%- endfor -%} |
210 | 142 | {%- endif -%} |
|
0 commit comments