11import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
2+ import de.undercouch.gradle.tasks.download.Download
23import ru.vyarus.gradle.plugin.animalsniffer.AnimalSniffer
34
45plugins {
@@ -7,7 +8,8 @@ plugins {
78 id(" com.github.johnrengelman.shadow" )
89 id(" me.champeau.jmh" ) version " 0.7.3"
910 id(" ru.vyarus.animalsniffer" ) version " 2.0.0"
10- id(" com.squareup.wire" ) version " 5.3.0"
11+ id(" com.squareup.wire" ) version " 5.3.1"
12+ id(" de.undercouch.download" )
1113}
1214
1315description = " Exporter implementations that store signals on disk"
@@ -49,11 +51,14 @@ jmh {
4951 timeUnit.set(" ms" )
5052}
5153
54+ val protoVersion = " 1.5.0"
55+ val protoArchive = layout.buildDirectory.file(" archives/opentelemetry-proto-$protoVersion .zip" ).get().asFile
56+
5257wire {
5358 java {}
5459
5560 sourcePath {
56- srcJar( " io.opentelemetry.proto: opentelemetry-proto:1.5.0-alpha " )
61+ srcDir(layout.buildDirectory.dir( " protos/ opentelemetry-proto- $protoVersion " ) )
5762 }
5863
5964 root(
@@ -63,6 +68,26 @@ wire {
6368 )
6469}
6570
71+ afterEvaluate {
72+ tasks {
73+ val downloadProtoArchive by registering(Download ::class ) {
74+ onlyIf { ! protoArchive.exists() }
75+ src(" https://github.com/open-telemetry/opentelemetry-proto/archive/v$protoVersion .zip" )
76+ dest(protoArchive)
77+ }
78+
79+ val unzipProtoArchive by registering(Copy ::class ) {
80+ dependsOn(downloadProtoArchive)
81+ from(zipTree(protoArchive))
82+ into(layout.buildDirectory.dir(" protos" ))
83+ }
84+
85+ named(" generateMainProtos" ) {
86+ dependsOn(unzipProtoArchive)
87+ }
88+ }
89+ }
90+
6691tasks.named<ShadowJar >(" shadowJar" ) {
6792 archiveClassifier.set(" " )
6893 configurations = emptyList() // To avoid embedding any dependencies as we only need to rename some local packages.
0 commit comments