diff options
author | dimdim11 <dimdim11@yandex-team.com> | 2025-04-17 11:14:11 +0300 |
---|---|---|
committer | dimdim11 <dimdim11@yandex-team.com> | 2025-04-17 11:30:32 +0300 |
commit | b5d022f593ab3b71524452c0f9238d422eabbf93 (patch) | |
tree | f05fcbabc0135e1ef668f88e0e5ed40ccfba2194 | |
parent | ff9836d484554edbf66dfb4c6bf846d828aea79f (diff) | |
download | ydb-b5d022f593ab3b71524452c0f9238d422eabbf93.tar.gz |
Cut classpath by common_dir
Cut classpath by common_dir
commit_hash:d49342ba8eea0705b4965f0c1ad7b9ac7bd9f8f3
13 files changed, 61 insertions, 31 deletions
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 2bff0ca3932..aa14d715ad0 100644 --- a/build/export_generators/ide-gradle/build.gradle.kts.any.jinja +++ b/build/export_generators/ide-gradle/build.gradle.kts.any.jinja @@ -3,16 +3,16 @@ {#- That is why all common macroses here -#} {%- macro PatchRoots(arg, depend = false, output = false) -%} -{#- Always replace (arcadia_root) === (SOURCE_ROOT in ymake) to $project_root in Gradle -#} +{#- Always replace (arcadia_root) === (SOURCE_ROOT in ymake) to $arcadia_root in Gradle -#} {%- if depend -%} -{#- Replace (export_root) === (BUILD_ROOT in ymake) to $project_root in Gradle, because prebuilt tools in arcadia, not in build_root -#} -"{{ arg|replace(export_root, "$project_root")|replace(arcadia_root, "$project_root") }}" +{#- Replace (export_root) === (BUILD_ROOT in ymake) to $arcadia_root in Gradle, because prebuilt tools in arcadia, not in build_root -#} +"{{ arg|replace(export_root, "$arcadia_root")|replace(arcadia_root, "$arcadia_root") }}" {%- elif output and arg[0] != '/' -%} {#- Relative outputs in buildDir -#} "$buildDir/{{ arg }}" {%- else -%} {#- Replace (export_root) === (BUILD_ROOT in ymake) to baseBuildDir in Gradle - root of all build folders for modules -#} -"{{ arg|replace(export_root, "$baseBuildDir")|replace(arcadia_root, "$project_root") }}" +"{{ arg|replace(export_root, "$baseBuildDir")|replace(arcadia_root, "$arcadia_root") }}" {%- endif -%} {%- endmacro -%} @@ -26,6 +26,8 @@ {%- endmacro -%} {%- endif -%} +{%- include "[generator]/common_dir.jinja" -%} + {%- if proto_template -%} {%- include "[generator]/proto_vars.jinja" -%} {%- include "[generator]/proto_import.jinja" -%} diff --git a/build/export_generators/ide-gradle/builddir.jinja b/build/export_generators/ide-gradle/builddir.jinja index 88a5694d157..9ee3cd071d4 100644 --- a/build/export_generators/ide-gradle/builddir.jinja +++ b/build/export_generators/ide-gradle/builddir.jinja @@ -1,6 +1,6 @@ {#- empty string #} val baseBuildDir = "{{ export_root }}/gradle.build" -buildDir = file(baseBuildDir + "/" + project.path.replace(":", "/")) +buildDir = file(baseBuildDir + "{%- if common_dir %}/{{ common_dir }}{% endif -%}/" + project.path.replace(":", "/")) subprojects { - buildDir = file(baseBuildDir + "/" + project.path.replace(":", "/")) + buildDir = file(baseBuildDir + "{%- if common_dir %}/{{ common_dir }}{% endif -%}/" + project.path.replace(":", "/")) } diff --git a/build/export_generators/ide-gradle/codegen.jinja b/build/export_generators/ide-gradle/codegen.jinja index 3950c9aa166..4df2ad85a59 100644 --- a/build/export_generators/ide-gradle/codegen.jinja +++ b/build/export_generators/ide-gradle/codegen.jinja @@ -2,22 +2,28 @@ {%- if proto_template %} tasks.getByName("prepareMainProtos").dependsOn({{ taskvar }}) -{%- endif %} +{%- endif -%} +{#- Check main target codegen -#} +{%- if varprefix == "codegen" %} tasks.compileJava.configure { dependsOn({{ taskvar }}) } +{%- endif %} tasks.compileTestJava.configure { dependsOn({{ taskvar }}) } -{%- if with_kotlin %} +{%- if with_kotlin -%} +{#- Check main target codegen -#} +{%- if varprefix == "codegen" %} tasks.compileKotlin.configure { dependsOn({{ taskvar }}) } +{%- endif %} tasks.compileTestKotlin.configure { dependsOn({{ taskvar }}) } -{% endif -%} +{% endif -%} {%- endmacro -%} {%- macro ObjDepends(obj) -%} @@ -33,11 +39,13 @@ tasks.getByName("{{ parent_taskvar }}").dependsOn({{ taskvar }}) {%- if target is defined -%} {%- set current_target = target -%} +{#- Main target codegen -#} {%- set varprefix = "codegen" -%} {%- include "[generator]/codegen_current_target.jinja" -%} {%- endif -%} {%- if extra_targets|length -%} {%- for current_target in extra_targets -%} +{#- TestN target codegen -#} {%- set varprefix = "test" + loop.index0|tojson + "Codegen" -%} {%- include "[generator]/codegen_current_target.jinja" -%} {%- endfor -%} diff --git a/build/export_generators/ide-gradle/codegen_run_java_program.jinja b/build/export_generators/ide-gradle/codegen_run_java_program.jinja index e3604f85e62..87fb1bedeaa 100644 --- a/build/export_generators/ide-gradle/codegen_run_java_program.jinja +++ b/build/export_generators/ide-gradle/codegen_run_java_program.jinja @@ -17,7 +17,7 @@ val {{ varprefix }}{{ run['_object_index'] }} = task<JavaExec>("{{ varprefix }}{ {% for classpath in classpaths -%} {%- set rel_file_classpath = classpath|replace('@', '')|replace(export_root, '')|replace(arcadia_root, '') %} - val classpaths = "$project_root/" + File("$project_root{{ rel_file_classpath }}").readText().trim().replace(":", ":$project_root/") + val classpaths = "$arcadia_root/" + File("$arcadia_root{{ rel_file_classpath }}").readText().trim().replace(":", ":$arcadia_root/") classpath = files(classpaths.split(":")) {%- endfor -%} {%- endif %} diff --git a/build/export_generators/ide-gradle/common_dir.jinja b/build/export_generators/ide-gradle/common_dir.jinja new file mode 100644 index 00000000000..a9106fb926e --- /dev/null +++ b/build/export_generators/ide-gradle/common_dir.jinja @@ -0,0 +1,5 @@ +{%- if common_dir -%} +{%- set common_dir_classpath = '":' + common_dir|replace("/", ":") -%} +{%- else -%} +{%- set common_dir_classpath = false -%} +{%- endif -%} diff --git a/build/export_generators/ide-gradle/configuration.jinja b/build/export_generators/ide-gradle/configuration.jinja index b238ca95bfa..c049cba2dc5 100644 --- a/build/export_generators/ide-gradle/configuration.jinja +++ b/build/export_generators/ide-gradle/configuration.jinja @@ -1,5 +1,6 @@ {#- empty string #} -val project_root = "{{ arcadia_root }}" +val arcadia_root = "{{ arcadia_root }}" +val project_root = "{{ project_root }}" {% if mainClass -%} application { diff --git a/build/export_generators/ide-gradle/dependencies.jinja b/build/export_generators/ide-gradle/dependencies.jinja index a869975b766..d5958c36acc 100644 --- a/build/export_generators/ide-gradle/dependencies.jinja +++ b/build/export_generators/ide-gradle/dependencies.jinja @@ -2,11 +2,11 @@ {%- if annotation_processors|length -%} {%- set lomboks = annotation_processors|select('startsWith', 'contrib/java/org/projectlombok/lombok') -%} {%- for lombok in lomboks %} - {{ funcName }}(files("$project_root/{{ lombok }}")) + {{ funcName }}(files("$arcadia_root/{{ lombok }}")) {%- endfor -%} {%- set annotation_processors = annotation_processors|reject('in', lomboks) -%} {%- for annotation_processor in annotation_processors %} - {{ funcName }}(files("$project_root/{{ annotation_processor }}")) + {{ funcName }}(files("$arcadia_root/{{ annotation_processor }}")) {%- endfor -%} {%- endif -%} {%- endmacro -%} @@ -22,15 +22,18 @@ dependencies { {%- endif -%} {%- if library.prebuilt and library.jar and (library.type != "contrib" or build_contribs) %} - implementation(files("$project_root/{{ library.jar }}")) + implementation(files("$arcadia_root/{{ library.jar }}")) {%- else -%} {%- set classpath = library.classpath -%} {%- if classpath|replace('"','') == classpath -%} {%- set classpath = '"' + classpath + '"' -%} {%- endif -%} +{%- include "[generator]/patch_classpath.jinja" -%} {%- if library.type != "contrib" %} -{%- if library.testdep %} - implementation(project(path = ":{{ library.testdep | replace("/", ":") }}", configuration = "testArtifacts")) +{%- if library.testdep -%} +{%- set classpath = '":' + library.testdep | replace("/", ":") + '"' -%} +{%- include "[generator]/patch_classpath.jinja" %} + implementation(project(path = {{ classpath }}, configuration = "testArtifacts")) {%- else %} implementation({{ classpath }}) {%- endif -%} @@ -53,14 +56,17 @@ dependencies { {%- 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 }}")) + testImplementation(files("$arcadia_root/{{ library.jar }}")) {%- else -%} {%- set classpath = library.classpath -%} {%- if classpath|replace('"','') == classpath -%} {%- set classpath = '"' + classpath + '"' -%} {%- endif %} -{%- if library.type != "contrib" and library.testdep %} - testImplementation(project(path = ":{{ library.testdep | replace("/", ":") }}", configuration = "testArtifacts")) +{%- include "[generator]/patch_classpath.jinja" -%} +{%- if library.type != "contrib" and library.testdep -%} +{%- set classpath = '":' + library.testdep | replace("/", ":") + '"' -%} +{%- include "[generator]/patch_classpath.jinja" %} + testImplementation(project(path = {{ classpath }}, configuration = "testArtifacts")) {%- else %} testImplementation({{ classpath }}) {%- endif -%} diff --git a/build/export_generators/ide-gradle/kotlinc_flags.jinja b/build/export_generators/ide-gradle/kotlinc_flags.jinja index fce0eecfcf7..3f6c8d90ad1 100644 --- a/build/export_generators/ide-gradle/kotlinc_flags.jinja +++ b/build/export_generators/ide-gradle/kotlinc_flags.jinja @@ -12,7 +12,7 @@ tasks.withType<KotlinCompile> { compilerOptions { {%- for kotlinc_flag in kotlinc_flags|unique %} - freeCompilerArgs.add("{{ kotlinc_flag|replace(export_root, "$project_root")|replace(arcadia_root, "$project_root") }}") + freeCompilerArgs.add("{{ kotlinc_flag|replace(export_root, "$arcadia_root")|replace(arcadia_root, "$arcadia_root") }}") {%- endfor %} } } diff --git a/build/export_generators/ide-gradle/patch_classpath.jinja b/build/export_generators/ide-gradle/patch_classpath.jinja new file mode 100644 index 00000000000..c653e7b1e06 --- /dev/null +++ b/build/export_generators/ide-gradle/patch_classpath.jinja @@ -0,0 +1,3 @@ +{%- if common_dir_classpath -%} +{%- set classpath = classpath|replace(common_dir_classpath, '"') -%} +{%- endif -%} diff --git a/build/export_generators/ide-gradle/proto_configuration.jinja b/build/export_generators/ide-gradle/proto_configuration.jinja index 5a9554b2aeb..c2cf9d24592 100644 --- a/build/export_generators/ide-gradle/proto_configuration.jinja +++ b/build/export_generators/ide-gradle/proto_configuration.jinja @@ -1,5 +1,6 @@ {#- empty string #} -val project_root = "{{ arcadia_root }}" +val arcadia_root = "{{ arcadia_root }}" +val project_root = "{{ project_root }}" java { withSourcesJar() diff --git a/build/export_generators/ide-gradle/proto_dependencies.jinja b/build/export_generators/ide-gradle/proto_dependencies.jinja index 61bcc05fa98..dc3ca68e4be 100644 --- a/build/export_generators/ide-gradle/proto_dependencies.jinja +++ b/build/export_generators/ide-gradle/proto_dependencies.jinja @@ -2,12 +2,13 @@ dependencies { {%- 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 }}")) + implementation(files("$arcadia_root/{{ library.jar }}")) {%- else -%} {%- set classpath = library.classpath -%} {%- if classpath|replace('"','') == classpath -%} {%- set classpath = '"' + classpath + '"' -%} {%- endif %} +{%- include "[generator]/patch_classpath.jinja" -%} {%- if library.type != "contrib" %} implementation {%- else %} diff --git a/build/export_generators/ide-gradle/proto_prepare.jinja b/build/export_generators/ide-gradle/proto_prepare.jinja index 804428a964e..7be93a58c35 100644 --- a/build/export_generators/ide-gradle/proto_prepare.jinja +++ b/build/export_generators/ide-gradle/proto_prepare.jinja @@ -2,7 +2,7 @@ val prepareMainProtos = tasks.register<Copy>("prepareMainProtos") { {%- if target.proto_files|length %} - from("$project_root") { + from("$arcadia_root") { {#- list of all current project proto files -#} {%- for proto in target.proto_files %} include("{{ proto }}") @@ -30,11 +30,11 @@ val prepareMainProtos = tasks.register<Copy>("prepareMainProtos") { } {%- endif -%} -{%- if extractLibrariesProtosTask -%} +{%- if extractLibrariesProtosTask %} val extractMainLibrariesProtos = tasks.register<Copy>("extractMainLibrariesProtos") { -{%- if libraries|length -%} - from("$project_root") { +{%- if libraries|length %} + from("$arcadia_root") { {#- list of all library directories -#} {%- for library in libraries -%} {%- set path_and_jar = rsplit(library.jar, '/', 2) %} diff --git a/build/export_generators/ide-gradle/settings.gradle.kts.jinja b/build/export_generators/ide-gradle/settings.gradle.kts.jinja index 68bb5b594d9..865019f9017 100644 --- a/build/export_generators/ide-gradle/settings.gradle.kts.jinja +++ b/build/export_generators/ide-gradle/settings.gradle.kts.jinja @@ -1,12 +1,15 @@ +{%- include "[generator]/common_dir.jinja" -%} rootProject.name = "{{ project_name }}" - {% for subdir in subdirs -%} {%- set arcadia_subdir = arcadia_root + "/" + subdir -%} {%- if arcadia_subdir != project_root -%} -{%- set classname = subdir | replace("/", ":") %} -include(":{{ classname }}") -project(":{{ classname }}").projectDir = file("{{ arcadia_subdir }}") -{% endif -%} +{%- set classpath = '":' + subdir | replace("/", ":") + '"' -%} +{%- include "[generator]/patch_classpath.jinja" %} +include({{ classpath }}) +{%- if not common_dir_classpath %} +project({{ classpath }}).projectDir = file("{{ arcadia_subdir }}") +{%- endif -%} +{%- endif -%} {%- endfor -%} {%- include "[generator]/debug.jinja" ignore missing -%} |