aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordimdim11 <dimdim11@yandex-team.com>2024-11-21 20:12:46 +0300
committerdimdim11 <dimdim11@yandex-team.com>2024-11-21 20:26:31 +0300
commit038c81c8f86c12a0cdd2631c89bbfee6723cc964 (patch)
tree2549e8cb777f018b45e859c7a7ab72e55c2483f6
parent5fb7f5f70d23f144b1ebc88a830a28898c553093 (diff)
downloadydb-038c81c8f86c12a0cdd2631c89bbfee6723cc964.tar.gz
Fix proto with proto-libraries, refactor errorprone
Refactor errorprone Fix building protos in Gradle commit_hash:54d1cdf9df00e7ab30b991ddf1f534ab5992ef3c
-rw-r--r--build/export_generators/ide-gradle/build.gradle.kts.jinja41
-rw-r--r--build/export_generators/ide-gradle/build.gradle.kts.proto.jinja46
2 files changed, 61 insertions, 26 deletions
diff --git a/build/export_generators/ide-gradle/build.gradle.kts.jinja b/build/export_generators/ide-gradle/build.gradle.kts.jinja
index 46bcd4cefd..798922b5b7 100644
--- a/build/export_generators/ide-gradle/build.gradle.kts.jinja
+++ b/build/export_generators/ide-gradle/build.gradle.kts.jinja
@@ -38,21 +38,6 @@ subprojects {
{%- endif %}
plugins {
-{#- some plugins configuration -#}
-{%- for library in target.consumer if library.classpath -%}
-{#- error prone plugin configuration -#}
-{%- if library.prebuilt and library.jar and (library.type != "contrib" or build_contribs) and "contrib/java/com/google/errorprone/error_prone_annotations/" in library.jar -%}
-
- id("net.ltgt.errorprone") version "{{ errorprone_plugin_version }}"
-
-{%- endif -%}
-{%- endfor -%}
-
-{#- lombok configuration -#}
-{#- TODO remove usings annotation_processors semantic -#}
-{%- if ("lombok.launch.AnnotationProcessorHider$AnnotationProcessor" in target.annotation_processors) or (target.use_annotation_processor|length and target.use_annotation_processor|select('startsWith', 'contrib/java/org/projectlombok/lombok')|length) %}
- id("io.freefair.lombok") version "8.6"
-{%- endif -%}
{%- if mainClass %}
`application`
{%- else %}
@@ -76,6 +61,17 @@ plugins {
{%- if target.with_kotlinc_plugin_serialization|length %}
kotlin("plugin.serialization") version "{{ kotlin_version }}"
{% endif -%}
+{%- endif -%}
+
+{#- errorprone plugin configuration -#}
+{%- if target.consumer|selectattr('jar', 'startsWith', 'contrib/java/com/google/errorprone/error_prone_annotations')|length %}
+ id("net.ltgt.errorprone") version "{{ errorprone_plugin_version }}"
+{%- endif -%}
+
+{#- lombok plugin configuration -#}
+{#- TODO remove usings annotation_processors semantic -#}
+{%- if ("lombok.launch.AnnotationProcessorHider$AnnotationProcessor" in target.annotation_processors) or (target.use_annotation_processor|length and target.use_annotation_processor|select('startsWith', 'contrib/java/org/projectlombok/lombok')|length) %}
+ id("io.freefair.lombok") version "8.6"
{%- endif %}
}
@@ -272,6 +268,7 @@ sourceSets.main.java.srcDirs += "{{ srcdir_glob[0] }}"
{%- endfor -%}
sourceSets {
+{%- if target.runs|length %}
main {
{#-
Default by Gradle:
@@ -280,13 +277,11 @@ sourceSets {
resources.srcDir("src/main/resources")
#}
-{%- if target.runs|length -%}
{%- for run in target.runs -%}
{{ OutDirs(run, ' java.srcDir("', '")') }}
-{%- endfor -%}
-{%- endif %}
+{%- endfor %}
}
-
+{%- endif %}
test {
{#-
Default by Gradle:
@@ -315,11 +310,9 @@ sourceSets {
dependencies {
{%- for library in target.consumer if library.classpath -%}
-{# error prone plugin configuration #}
-{%- if library.prebuilt and library.jar and (library.type != "contrib" or build_contribs) and "contrib/java/com/google/errorprone/error_prone_annotations" in library.jar -%}
-{% set errorprone_version = library.jar -%}
-{% set errorprone_parts = errorprone_version|replace("contrib/java/com/google/errorprone/error_prone_annotations/") -%}
-{% set errorprone_parts = split(errorprone_parts, '/') %}
+{%- if library.prebuilt and (library.type != "contrib" or build_contribs) and ("contrib/java/com/google/errorprone/error_prone_annotations" in library.jar) -%}
+{%- set errorprone_version = library.jar|replace("contrib/java/com/google/errorprone/error_prone_annotations/", "") -%}
+{%- set errorprone_parts = split(errorprone_version, '/', 2) %}
errorprone("com.google.errorprone:error_prone_core:{{ errorprone_parts[0] }}")
{%- endif -%}
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 bb6de76adb..fe989ed989 100644
--- a/build/export_generators/ide-gradle/build.gradle.kts.proto.jinja
+++ b/build/export_generators/ide-gradle/build.gradle.kts.proto.jinja
@@ -1,4 +1,6 @@
{%- set publish = target.publish -%}
+{%- set libraries = target.consumer|selectattr('type', 'eq', 'library') -%}
+
import com.google.protobuf.gradle.*
val baseBuildDir = "{{ export_root }}/gradle.build/"
@@ -7,6 +9,11 @@ subprojects {
buildDir = file(baseBuildDir + project.path.replaceFirst(":", "/").replace(":", "."))
}
+val mainProtosDir = File(buildDir, "main_protos")
+{%- if libraries|length %}
+val mainExtractedIncludeProtosDir = File(buildDir, "extracted-include-protos/main")
+{%- endif %}
+
plugins {
id("java-library")
id("com.google.protobuf") version "0.8.19"
@@ -99,8 +106,13 @@ dependencies {
}
{%- endif -%}
{%- endif -%}
-{%- endfor %}
- protobuf(files("$projectDir"))
+{%- endfor -%}
+
+{%- if target.proto_namespace %}
+ protobuf(files(File(mainProtosDir, "{{ target.proto_namespace }}")))
+{%- else %}
+ protobuf(files(mainProtosDir))
+{%- endif %}
}
protobuf {
@@ -141,6 +153,36 @@ protobuf {
{%- endif %}
}
+val prepareMainProtos = tasks.register<Copy>("prepareMainProtos") {
+ from("$project_root") {
+{#- list of all current project proto files -#}
+{%- for proto in target.proto_files %}
+ include("{{ proto }}")
+{%- endfor %}
+ }
+ into(mainProtosDir)
+}
+
+{% if libraries|length -%}
+val extractMainLibrariesProtos = tasks.register<Copy>("extractMainLibrariesProtos") {
+ from("$project_root") {
+{#- list of all library directories -#}
+{%- for library in libraries -%}
+{%- set path_and_jar = rsplit(library.jar, '/', 2) %}
+ include("{{ path_and_jar[0] }}/**/*.proto")
+{%- endfor %}
+ }
+ into(mainExtractedIncludeProtosDir)
+}
+
+{% endif -%}
+afterEvaluate {
+ tasks.getByName("extractProto").dependsOn(prepareMainProtos)
+{%- if libraries|length %}
+ tasks.getByName("extractProto").dependsOn(extractMainLibrariesProtos)
+{%- endif %}
+}
+
{# To avoid problems when build project with proto #}
tasks.getByName("sourcesJar").dependsOn("generateProto")