diff options
author | dimdim11 <dimdim11@yandex-team.com> | 2024-01-31 15:18:51 +0300 |
---|---|---|
committer | Alexander Smirnov <alex@ydb.tech> | 2024-02-09 19:16:36 +0300 |
commit | ebe90bfe4858d1e0859978316a2154bc47a3f865 (patch) | |
tree | 26082acb714753812c6b1c6ae4b950ad39c83b0d | |
parent | b35f714f9f7356e2b91ce31ceda6faeec7fd2a45 (diff) | |
download | ydb-ebe90bfe4858d1e0859978316a2154bc47a3f865.tar.gz |
Add target and extra_targets, remove unused Targets_, recanonize tests
Add target and extra_targets, remove unused Targets_, recanonize tests
4 files changed, 154 insertions, 146 deletions
diff --git a/build/export_generators/gradle/build.gradle.kts.jinja b/build/export_generators/gradle/build.gradle.kts.jinja index 1106967749..7a31811ffa 100644 --- a/build/export_generators/gradle/build.gradle.kts.jinja +++ b/build/export_generators/gradle/build.gradle.kts.jinja @@ -1,75 +1,78 @@ +{%- set target = targets[0] -%} +{%- set extra_targets = targets|selectattr('isTest') -%} +{%- set publish = target.publish -%} +{%- set mainClass = target.app_main_class -%} +{%- set hasJunit5Test = extra_targets|selectattr('junit5_test') -%} plugins { -{% if targets|selectattr("app_main_class") -%} +{% if mainClass -%} `application` -{% else -%} +{% else -%} `java-library` -{% endif -%} -{% if targets|selectattr('publish') -%} +{% endif -%} +{% if publish -%} `maven-publish` `signing` -{% endif -%} +{% endif -%} } -{% if targets|selectattr('publish') -%} -group = "{{ targets[0].publish_group }}" +{% if publish -%} +group = "{{ target.publish_group }}" version = project.properties["version"] -{% endif -%} +{% endif -%} repositories { mavenCentral() } -{% if targets|selectattr("app_main_class") -%} +{% if mainClass -%} application { -{% for target in targets|selectattr("app_main_class") -%} - mainClass.set("{{ target.app_main_class }}") -{% endfor -%} + mainClass.set("{{ mainClass }}") } -{% endif -%} +{% endif -%} java { withSourcesJar() withJavadocJar() } dependencies { -{% for target in targets -%} -{% if target.junit5_test -%} +{% if hasJunit5Test -%} testImplementation("org.junit.jupiter:junit-jupiter:5.8.2") - api("org.apache.commons:commons-math3:3.6.1") - api("com.google.guava:guava:31.0.1-jre") -{% endif -%} -{% for library in target.consumer -%} -{% set classpath = library.classpath -%} -{% if targets|selectattr("app_main_class") -%} -{% if library.excludes.consumer is defined %} +{% endif -%} +{% for library in target.consumer -%} +{% set classpath = library.classpath -%} +{% if mainClass -%} +{% if library.excludes.consumer is defined %} implementation({{ classpath }}) { -{% for exclude in library.excludes.consumer if exclude.classpath -%} -{% set classpath = exclude.classpath|replace('"','') -%} -{% set classpath_parts = split(classpath, ':') -%} +{% for exclude in library.excludes.consumer if exclude.classpath -%} +{% set classpath = exclude.classpath|replace('"','') -%} +{% set classpath_parts = split(classpath, ':') -%} exclude(group = "{{ classpath_parts[0] }}", module = "{{ classpath_parts[1] }}") -{% endfor -%} +{% endfor -%} } -{% else -%} +{% else -%} implementation({{ classpath }}) -{% endif -%} -{% elif target.isTest -%} - testImplementation({{ classpath }}) -{% else -%} +{% endif -%} +{% else -%} api({{ classpath }}) -{% endif -%} -{% endfor -%} -{% endfor -%} +{% endif -%} +{% endfor -%} +{% for extra_target in extra_targets -%} +{% for library in extra_target.consumer -%} +{% set classpath = library.classpath -%} + testImplementation({{ classpath }}) +{% endfor -%} +{% endfor -%} } -{% if targets|selectattr("junit5_test") -%} +{% if hasJunit5Test -%} tasks.named<Test>("test") { useJUnitPlatform() } -{% endif -%} +{% endif -%} tasks.test { testLogging { showStandardStreams = true @@ -77,7 +80,7 @@ tasks.test { } } -{% include "extra-tests.gradle.kts" ignore missing %} -{% if targets|selectattr('publish') -%} -{% include 'publish.gradle.kts' -%} -{% endif -%} +{% include "extra-tests.gradle.kts" ignore missing %} +{% if publish -%} +{% include 'publish.gradle.kts' -%} +{% endif -%} diff --git a/build/export_generators/gradle/build.gradle.kts.proto.jinja b/build/export_generators/gradle/build.gradle.kts.proto.jinja index 43e6ec3529..d4ad5874cd 100644 --- a/build/export_generators/gradle/build.gradle.kts.proto.jinja +++ b/build/export_generators/gradle/build.gradle.kts.proto.jinja @@ -1,3 +1,5 @@ +{%- set target = targets[0] -%} +{%- set publish = target.publish -%} import com.google.protobuf.gradle.* val buildProtoDir = File("${buildDir}", "__proto__") @@ -5,16 +7,16 @@ val buildProtoDir = File("${buildDir}", "__proto__") plugins { id("java-library") id("com.google.protobuf") version "0.8.19" -{% if targets|selectattr('publish') -%} +{% if publish -%} `maven-publish` `signing` -{% endif -%} +{% endif -%} } -{% if targets|selectattr('publish') -%} -group = "{{ targets[0].publish_group }}" +{% if publish -%} +group = "{{ target.publish_group }}" version = project.properties["version"] -{% endif -%} +{% endif -%} repositories { mavenCentral() @@ -26,31 +28,28 @@ java { } dependencies { -{% if targets[0].consumer is defined -%} -{%- for library in targets[0].consumer -%} +{%- for library in target.consumer %} api({{ library.classpath }}) -{% endfor -%} -{%- endif -%} - -{% if targets[0].proto_namespace is defined -%} - protobuf(files(File(buildProtoDir, "{{ targets[0].proto_namespace }}"))) -{% else -%} +{%- endfor %} +{% if target.proto_namespace %} + protobuf(files(File(buildProtoDir, "{{ target.proto_namespace }}"))) +{%- else %} protobuf(files(buildProtoDir)) -{% endif -%} +{%- endif %} } protobuf { protoc { // Download from repositories artifact = "com.google.protobuf:protoc: -{%- if targets[0].proto_compiler_version is defined -%} -{{ targets[0].proto_compiler_version }} +{%- if target.proto_compiler_version -%} +{{ target.proto_compiler_version }} {%- else -%} 3.22.5 {%- endif -%} " } -{% if targets[0].proto_grpc is defined -%} +{% if target.proto_grpc -%} plugins { id("grpc") { artifact = "io.grpc:protoc-gen-grpc-java:1.45.0" @@ -68,9 +67,9 @@ protobuf { val prepareProto = tasks.register<Copy>("prepareProto") { from(rootDir) { -{% for proto in targets[0].proto_files -%} +{% for proto in target.proto_files -%} include("{{ proto }}") -{% endfor -%} +{% endfor -%} } into(buildProtoDir) } @@ -78,6 +77,6 @@ val prepareProto = tasks.register<Copy>("prepareProto") { afterEvaluate { tasks.getByName("extractProto").dependsOn(prepareProto) } -{% if targets|selectattr('publish') -%} -{% include 'publish.gradle.kts' -%} -{% endif -%} +{% if publish -%} +{% include 'publish.gradle.kts' -%} +{% endif -%} diff --git a/build/export_generators/ide-gradle/build.gradle.kts.jinja b/build/export_generators/ide-gradle/build.gradle.kts.jinja index 79d8b1b501..3e96fecdf1 100644 --- a/build/export_generators/ide-gradle/build.gradle.kts.jinja +++ b/build/export_generators/ide-gradle/build.gradle.kts.jinja @@ -1,11 +1,12 @@ -{%- set mainClassTargets = targets|selectattr("app_main_class") -%} -{%- set publish = targets|selectattr('publish') -%} -{%- set hasJunit5Test = targets|selectattr('junit5_test') -%} -{%- set target0 = targets[0] -%} -{%- set with_kotlin = target0.with_kotlin -%} -{%- set kotlin_version = target0.kotlin_version -%} +{%- set target = targets[0] -%} +{%- set extra_targets = targets|selectattr('isTest') -%} +{%- set mainClass = target.app_main_class -%} +{%- set publish = target.publish -%} +{%- set with_kotlin = target.with_kotlin -%} +{%- set kotlin_version = target.kotlin_version -%} +{%- set hasJunit5Test = extra_targets|selectattr('junit5_test') -%} plugins { -{%- if mainClassTargets %} +{%- if mainClass %} `application` {%- else %} `java-library` @@ -16,21 +17,21 @@ plugins { {%- endif -%} {%- if with_kotlin and kotlin_version %} kotlin("jvm") version "{{ kotlin_version }}" -{%- if target0.with_kotlinc_plugin_allopen %} +{%- if target.with_kotlinc_plugin_allopen %} kotlin("plugin.allopen") version "{{ kotlin_version }}" {% endif -%} -{%- if target0.with_kotlinc_plugin_lombok %} +{%- if target.with_kotlinc_plugin_lombok %} kotlin("plugin.lombok") version "{{ kotlin_version }}" {% endif -%} -{%- if target0.with_kotlinc_plugin_noarg %} +{%- if target.with_kotlinc_plugin_noarg %} kotlin("plugin.noarg") version "{{ kotlin_version }}" {% endif -%} -{%- if target0.with_kotlinc_plugin_serialization %} +{%- if target.with_kotlinc_plugin_serialization %} kotlin("plugin.serialization") version "{{ kotlin_version }}" {% endif -%} {%- endif %} } -{%- if target0.with_kotlinc_plugin_allopen %} +{%- if target.with_kotlinc_plugin_allopen %} allOpen { annotation("org.springframework.stereotype.Component") @@ -39,13 +40,13 @@ allOpen { {%- if with_kotlin %} kotlin { - jvmToolchain({%- if target0.required_jdk -%}{{ target0.required_jdk }}{%- else -%}17{%- endif -%}) + jvmToolchain({%- if target.required_jdk -%}{{ target.required_jdk }}{%- else -%}17{%- endif -%}) } {% endif -%} {%- if publish %} -group = "{{ target0.publish_group }}" -version = {% if target0.publish_version and target0.publish_version != "no" -%}"{{ target0.publish_version }}"{%- else -%}project.properties["version"]{%- endif %} +group = "{{ target.publish_group }}" +version = {% if target.publish_version and target.publish_version != "no" -%}"{{ target.publish_version }}"{%- else -%}project.properties["version"]{%- endif %} {% endif %} repositories { @@ -54,11 +55,9 @@ repositories { val project_root="{%- if exportRoot.startswith(arcadiaRoot + '/') -%}{{ arcadiaRoot }}{%- else -%}{{ exportRoot }}{%- endif -%}" -{% if mainClassTargets -%} +{% if mainClass -%} application { -{%- for target in mainClassTargets %} - mainClass.set("{{ target.app_main_class }}") -{% endfor -%} + mainClass.set("{{ mainClass }}") } {% endif -%} @@ -97,9 +96,16 @@ tasks.test { {% endif -%} -{% for target in targets -%} -{%- if target.jar_source_set is defined -%} -{%- for source_set in target.jar_source_set -%} +{%- if target.jar_source_set is defined -%} +{%- for source_set in target.jar_source_set -%} +{%- set srcdir_glob = split(source_set, ':') -%} +sourceSets.main.java.srcDirs += "{{ srcdir_glob[0] }}" +{% endfor -%} +{%- endif -%} + +{% for extra_target in extra_targets -%} +{%- if extra_target.jar_source_set is defined -%} +{%- for source_set in extra_target.jar_source_set -%} {%- set srcdir_glob = split(source_set, ':') -%} sourceSets.main.java.srcDirs += "{{ srcdir_glob[0] }}" {% endfor -%} @@ -107,34 +113,44 @@ sourceSets.main.java.srcDirs += "{{ srcdir_glob[0] }}" {%- endfor -%} dependencies { -{%- for target in targets -%} -{%- for library in target.consumer if library.classpath -%} -{%- if library.prebuilt and library.jar and (library.type != "contrib" or build_contribs) -%} -{%- if target.isTest %} - testImplementation -{%- else %} - implementation -{%- endif -%}(files("$project_root/{{ library.jar }}")) -{%- else -%} -{%- if target.isTest %} -{%- if library.type != "contrib" and library.test2test %} - testImplementation(project(path = ":{{ library.test2test | replace("/", ":") }}", configuration = "testArtifacts")) -{%- else %} - testImplementation({{ library.classpath }}) -{%- endif %} -{%- elif library.type != "contrib" %} +{%- for library in target.consumer if library.classpath -%} +{%- if library.prebuilt and library.jar and (library.type != "contrib" or build_contribs) %} + implementation(files("$project_root/{{ library.jar }}")) +{%- else -%} +{%- if library.type != "contrib" %} implementation({{ library.classpath }}) -{%- else %} +{%- else %} api({{ library.classpath }}) -{%- endif -%} -{%- if library.excludes.consumer is defined %} { -{% for exclude in library.excludes.consumer if exclude.classpath -%} -{% set classpath = exclude.classpath|replace('"','') -%} -{% set classpath_parts = split(classpath, ':') -%} +{%- endif -%} +{%- if library.excludes.consumer is defined %} { +{% for exclude in library.excludes.consumer if exclude.classpath -%} +{% set classpath = exclude.classpath|replace('"','') -%} +{% set classpath_parts = split(classpath, ':') -%} + exclude(group = "{{ classpath_parts[0] }}", module = "{{ classpath_parts[1] }}") +{% endfor -%} + } +{%- endif -%} +{%- endif -%} +{%- endfor -%} + +{%- for extra_target in extra_targets -%} +{%- for library in extra_target.consumer if library.classpath -%} +{%- if library.prebuilt and library.jar and (library.type != "contrib" or build_contribs) %} + testImplementation(files("$project_root/{{ library.jar }}")) +{%- else -%} +{%- if library.type != "contrib" and library.test2test %} + testImplementation(project(path = ":{{ library.test2test | replace("/", ":") }}", configuration = "testArtifacts")) +{%- else %} + testImplementation({{ library.classpath }}) +{%- endif -%} +{%- if library.excludes.consumer is defined %} { +{% for exclude in library.excludes.consumer if exclude.classpath -%} +{% set classpath = exclude.classpath|replace('"','') -%} +{% set classpath_parts = split(classpath, ':') -%} exclude(group = "{{ classpath_parts[0] }}", module = "{{ classpath_parts[1] }}") -{% endfor -%} +{% endfor -%} } -{%- endif -%} +{%- endif -%} {%- endif -%} {%- endfor -%} {%- endfor %} diff --git a/build/export_generators/ide-gradle/build.gradle.kts.proto.jinja b/build/export_generators/ide-gradle/build.gradle.kts.proto.jinja index c7e15a8779..ec22f54680 100644 --- a/build/export_generators/ide-gradle/build.gradle.kts.proto.jinja +++ b/build/export_generators/ide-gradle/build.gradle.kts.proto.jinja @@ -1,5 +1,5 @@ -{%- set publish = targets|selectattr('publish') -%} -{%- set target0 = targets[0] -%} +{%- set target = targets[0] -%} +{%- set publish = target.publish -%} import com.google.protobuf.gradle.* val buildProtoDir = File("${buildDir}", "__proto__") @@ -14,8 +14,8 @@ plugins { } {%- if publish %} -group = "{{ target0.publish_group }}" -version = {% if target0.publish_version -%}"{{ target0.publish_version }}"{%- else -%}project.properties["version"]{%- endif %} +group = "{{ target.publish_group }}" +version = {% if target.publish_version -%}"{{ target.publish_version }}"{%- else -%}project.properties["version"]{%- endif %} {%- endif %} repositories { @@ -39,46 +39,36 @@ configurations.testImplementation { isTransitive = false } -{% for target in targets -%} -{%- if target.jar_source_set is defined -%} -{%- for source_set in target.jar_source_set -%} -{%- set srcdir_glob = split(source_set, ':') -%} +{%- if target.jar_source_set is defined -%} +{%- for source_set in target.jar_source_set -%} +{%- set srcdir_glob = split(source_set, ':') -%} sourceSets.main.java.srcDirs += "{{ srcdir_glob[0] }}" -{% endfor -%} -{%- endif -%} -{%- endfor -%} +{% endfor -%} +{%- endif -%} dependencies { -{%- for target in targets -%} -{%- for library in target.consumer if library.classpath -%} -{%- if library.prebuilt and library.jar and (library.type != "contrib" or target.handler.build_contribs) -%} -{%- if target.isTest %} - testImplementation -{%- else %} +{%- for library in target.consumer if library.classpath -%} +{%- if library.prebuilt and library.jar and (library.type != "contrib" or target.handler.build_contribs) %} + implementation(files("$project_root/{{ library.jar }}")) +{%- else -%} +{%- if library.type != "contrib" %} implementation -{%- endif -%}(files("$project_root/{{ library.jar }}")) -{%- else -%} -{%- if target.isTest %} - testImplementation -{%- elif library.type != "contrib" %} - implementation -{%- else %} +{%- else %} api -{%- endif -%}({{ library.classpath }}) -{%- if library.excludes.consumer is defined %} { -{% for exclude in library.excludes.consumer -%} -{% set classpath = exclude.classpath|replace('"','') -%} -{% set classpath_parts = split(classpath, ':') -%} +{%- endif -%}({{ library.classpath }}) +{%- if library.excludes.consumer is defined %} { +{% for exclude in library.excludes.consumer -%} +{% set classpath = exclude.classpath|replace('"','') -%} +{% set classpath_parts = split(classpath, ':') -%} exclude(group = "{{ classpath_parts[0] }}", module = "{{ classpath_parts[1] }}") -{% endfor -%} +{% endfor -%} } -{%- endif -%} {%- endif -%} -{%- endfor -%} +{%- endif -%} {%- endfor %} -{% if target0.proto_namespace is defined -%} - protobuf(files(File(buildProtoDir, "{{ target0.proto_namespace }}"))) +{% if target.proto_namespace -%} + protobuf(files(File(buildProtoDir, "{{ target.proto_namespace }}"))) {% else -%} protobuf(files(buildProtoDir)) {% endif -%} @@ -87,12 +77,12 @@ dependencies { protobuf { protoc { // Download from repositories - artifact = "com.google.protobuf:protoc:{%- if target0.proto_compiler_version is defined -%}{{ target0.proto_compiler_version }}{%- else -%}3.22.5{%- endif -%}" + artifact = "com.google.protobuf:protoc:{%- if target.proto_compiler_version -%}{{ target.proto_compiler_version }}{%- else -%}3.22.5{%- endif -%}" } -{% if target0.proto_grpc is defined -%} +{% if target.proto_grpc is defined -%} plugins { id("grpc") { - artifact = "io.grpc:protoc-gen-grpc-java:{%- if target0.proto_grpc_version -%}{{ target0.proto_grpc_version }}{%- else -%}1.45.0{%- endif -%}" + artifact = "io.grpc:protoc-gen-grpc-java:{%- if target.proto_grpc_version -%}{{ target.proto_grpc_version }}{%- else -%}1.45.0{%- endif -%}" } } generateProtoTasks { @@ -107,7 +97,7 @@ protobuf { val prepareProto = tasks.register<Copy>("prepareProto") { from(rootDir) { -{%- for proto in target0.proto_files %} +{%- for proto in target.proto_files %} include("{{ proto }}") {%- endfor %} } |