diff options
author | dimdim11 <dimdim11@yandex-team.com> | 2024-12-19 13:32:43 +0300 |
---|---|---|
committer | dimdim11 <dimdim11@yandex-team.com> | 2024-12-19 14:32:23 +0300 |
commit | dad376b2660dbf622273e9b09b80c50e987c8e2d (patch) | |
tree | 33076bab95608b9fdbf0a4cbb0762e2e578f5ff3 | |
parent | 96985fad77de4f87604398f5787a1df39de18ccc (diff) | |
download | ydb-dad376b2660dbf622273e9b09b80c50e987c8e2d.tar.gz |
Patch and use jdk_version, jdk_path semantics
Patch and use jdk_version, jdk_path semantics
commit_hash:1e3c09f57ec484bba88fb8991fc5a00f6fd4df9b
7 files changed, 46 insertions, 15 deletions
diff --git a/build/export_generators/ide-gradle/jdk.jinja b/build/export_generators/ide-gradle/jdk.jinja new file mode 100644 index 0000000000..79df30fe91 --- /dev/null +++ b/build/export_generators/ide-gradle/jdk.jinja @@ -0,0 +1,28 @@ +{%- set jdk_version = false -%} +{%- if target.required_jdk -%} +{%- set jdk_version = target.required_jdk -%} +{%- elif target.jdk_version -%} +{%- set jdk_version = target.jdk_version -%} +{%- elif not target and extra_targets|length -%} +{%- set jdk_version_targets = extra_targets|selectattr('jdk_version') -%} +{%- if jdk_version_targets|length -%} +{%- set jdk_version_target = jdk_version_targets|first -%} +{%- set jdk_version = jdk_version_target.jdk_version -%} +{%- else -%} +{%- set jdk_version = '17' -%} +{%- endif -%} +{%- else -%} +{%- set jdk_version = '17' -%} +{%- endif -%} + +{%- set jdk_path = false -%} +{%- if target.jdk_path and target.jdk_path != "NOT_FOUND" -%} +{%- set jdk_path = target.jdk_path -%} +{#- If no main target, but exists extra_targets -#} +{%- elif not target and extra_targets|length -%} +{%- set jdk_path_targets = extra_targets|selectattr('jdk_path')|rejectattr('jdk_path', 'eq', 'NOT_FOUND') -%} +{%- if jdk_path_targets|length -%} +{%- set jdk_path_target = jdk_path_targets|first -%} +{%- set jdk_path = jdk_path_target.jdk_path -%} +{%- endif -%} +{%- endif -%} diff --git a/build/export_generators/ide-gradle/kotlin_plugins.jinja b/build/export_generators/ide-gradle/kotlin_plugins.jinja index df0f65de36..823fa5243d 100644 --- a/build/export_generators/ide-gradle/kotlin_plugins.jinja +++ b/build/export_generators/ide-gradle/kotlin_plugins.jinja @@ -59,6 +59,6 @@ noArg { {%- if with_kotlin %} kotlin { - jvmToolchain({{ required_jdk }}) + jvmToolchain({{ jdk_version }}) } {% endif -%} diff --git a/build/export_generators/ide-gradle/plugins.jinja b/build/export_generators/ide-gradle/plugins.jinja index 13a46003be..25768f55ee 100644 --- a/build/export_generators/ide-gradle/plugins.jinja +++ b/build/export_generators/ide-gradle/plugins.jinja @@ -35,12 +35,11 @@ plugins { {%- endif %} } -{#- language level -#} -{%- if has_required_jdk %} +{%- if jdk_version %} java { toolchain { - languageVersion = JavaLanguageVersion.of("{{ required_jdk }}") + languageVersion = JavaLanguageVersion.of("{{ jdk_version }}") } } -{%- endif -%} +{% endif -%} diff --git a/build/export_generators/ide-gradle/preview.jinja b/build/export_generators/ide-gradle/preview.jinja index 18aa8fcd2d..5864b5171d 100644 --- a/build/export_generators/ide-gradle/preview.jinja +++ b/build/export_generators/ide-gradle/preview.jinja @@ -3,7 +3,7 @@ tasks.withType<JavaCompile> { options.compilerArgs.add("--enable-preview") options.compilerArgs.add("-Xlint:preview") - options.release.set({{ required_jdk }}) + options.release.set({{ jdk_version }}) } tasks.withType<JavaExec> { @@ -17,7 +17,7 @@ tasks.withType<Test> { tasks.withType<Javadoc> { val javadocOptions = options as CoreJavadocOptions - javadocOptions.addStringOption("source", "{{ required_jdk }}") + javadocOptions.addStringOption("source", "{{ jdk_version }}") javadocOptions.addBooleanOption("-enable-preview", true) } {% endif -%} diff --git a/build/export_generators/ide-gradle/proto_plugins.jinja b/build/export_generators/ide-gradle/proto_plugins.jinja index a5bb76d758..655614672d 100644 --- a/build/export_generators/ide-gradle/proto_plugins.jinja +++ b/build/export_generators/ide-gradle/proto_plugins.jinja @@ -7,3 +7,12 @@ plugins { `signing` {%- endif %} } + +{%- if jdk_version %} + +java { + toolchain { + languageVersion = JavaLanguageVersion.of("{{ jdk_version }}") + } +} +{%- endif -%} diff --git a/build/export_generators/ide-gradle/proto_vars.jinja b/build/export_generators/ide-gradle/proto_vars.jinja index 45fa6d7bb7..761c74b070 100644 --- a/build/export_generators/ide-gradle/proto_vars.jinja +++ b/build/export_generators/ide-gradle/proto_vars.jinja @@ -1,2 +1,4 @@ {%- set publish = target.publish -%} {%- set libraries = target.consumer|selectattr('type', 'eq', 'library') -%} + +{%- include "[generator]/jdk.jinja" -%} diff --git a/build/export_generators/ide-gradle/vars.jinja b/build/export_generators/ide-gradle/vars.jinja index d8722a2b42..26f7e3621c 100644 --- a/build/export_generators/ide-gradle/vars.jinja +++ b/build/export_generators/ide-gradle/vars.jinja @@ -5,11 +5,4 @@ {%- 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 -%} -{%- if not target.required_jdk -%} -{%- set has_required_jdk = false -%} -{#- If no required JDK, set default JDK for Kotlin parts -#} -{%- set required_jdk = '17' -%} -{%- else -%} -{%- set has_required_jdk = true -%} -{%- set required_jdk = target.required_jdk -%} -{%- endif -%} +{%- include "[generator]/jdk.jinja" -%} |