blob: 48a2a171678853de598c677184c231129c920019 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
{%- if with_kotlin -%}
{%- if with_kapt or with_test_kapt %}
{%- if all_kapt_ap_opts|length %}
fun encodeAPOptions(options: Map<String, String>): String {
val os = ByteArrayOutputStream()
val oos = ObjectOutputStream(os)
oos.writeInt(options.size)
for ((key, value) in options.entries) {
oos.writeUTF(key)
oos.writeUTF(value)
}
oos.flush()
return Base64.getEncoder().encodeToString(os.toByteArray())
}
{% endif -%}
{%- set all_kapt_processors = all_targets|selectattr('kapt')|map(attribute='kapt')|selectattr('processors')|map(attribute='processors')|sum -%}
{%- set all_kapt_opts = all_targets|selectattr('kapt')|map(attribute='kapt')|selectattr('opts')|map(attribute='opts')|sum -%}
{%- set opts_correctErrorTypes = all_kapt_opts|select('startsWith', 'plugin:org.jetbrains.kotlin.kapt3:correctErrorTypes=') -%}
{%- set opts_verbose = all_kapt_opts|select('startsWith', 'plugin:org.jetbrains.kotlin.kapt3:verbose=') -%}
{%- set has_annotation_processors = all_targets|selectattr('use_annotation_processors')|map(attribute='use_annotation_processors')|sum|length -%}
{%- if all_kapt_processors|length or opts_correctErrorTypes|length or opts_verbose|length or all_kapt_ap_opts|length or has_annotation_processors -%}
kapt {
{%- if all_kapt_processors|length %}
annotationProcessors({%- for processor in all_kapt_processors -%}"{{ processor }}"{%- if not loop.last -%}, {%- endif -%}{%- endfor -%})
{%- endif -%}
{%- if has_annotation_processors %}
keepJavacAnnotationProcessors = true
{%- endif -%}
{%- if opts_correctErrorTypes|length -%}
{%- set key_and_value = split(opts_correctErrorTypes|first, '=', 2) %}
correctErrorTypes = {{ key_and_value[1] }}
{%- endif -%}
{%- if opts_verbose|length -%}
{%- set key_and_value = split(opts_verbose|first, '=', 2) -%}
{%- if key_and_value[1] == "true" %}
dumpDefaultParameterValues = true
showProcessorStats = true
{%- endif -%}
{%- endif -%}
{%- if all_kapt_ap_opts|length %}
arguments {
{%- for ap_opt in all_kapt_ap_opts|unique -%}
{%- set key_and_value = split(ap_opt, '=', 2) %}
arg("{{ key_and_value[0] }}", {{ PatchRoots(key_and_value[1]) }})
{%- endfor %}
}
{%- endif %}
}
{%- endif -%}
{%- endif -%}
{%- endif -%}
|