From cd7364dd0b35e3da5528f4e1561b7ca5f6842088 Mon Sep 17 00:00:00 2001 From: Anuraag Agrawal Date: Tue, 2 Feb 2021 18:17:49 +0900 Subject: [PATCH] Migrate proto to kts (#2639) * Migrate proto to kts * Less types --- proto/build.gradle | 65 --------------------------------------- proto/build.gradle.kts | 70 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 65 deletions(-) delete mode 100644 proto/build.gradle create mode 100644 proto/build.gradle.kts diff --git a/proto/build.gradle b/proto/build.gradle deleted file mode 100644 index a0ad97bfca..0000000000 --- a/proto/build.gradle +++ /dev/null @@ -1,65 +0,0 @@ -plugins { - id "java-library" - id "maven-publish" - - id "com.google.protobuf" - id "de.undercouch.download" - id "ru.vyarus.animalsniffer" -} - -description = 'OpenTelemetry Proto' -ext.moduleName = 'io.opentelemetry.proto' - -dependencies { - api "com.google.protobuf:protobuf-java", - "io.grpc:grpc-api", - "io.grpc:grpc-protobuf", - "io.grpc:grpc-stub" -} - -def protoVersion = "0.7.0" -// To generate checksum, download the file and run "shasum -a 256 ~/path/to/vfoo.zip" -def protoChecksum = "0b581c654b2360485b99c2de3731dd59275b0fe7b91d78e7f6c5efd5997f4c82" -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 - } -} diff --git a/proto/build.gradle.kts b/proto/build.gradle.kts new file mode 100644 index 0000000000..7f81a1ee55 --- /dev/null +++ b/proto/build.gradle.kts @@ -0,0 +1,70 @@ +import de.undercouch.gradle.tasks.download.Download +import de.undercouch.gradle.tasks.download.Verify + +plugins { + id("java-library") + id("maven-publish") + + id("com.google.protobuf") + id("de.undercouch.download") + id("ru.vyarus.animalsniffer") +} + +description = "OpenTelemetry Proto" +extra["moduleName"] = "io.opentelemetry.proto" + +dependencies { + api("com.google.protobuf:protobuf-java") + api("io.grpc:grpc-api") + api("io.grpc:grpc-protobuf") + api("io.grpc:grpc-stub") +} + +val protoVersion = "0.7.0" +// To generate checksum, download the file and run "shasum -a 256 ~/path/to/vfoo.zip" +val protoChecksum = "0b581c654b2360485b99c2de3731dd59275b0fe7b91d78e7f6c5efd5997f4c82" +val protoArchive = file("$buildDir/archives/opentelemetry-proto-${protoVersion}.zip") + +tasks { + val downloadProtoArchive by registering(Download::class) { + onlyIf { !protoArchive.exists() } + src("https://github.com/open-telemetry/opentelemetry-proto/archive/v${protoVersion}.zip") + dest(protoArchive) + } + + val verifyProtoArchive by registering(Verify::class) { + dependsOn(downloadProtoArchive) + src(protoArchive) + algorithm("SHA-256") + checksum(protoChecksum) + } + + val unzipProtoArchive by registering(Copy::class) { + dependsOn(verifyProtoArchive) + from(zipTree(protoArchive)) + into("$buildDir/protos") + } + + afterEvaluate { + named("generateProto") { + dependsOn(unzipProtoArchive) + } + } +} + +sourceSets { + main { + proto { + srcDir("$buildDir/protos/opentelemetry-proto-${protoVersion}") + } + } +} + +// IntelliJ complains that the generated classes are not found, ask IntelliJ to include the +// generated Java directories as source folders. +idea { + module { + sourceDirs.add(file("build/generated/source/proto/main/java")) + // If you have additional sourceSets and/or codegen plugins, add all of them + } +}