93 lines
2.5 KiB
Groovy
93 lines
2.5 KiB
Groovy
plugins {
|
|
id "java"
|
|
id "maven-publish"
|
|
|
|
id "com.google.protobuf"
|
|
id "de.undercouch.download"
|
|
id "ru.vyarus.animalsniffer"
|
|
}
|
|
|
|
description = 'OpenTelemetry Proto'
|
|
ext.moduleName = 'io.opentelemetry.proto'
|
|
|
|
dependencies {
|
|
// Protobuf plugin seems to erroneously use the non-classpath configurations for resolving
|
|
// dependencies.
|
|
implementation enforcedPlatform(boms.grpc)
|
|
implementation enforcedPlatform(boms.protobuf)
|
|
|
|
api libraries.protobuf,
|
|
libraries.grpc_api,
|
|
libraries.grpc_protobuf,
|
|
libraries.grpc_stub
|
|
|
|
signature libraries.android_signature
|
|
}
|
|
|
|
animalsniffer {
|
|
// Don't check sourceSets.jmh and sourceSets.test
|
|
sourceSets = [
|
|
sourceSets.main
|
|
]
|
|
}
|
|
|
|
protobuf {
|
|
protoc {
|
|
// The artifact spec for the Protobuf Compiler
|
|
artifact = "com.google.protobuf:protoc:${protocVersion}"
|
|
}
|
|
plugins {
|
|
grpc { artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}" }
|
|
}
|
|
generateProtoTasks {
|
|
all()*.plugins { grpc {} }
|
|
}
|
|
}
|
|
|
|
def protoVersion = "0.6.0"
|
|
// To generate checksum, download the file and run "shasum -a 256 ~/path/to/vfoo.zip"
|
|
def protoChecksum = "a40003d50a565c989283d6b5b93b6189c28378387b715bdd54bf4600bb9c17c1"
|
|
def protoArchivePath = "$buildDir/archives/opentelemetry-proto-${protoVersion}.zip"
|
|
|
|
def downloadProtoArchive = tasks.register("downloadProtoArchive", Download) {
|
|
onlyIf { !file(protoArchivePath).exists() }
|
|
src "https://github.com/open-telemetry/opentelemetry-proto/archive/v${protoVersion}.zip"
|
|
dest protoArchivePath
|
|
}
|
|
|
|
def verifyProtoArchive = tasks.register("verifyProtoArchive", Verify) {
|
|
dependsOn(downloadProtoArchive)
|
|
src protoArchivePath
|
|
algorithm "SHA-256"
|
|
checksum protoChecksum
|
|
}
|
|
|
|
def unzipProtoArchive = tasks.register("unzipProtoArchive", Copy) {
|
|
dependsOn(verifyProtoArchive)
|
|
from zipTree(protoArchivePath)
|
|
into "$buildDir/protos"
|
|
}
|
|
|
|
sourceSets {
|
|
main {
|
|
proto {
|
|
srcDir "$buildDir/protos/opentelemetry-proto-${protoVersion}"
|
|
}
|
|
}
|
|
}
|
|
|
|
afterEvaluate {
|
|
tasks.named("generateProto") {
|
|
dependsOn(unzipProtoArchive)
|
|
}
|
|
}
|
|
|
|
// IntelliJ complains that the generated classes are not found, ask IntelliJ to include the
|
|
// generated Java directories as source folders.
|
|
idea {
|
|
module {
|
|
sourceDirs += file("build/generated/source/proto/main/java")
|
|
// If you have additional sourceSets and/or codegen plugins, add all of them
|
|
}
|
|
}
|