Skip to content

Commit b5d022f

Browse files
committed
Cut classpath by common_dir
Cut classpath by common_dir commit_hash:d49342ba8eea0705b4965f0c1ad7b9ac7bd9f8f3
1 parent ff9836d commit b5d022f

13 files changed

+61
-31
lines changed

build/export_generators/ide-gradle/build.gradle.kts.any.jinja

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
{#- That is why all common macroses here -#}
44

55
{%- macro PatchRoots(arg, depend = false, output = false) -%}
6-
{#- Always replace (arcadia_root) === (SOURCE_ROOT in ymake) to $project_root in Gradle -#}
6+
{#- Always replace (arcadia_root) === (SOURCE_ROOT in ymake) to $arcadia_root in Gradle -#}
77
{%- if depend -%}
8-
{#- Replace (export_root) === (BUILD_ROOT in ymake) to $project_root in Gradle, because prebuilt tools in arcadia, not in build_root -#}
9-
"{{ arg|replace(export_root, "$project_root")|replace(arcadia_root, "$project_root") }}"
8+
{#- Replace (export_root) === (BUILD_ROOT in ymake) to $arcadia_root in Gradle, because prebuilt tools in arcadia, not in build_root -#}
9+
"{{ arg|replace(export_root, "$arcadia_root")|replace(arcadia_root, "$arcadia_root") }}"
1010
{%- elif output and arg[0] != '/' -%}
1111
{#- Relative outputs in buildDir -#}
1212
"$buildDir/{{ arg }}"
1313
{%- else -%}
1414
{#- Replace (export_root) === (BUILD_ROOT in ymake) to baseBuildDir in Gradle - root of all build folders for modules -#}
15-
"{{ arg|replace(export_root, "$baseBuildDir")|replace(arcadia_root, "$project_root") }}"
15+
"{{ arg|replace(export_root, "$baseBuildDir")|replace(arcadia_root, "$arcadia_root") }}"
1616
{%- endif -%}
1717
{%- endmacro -%}
1818

@@ -26,6 +26,8 @@
2626
{%- endmacro -%}
2727
{%- endif -%}
2828

29+
{%- include "[generator]/common_dir.jinja" -%}
30+
2931
{%- if proto_template -%}
3032
{%- include "[generator]/proto_vars.jinja" -%}
3133
{%- include "[generator]/proto_import.jinja" -%}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{#- empty string #}
22
val baseBuildDir = "{{ export_root }}/gradle.build"
3-
buildDir = file(baseBuildDir + "/" + project.path.replace(":", "/"))
3+
buildDir = file(baseBuildDir + "{%- if common_dir %}/{{ common_dir }}{% endif -%}/" + project.path.replace(":", "/"))
44
subprojects {
5-
buildDir = file(baseBuildDir + "/" + project.path.replace(":", "/"))
5+
buildDir = file(baseBuildDir + "{%- if common_dir %}/{{ common_dir }}{% endif -%}/" + project.path.replace(":", "/"))
66
}

build/export_generators/ide-gradle/codegen.jinja

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,28 @@
22
{%- if proto_template %}
33

44
tasks.getByName("prepareMainProtos").dependsOn({{ taskvar }})
5-
{%- endif %}
5+
{%- endif -%}
66

7+
{#- Check main target codegen -#}
8+
{%- if varprefix == "codegen" %}
79
tasks.compileJava.configure {
810
dependsOn({{ taskvar }})
911
}
12+
{%- endif %}
1013
tasks.compileTestJava.configure {
1114
dependsOn({{ taskvar }})
1215
}
13-
{%- if with_kotlin %}
16+
{%- if with_kotlin -%}
17+
{#- Check main target codegen -#}
18+
{%- if varprefix == "codegen" %}
1419
tasks.compileKotlin.configure {
1520
dependsOn({{ taskvar }})
1621
}
22+
{%- endif %}
1723
tasks.compileTestKotlin.configure {
1824
dependsOn({{ taskvar }})
1925
}
20-
{% endif -%}
26+
{% endif -%}
2127
{%- endmacro -%}
2228

2329
{%- macro ObjDepends(obj) -%}
@@ -33,11 +39,13 @@ tasks.getByName("{{ parent_taskvar }}").dependsOn({{ taskvar }})
3339

3440
{%- if target is defined -%}
3541
{%- set current_target = target -%}
42+
{#- Main target codegen -#}
3643
{%- set varprefix = "codegen" -%}
3744
{%- include "[generator]/codegen_current_target.jinja" -%}
3845
{%- endif -%}
3946
{%- if extra_targets|length -%}
4047
{%- for current_target in extra_targets -%}
48+
{#- TestN target codegen -#}
4149
{%- set varprefix = "test" + loop.index0|tojson + "Codegen" -%}
4250
{%- include "[generator]/codegen_current_target.jinja" -%}
4351
{%- endfor -%}

build/export_generators/ide-gradle/codegen_run_java_program.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ val {{ varprefix }}{{ run['_object_index'] }} = task<JavaExec>("{{ varprefix }}{
1717
{% for classpath in classpaths -%}
1818
{%- set rel_file_classpath = classpath|replace('@', '')|replace(export_root, '')|replace(arcadia_root, '') %}
1919

20-
val classpaths = "$project_root/" + File("$project_root{{ rel_file_classpath }}").readText().trim().replace(":", ":$project_root/")
20+
val classpaths = "$arcadia_root/" + File("$arcadia_root{{ rel_file_classpath }}").readText().trim().replace(":", ":$arcadia_root/")
2121
classpath = files(classpaths.split(":"))
2222
{%- endfor -%}
2323
{%- endif %}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{%- if common_dir -%}
2+
{%- set common_dir_classpath = '":' + common_dir|replace("/", ":") -%}
3+
{%- else -%}
4+
{%- set common_dir_classpath = false -%}
5+
{%- endif -%}

build/export_generators/ide-gradle/configuration.jinja

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{#- empty string #}
2-
val project_root = "{{ arcadia_root }}"
2+
val arcadia_root = "{{ arcadia_root }}"
3+
val project_root = "{{ project_root }}"
34

45
{% if mainClass -%}
56
application {

build/export_generators/ide-gradle/dependencies.jinja

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
{%- if annotation_processors|length -%}
33
{%- set lomboks = annotation_processors|select('startsWith', 'contrib/java/org/projectlombok/lombok') -%}
44
{%- for lombok in lomboks %}
5-
{{ funcName }}(files("$project_root/{{ lombok }}"))
5+
{{ funcName }}(files("$arcadia_root/{{ lombok }}"))
66
{%- endfor -%}
77
{%- set annotation_processors = annotation_processors|reject('in', lomboks) -%}
88
{%- for annotation_processor in annotation_processors %}
9-
{{ funcName }}(files("$project_root/{{ annotation_processor }}"))
9+
{{ funcName }}(files("$arcadia_root/{{ annotation_processor }}"))
1010
{%- endfor -%}
1111
{%- endif -%}
1212
{%- endmacro -%}
@@ -22,15 +22,18 @@ dependencies {
2222
{%- endif -%}
2323

2424
{%- if library.prebuilt and library.jar and (library.type != "contrib" or build_contribs) %}
25-
implementation(files("$project_root/{{ library.jar }}"))
25+
implementation(files("$arcadia_root/{{ library.jar }}"))
2626
{%- else -%}
2727
{%- set classpath = library.classpath -%}
2828
{%- if classpath|replace('"','') == classpath -%}
2929
{%- set classpath = '"' + classpath + '"' -%}
3030
{%- endif -%}
31+
{%- include "[generator]/patch_classpath.jinja" -%}
3132
{%- if library.type != "contrib" %}
32-
{%- if library.testdep %}
33-
implementation(project(path = ":{{ library.testdep | replace("/", ":") }}", configuration = "testArtifacts"))
33+
{%- if library.testdep -%}
34+
{%- set classpath = '":' + library.testdep | replace("/", ":") + '"' -%}
35+
{%- include "[generator]/patch_classpath.jinja" %}
36+
implementation(project(path = {{ classpath }}, configuration = "testArtifacts"))
3437
{%- else %}
3538
implementation({{ classpath }})
3639
{%- endif -%}
@@ -53,14 +56,17 @@ dependencies {
5356
{%- for extra_target in extra_targets -%}
5457
{%- for library in extra_target.consumer if library.classpath -%}
5558
{%- if library.prebuilt and library.jar and (library.type != "contrib" or build_contribs) %}
56-
testImplementation(files("$project_root/{{ library.jar }}"))
59+
testImplementation(files("$arcadia_root/{{ library.jar }}"))
5760
{%- else -%}
5861
{%- set classpath = library.classpath -%}
5962
{%- if classpath|replace('"','') == classpath -%}
6063
{%- set classpath = '"' + classpath + '"' -%}
6164
{%- endif %}
62-
{%- if library.type != "contrib" and library.testdep %}
63-
testImplementation(project(path = ":{{ library.testdep | replace("/", ":") }}", configuration = "testArtifacts"))
65+
{%- include "[generator]/patch_classpath.jinja" -%}
66+
{%- if library.type != "contrib" and library.testdep -%}
67+
{%- set classpath = '":' + library.testdep | replace("/", ":") + '"' -%}
68+
{%- include "[generator]/patch_classpath.jinja" %}
69+
testImplementation(project(path = {{ classpath }}, configuration = "testArtifacts"))
6470
{%- else %}
6571
testImplementation({{ classpath }})
6672
{%- endif -%}

build/export_generators/ide-gradle/kotlinc_flags.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
tasks.withType<KotlinCompile> {
1313
compilerOptions {
1414
{%- for kotlinc_flag in kotlinc_flags|unique %}
15-
freeCompilerArgs.add("{{ kotlinc_flag|replace(export_root, "$project_root")|replace(arcadia_root, "$project_root") }}")
15+
freeCompilerArgs.add("{{ kotlinc_flag|replace(export_root, "$arcadia_root")|replace(arcadia_root, "$arcadia_root") }}")
1616
{%- endfor %}
1717
}
1818
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{%- if common_dir_classpath -%}
2+
{%- set classpath = classpath|replace(common_dir_classpath, '"') -%}
3+
{%- endif -%}

build/export_generators/ide-gradle/proto_configuration.jinja

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{#- empty string #}
2-
val project_root = "{{ arcadia_root }}"
2+
val arcadia_root = "{{ arcadia_root }}"
3+
val project_root = "{{ project_root }}"
34

45
java {
56
withSourcesJar()

0 commit comments

Comments
 (0)