|
@@ -1,172 +1,13 @@
|
|
|
-{%- set publish = target.publish -%}
|
|
|
-{%- set libraries = target.consumer|selectattr('type', 'eq', 'library') -%}
|
|
|
-import com.google.protobuf.gradle.*
|
|
|
-
|
|
|
-{% include "[generator]/builddir.jinja" %}
|
|
|
-
|
|
|
-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"
|
|
|
-{%- if publish %}
|
|
|
- `maven-publish`
|
|
|
- `signing`
|
|
|
-{%- endif %}
|
|
|
-}
|
|
|
-{%- include "[generator]/publish.jinja" %}
|
|
|
-
|
|
|
-{% include "[generator]/bucket.jinja" %}
|
|
|
-val project_root = "{{ arcadia_root }}"
|
|
|
-
|
|
|
-sourceSets {
|
|
|
- main {
|
|
|
- java.srcDir("$buildDir/generated/sources/proto/main/java")
|
|
|
-{%- if target.proto_grpc %}
|
|
|
- java.srcDir("$buildDir/generated/sources/proto/main/grpc")
|
|
|
-{%- endif %}
|
|
|
- }
|
|
|
- test {
|
|
|
- java.srcDir("$buildDir/generated/sources/proto/test/java")
|
|
|
-{%- if target.proto_grpc %}
|
|
|
- java.srcDir("$buildDir/generated/sources/proto/test/grpc")
|
|
|
-{%- endif %}
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-java {
|
|
|
- withSourcesJar()
|
|
|
- withJavadocJar()
|
|
|
-}
|
|
|
-
|
|
|
-configurations.api {
|
|
|
- isTransitive = false
|
|
|
-}
|
|
|
-
|
|
|
-configurations.implementation {
|
|
|
- isTransitive = false
|
|
|
-}
|
|
|
-
|
|
|
-configurations.testImplementation {
|
|
|
- isTransitive = false
|
|
|
-}
|
|
|
-
|
|
|
-{%- 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 %}
|
|
|
-
|
|
|
-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 }}"))
|
|
|
-{%- else -%}
|
|
|
-{%- set classpath = library.classpath -%}
|
|
|
-{%- if classpath|replace('"','') == classpath -%}
|
|
|
-{%- set classpath = '"' + classpath + '"' -%}
|
|
|
-{%- endif %}
|
|
|
-{%- if library.type != "contrib" %}
|
|
|
- implementation
|
|
|
-{%- else %}
|
|
|
- api
|
|
|
-{%- endif -%}({{ 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 -%}
|
|
|
- }
|
|
|
-{%- endif -%}
|
|
|
-{%- endif -%}
|
|
|
-{%- endfor -%}
|
|
|
-
|
|
|
-{%- if target.proto_namespace %}
|
|
|
- protobuf(files(File(mainProtosDir, "{{ target.proto_namespace }}")))
|
|
|
-{%- else %}
|
|
|
- protobuf(files(mainProtosDir))
|
|
|
-{%- endif %}
|
|
|
-}
|
|
|
-
|
|
|
-protobuf {
|
|
|
- generatedFilesBaseDir = "$buildDir/generated/sources/proto"
|
|
|
-
|
|
|
- protoc {
|
|
|
- // Download from repositories
|
|
|
- artifact = "com.google.protobuf:protoc:{%- if target.proto_compiler_version -%}{{ target.proto_compiler_version }}{%- else -%}3.22.5{%- endif -%}"
|
|
|
- }
|
|
|
-{%- if target.proto_grpc %}
|
|
|
-
|
|
|
- plugins {
|
|
|
- id("grpc") {
|
|
|
- artifact = "io.grpc:protoc-gen-grpc-java:{%- if target.proto_grpc_version -%}{{ target.proto_grpc_version }}{%- else -%}1.45.0{%- endif -%}"
|
|
|
- }
|
|
|
-{%- if target.proto_kotlin_grpc %}
|
|
|
- id("grpckt") {
|
|
|
- artifact = "io.grpc:protoc-gen-grpc-kotlin:{%- if target.proto_kotlin_grpc_version -%}{{ target.proto_kotlin_grpc_version }}{%- else -%}1.3.1{%- endif -%}:jdk8@jar"
|
|
|
- }
|
|
|
-{%- endif %}
|
|
|
- }
|
|
|
-
|
|
|
- generateProtoTasks {
|
|
|
- all().forEach {
|
|
|
- it.plugins {
|
|
|
- id("grpc")
|
|
|
-{%- if target.proto_kotlin_grpc %}
|
|
|
- id("grpckt")
|
|
|
-{%- endif %}
|
|
|
- }
|
|
|
-{%- if target.proto_kotlin_grpc %}
|
|
|
- it.builtins {
|
|
|
- create("kotlin")
|
|
|
- }
|
|
|
-{%- endif %}
|
|
|
- }
|
|
|
- }
|
|
|
-{%- 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")
|
|
|
-
|
|
|
-{# To disable redundant javadoc (it may fail the build) #}
|
|
|
-tasks.withType<Javadoc>().configureEach {
|
|
|
- isEnabled = false
|
|
|
-}
|
|
|
-
|
|
|
+{%- include "[generator]/proto_vars.jinja" -%}
|
|
|
+{%- include "[generator]/proto_import.jinja" -%}
|
|
|
+{%- include "[generator]/repositories.jinja" -%}
|
|
|
+{%- include "[generator]/proto_builddir.jinja" -%}
|
|
|
+{%- include "[generator]/proto_plugins.jinja" -%}
|
|
|
+{%- include "[generator]/publish.jinja" -%}
|
|
|
+{%- include "[generator]/proto_configuration.jinja" -%}
|
|
|
+{%- include "[generator]/proto_source_sets.jinja" -%}
|
|
|
+{%- include "[generator]/protobuf.jinja" -%}
|
|
|
+{%- include "[generator]/proto_prepare.jinja" -%}
|
|
|
+{%- include "[generator]/javadoc.jinja" -%}
|
|
|
+{%- include "[generator]/proto_dependencies.jinja" -%}
|
|
|
{%- include "[generator]/debug.jinja" ignore missing -%}
|