123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- {%- set publish = targets|selectattr('publish') -%}
- {%- set target0 = targets[0] -%}
- import com.google.protobuf.gradle.*
- val buildProtoDir = File("${buildDir}", "__proto__")
- plugins {
- id("java-library")
- id("com.google.protobuf") version "0.8.19"
- {%- if publish %}
- `maven-publish`
- `signing`
- {%- endif -%}
- }
- {%- if publish %}
- group = "{{ target0.publish_group }}"
- version = {% if target0.publish_version -%}"{{ target0.publish_version }}"{%- else -%}project.properties["version"]{%- endif %}
- {%- endif %}
- repositories {
- mavenCentral()
- }
- java {
- withSourcesJar()
- withJavadocJar()
- }
- configurations.api {
- isTransitive = false
- }
- configurations.implementation {
- isTransitive = false
- }
- 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, ':') -%}
- sourceSets.main.java.srcDirs += "{{ srcdir_glob[0] }}"
- {% endfor -%}
- {%- endif -%}
- {%- 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 target.handler.build_contribs) -%}
- {%- if target.isTest %}
- testImplementation
- {%- else %}
- implementation
- {%- endif -%}(files("$project_root/{{ library.jar }}"))
- {%- else -%}
- {%- if target.isTest %}
- testImplementation
- {%- elif library.type != "contrib" %}
- implementation
- {%- 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, ':') -%}
- exclude(group = "{{ classpath_parts[0] }}", module = "{{ classpath_parts[1] }}")
- {% endfor -%}
- }
- {%- endif -%}
- {%- endif -%}
- {%- endfor -%}
- {%- endfor %}
- {% if target0.proto_namespace is defined -%}
- protobuf(files(File(buildProtoDir, "{{ target0.proto_namespace }}")))
- {% else -%}
- protobuf(files(buildProtoDir))
- {% endif -%}
- }
- 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 -%}"
- }
- {% if target0.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 -%}"
- }
- }
- generateProtoTasks {
- ofSourceSet("main").forEach {
- it.plugins {
- id("grpc")
- }
- }
- }
- {%- endif %}
- }
- val prepareProto = tasks.register<Copy>("prepareProto") {
- from(rootDir) {
- {%- for proto in target0.proto_files %}
- include("{{ proto }}")
- {%- endfor %}
- }
- into(buildProtoDir)
- }
- afterEvaluate {
- tasks.getByName("extractProto").dependsOn(prepareProto)
- }
- {{ dump }}
|