summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordimdim11 <[email protected]>2025-04-30 17:21:50 +0300
committerdimdim11 <[email protected]>2025-04-30 17:38:43 +0300
commit816a0f4682fac9c75accacdd34ccca3d816e8761 (patch)
treeaeda67290724e6502406a75c3ddbda7c60f161ff
parent8f9d74b1d484e2c87fc1a16e25c8276cc9fcdfe7 (diff)
Many fixes around kotlin and fix copy codegen
Many fixes around kotlin and fix copy codegen commit_hash:63e388f3b3d56c95287e71d0624b51288c07379c
-rw-r--r--build/export_generators/gradle/generator.toml3
-rw-r--r--build/export_generators/ide-gradle/build.gradle.kts.any.jinja1
-rw-r--r--build/export_generators/ide-gradle/codegen_copy_file.jinja4
-rw-r--r--build/export_generators/ide-gradle/common_vars.jinja22
-rw-r--r--build/export_generators/ide-gradle/generator.toml3
-rw-r--r--build/export_generators/ide-gradle/kotlin_plugins.jinja24
-rw-r--r--build/export_generators/ide-gradle/kotlinc_flags.jinja10
-rw-r--r--build/export_generators/ide-gradle/proto_vars.jinja7
-rw-r--r--build/export_generators/ide-gradle/vars.jinja8
9 files changed, 46 insertions, 36 deletions
diff --git a/build/export_generators/gradle/generator.toml b/build/export_generators/gradle/generator.toml
index 6f4009f241d..426656dc2cc 100644
--- a/build/export_generators/gradle/generator.toml
+++ b/build/export_generators/gradle/generator.toml
@@ -17,17 +17,14 @@ template="build.gradle.kts.jinja"
template={ path="build.gradle.kts.proto.jinja", dest="build.gradle.kts" }
[targets.jar_test]
-template="build.gradle.kts.jinja"
is_test = true
is_extra_target = true
[targets.junit4]
-template="build.gradle.kts.jinja"
is_test = true
is_extra_target = true
[targets.junit5]
-template="build.gradle.kts.jinja"
is_test = true
is_extra_target = true
diff --git a/build/export_generators/ide-gradle/build.gradle.kts.any.jinja b/build/export_generators/ide-gradle/build.gradle.kts.any.jinja
index 79936b6822c..d5126e76721 100644
--- a/build/export_generators/ide-gradle/build.gradle.kts.any.jinja
+++ b/build/export_generators/ide-gradle/build.gradle.kts.any.jinja
@@ -30,6 +30,7 @@
{%- if proto_template -%}
{%- include "[generator]/proto_vars.jinja" -%}
+{%- include "[generator]/import.jinja" -%}
{%- include "[generator]/proto_import.jinja" -%}
{%- include "[generator]/proto_builddir.jinja" -%}
{%- include "[generator]/proto_plugins.jinja" -%}
diff --git a/build/export_generators/ide-gradle/codegen_copy_file.jinja b/build/export_generators/ide-gradle/codegen_copy_file.jinja
index 2b054b7ce1f..7689c4db1c4 100644
--- a/build/export_generators/ide-gradle/codegen_copy_file.jinja
+++ b/build/export_generators/ide-gradle/codegen_copy_file.jinja
@@ -16,7 +16,7 @@ val {{ varprefix }}{{ copy['_object_index'] }} = tasks.register<Copy>("{{ varpre
into({{ PatchRoots(dst_path, false, true) }})
{%- if src_name != dst_name %}
rename("{{ src_name }}", "{{ dst_name }}")
+{%- endif %}
}
-{% endif -%}
-{%- endfor -%}
+{% endfor -%}
{%- endif -%}
diff --git a/build/export_generators/ide-gradle/common_vars.jinja b/build/export_generators/ide-gradle/common_vars.jinja
new file mode 100644
index 00000000000..11662f423a4
--- /dev/null
+++ b/build/export_generators/ide-gradle/common_vars.jinja
@@ -0,0 +1,22 @@
+{%- if target is defined -%}
+{%- set publish = target.publish -%}
+{%- set with_kotlin = target.with_kotlin -%}
+{%- if with_kotlin -%}
+{%- set kotlin_version = target.kotlin_version -%}
+{%- set with_kotlinc_plugin_allopen = target.with_kotlinc_plugin_allopen -%}
+{%- set with_kotlinc_plugin_noarg = target.with_kotlinc_plugin_noarg -%}
+{%- endif -%}
+{%- set has_errorprone = target.use_errorprone and not disable_errorprone and target.consumer|selectattr('jar', 'startsWith', 'contrib/java/com/google/errorprone/error_prone_annotations')|length -%}
+{%- else -%}
+{#- No target, only extra_targets, get main features from extra_targets -#}
+{%- set publish = extra_targets|selectattr('publish', 'eq', true)|length -%}
+{%- set with_kotlin = extra_targets|selectattr('with_kotlin', 'eq', true)|length -%}
+{%- if with_kotlin -%}
+{%- set kotlin_version = extra_targets|selectattr('kotlin_version')|map(attribute='kotlin_version')|first -%}
+{%- set with_kotlinc_plugin_allopen = extra_targets|selectattr('with_kotlinc_plugin_allopen')|map(attribute='with_kotlinc_plugin_allopen')|sum -%}
+{%- set with_kotlinc_plugin_noarg = extra_targets|selectattr('with_kotlinc_plugin_noarg')|map(attribute='with_kotlinc_plugin_noarg')|sum -%}
+{%- endif -%}
+{%- set has_errorprone = extra_targets|selectattr('use_errorprone', 'eq', true)|length and not disable_errorprone and extra_targets|selectattr('consumer')|map(attribute='consumer')|sum|selectattr('jar', 'startsWith', 'contrib/java/com/google/errorprone/error_prone_annotations')|length -%}
+{%- endif -%}
+
+{%- include "[generator]/jdk.jinja" -%}
diff --git a/build/export_generators/ide-gradle/generator.toml b/build/export_generators/ide-gradle/generator.toml
index 545ba60540b..61c247cba2f 100644
--- a/build/export_generators/ide-gradle/generator.toml
+++ b/build/export_generators/ide-gradle/generator.toml
@@ -20,17 +20,14 @@ template="build.gradle.kts.jinja"
template={ path="build.gradle.kts.proto.jinja", dest="build.gradle.kts" }
[targets.jar_test]
-template="build.gradle.kts.jinja"
is_test = true
is_extra_target = true
[targets.junit4]
-template="build.gradle.kts.jinja"
is_test = true
is_extra_target = true
[targets.junit5]
-template="build.gradle.kts.jinja"
is_test = true
is_extra_target = true
diff --git a/build/export_generators/ide-gradle/kotlin_plugins.jinja b/build/export_generators/ide-gradle/kotlin_plugins.jinja
index 823fa5243d4..0a2e7cd48d2 100644
--- a/build/export_generators/ide-gradle/kotlin_plugins.jinja
+++ b/build/export_generators/ide-gradle/kotlin_plugins.jinja
@@ -1,20 +1,20 @@
-{%- if target.with_kotlinc_plugin_allopen|length -%}
+{%- if with_kotlinc_plugin_allopen|length -%}
{%- set allopen_annotations = [] -%}
-{%- if target.with_kotlinc_plugin_allopen|select('eq', 'preset=spring')|length -%}
+{%- if with_kotlinc_plugin_allopen|select('eq', 'preset=spring')|length -%}
{%- set allopen_annotations = allopen_annotations + ['org.springframework.stereotype.Component', 'org.springframework.transaction.annotation.Transactional', 'org.springframework.scheduling.annotation.Async', 'org.springframework.cache.annotation.Cacheable', 'org.springframework.boot.test.context.SpringBootTest', 'org.springframework.validation.annotation.Validated'] -%}
{%- endif -%}
-{%- if target.with_kotlinc_plugin_allopen|select('eq', 'preset=quarkus')|length -%}
+{%- if with_kotlinc_plugin_allopen|select('eq', 'preset=quarkus')|length -%}
{%- set allopen_annotations = allopen_annotations + ['javax.enterprise.context.ApplicationScoped', 'javax.enterprise.context.RequestScoped'] -%}
{%- endif -%}
-{%- if target.with_kotlinc_plugin_allopen|select('eq', 'preset=micronaut')|length -%}
+{%- if with_kotlinc_plugin_allopen|select('eq', 'preset=micronaut')|length -%}
{%- set allopen_annotations = allopen_annotations + ['io.micronaut.aop.Around', 'io.micronaut.aop.Introduction', 'io.micronaut.aop.InterceptorBinding', 'io.micronaut.aop.InterceptorBindingDefinitions'] -%}
{%- endif -%}
-{%- if target.with_kotlinc_plugin_allopen|select('startsWith', 'annotation=')|length -%}
-{%- set sannotations = target.with_kotlinc_plugin_allopen|select('startsWith', 'annotation=')|join('|')|replace('annotation=','') -%}
+{%- if with_kotlinc_plugin_allopen|select('startsWith', 'annotation=')|length -%}
+{%- set sannotations = with_kotlinc_plugin_allopen|select('startsWith', 'annotation=')|join('|')|replace('annotation=','') -%}
{%- set annotations = split(sannotations, '|') -%}
{%- set allopen_annotations = allopen_annotations + annotations -%}
{%- endif -%}
-{%- set allopen_options = target.with_kotlinc_plugin_allopen|reject('startsWith', 'preset=')|reject('startsWith', 'annotation=')|reject('eq', 'default') %}
+{%- set allopen_options = with_kotlinc_plugin_allopen|reject('startsWith', 'preset=')|reject('startsWith', 'annotation=')|reject('eq', 'default') %}
allOpen {
{%- if allopen_options|length -%}
@@ -30,17 +30,17 @@ allOpen {
}
{% endif -%}
-{%- if target.with_kotlinc_plugin_noarg|length -%}
+{%- if with_kotlinc_plugin_noarg|length -%}
{%- set noarg_annotations = [] -%}
-{%- if target.with_kotlinc_plugin_noarg|select('eq', 'preset=jpa')|length -%}
+{%- if with_kotlinc_plugin_noarg|select('eq', 'preset=jpa')|length -%}
{%- set noarg_annotations = noarg_annotations + ['javax.persistence.Entity', 'javax.persistence.Embeddable', 'javax.persistence.MappedSuperclass', 'jakarta.persistence.Entity', 'jakarta.persistence.Embeddable', 'jakarta.persistence.MappedSuperclass'] -%}
{%- endif -%}
-{%- if target.with_kotlinc_plugin_noarg|select('startsWith', 'annotation=')|length -%}
-{%- set sannotations = target.with_kotlinc_plugin_noarg|select('startsWith', 'annotation=')|join('|')|replace('annotation=','') -%}
+{%- if with_kotlinc_plugin_noarg|select('startsWith', 'annotation=')|length -%}
+{%- set sannotations = with_kotlinc_plugin_noarg|select('startsWith', 'annotation=')|join('|')|replace('annotation=','') -%}
{%- set annotations = split(sannotations, '|') -%}
{%- set noarg_annotations = noarg_annotations + annotations -%}
{%- endif -%}
-{%- set noarg_options = target.with_kotlinc_plugin_noarg|reject('startsWith', 'preset=')|reject('startsWith', 'annotation=')|reject('eq', 'default') %}
+{%- set noarg_options = with_kotlinc_plugin_noarg|reject('startsWith', 'preset=')|reject('startsWith', 'annotation=')|reject('eq', 'default') %}
noArg {
{%- if noarg_options|length -%}
diff --git a/build/export_generators/ide-gradle/kotlinc_flags.jinja b/build/export_generators/ide-gradle/kotlinc_flags.jinja
index 3f6c8d90ad1..0aa895f668f 100644
--- a/build/export_generators/ide-gradle/kotlinc_flags.jinja
+++ b/build/export_generators/ide-gradle/kotlinc_flags.jinja
@@ -1,18 +1,18 @@
{%- if with_kotlin -%}
{%- set kotlinc_flags = [] -%}
-{%- if task.kotlinc.flags|length -%}
-{%- set kotlinc_flags = kotlinc_flags -%}
+{%- if target.kotlinc.flags|length -%}
+{%- set kotlinc_flags = target.kotlinc.flags|unique -%}
{%- endif -%}
{%- set extra_kotlinc_flags = extra_targets|selectattr('kotlinc')|map(attribute='kotlinc')|map(attribute='flags')|sum -%}
{%- if extra_kotlinc_flags|length -%}
-{%- set kotlinc_flags = kotlinc_flags + extra_kotlinc_flags -%}
+{%- set kotlinc_flags = kotlinc_flags + extra_kotlinc_flags|unique -%}
{%- endif -%}
{%- if kotlinc_flags|length %}
-tasks.withType<KotlinCompile> {
+tasks.withType<KotlinCompile>() {
compilerOptions {
{%- for kotlinc_flag in kotlinc_flags|unique %}
- freeCompilerArgs.add("{{ kotlinc_flag|replace(export_root, "$arcadia_root")|replace(arcadia_root, "$arcadia_root") }}")
+ freeCompilerArgs.add({{ PatchRoots(kotlinc_flag, true) }})
{%- endfor %}
}
}
diff --git a/build/export_generators/ide-gradle/proto_vars.jinja b/build/export_generators/ide-gradle/proto_vars.jinja
index 5b3cfb6425d..6daaa87975b 100644
--- a/build/export_generators/ide-gradle/proto_vars.jinja
+++ b/build/export_generators/ide-gradle/proto_vars.jinja
@@ -1,8 +1,5 @@
-{%- set publish = target.publish -%}
-{%- set with_kotlin = target.with_kotlin -%}
-{%- set kotlin_version = target.kotlin_version -%}
+{%- include "[generator]/common_vars.jinja" -%}
+
{%- set prepareProtosTask = target.proto_files|length or target.runs|length or target.custom_runs|length -%}
{%- set libraries = target.consumer|selectattr('type', 'eq', 'library') -%}
{%- set extractLibrariesProtosTask = libraries|length -%}
-
-{%- include "[generator]/jdk.jinja" -%}
diff --git a/build/export_generators/ide-gradle/vars.jinja b/build/export_generators/ide-gradle/vars.jinja
index 26f7e3621c7..f7bb31c3849 100644
--- a/build/export_generators/ide-gradle/vars.jinja
+++ b/build/export_generators/ide-gradle/vars.jinja
@@ -1,8 +1,4 @@
+{%- include "[generator]/common_vars.jinja" -%}
+
{%- set mainClass = target.app_main_class -%}
-{%- set publish = target.publish -%}
-{%- set with_kotlin = target.with_kotlin -%}
-{%- set kotlin_version = target.kotlin_version -%}
{%- set has_junit5_test = extra_targets|selectattr('junit5_test') -%}
-{%- set has_errorprone = target.use_errorprone and not disable_errorprone and target.consumer|selectattr('jar', 'startsWith', 'contrib/java/com/google/errorprone/error_prone_annotations')|length -%}
-
-{%- include "[generator]/jdk.jinja" -%}