Skip to content

Commit 84fec05

Browse files
authored
Enable gradle cache configuration (open-telemetry#2222)
1 parent 3cf1b89 commit 84fec05

File tree

4 files changed

+28
-18
lines changed

4 files changed

+28
-18
lines changed

buildSrc/src/main/kotlin/otel.java-conventions.gradle.kts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,13 @@ plugins.withId("otel.publish-conventions") {
106106
register("generateVersionResource") {
107107
val moduleName = otelJava.moduleName
108108
val propertiesDir = moduleName.map { layout.buildDirectory.file("generated/properties/${it.replace('.', '/')}") }
109+
val projectVersion = project.version.toString()
109110

110-
inputs.property("project.version", project.version.toString())
111+
inputs.property("project.version", projectVersion)
111112
outputs.dir(propertiesDir)
112113

113114
doLast {
114-
File(propertiesDir.get().get().asFile, "version.properties").writeText("contrib.version=${project.version}")
115+
File(propertiesDir.get().get().asFile, "version.properties").writeText("contrib.version=${projectVersion}")
115116
}
116117
}
117118
}

buildSrc/src/main/kotlin/otel.spotless-conventions.gradle.kts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ spotless {
88
licenseHeaderFile(rootProject.file("buildscripts/spotless.license.java"), "(package|import|public|// Includes work from:)")
99
target("src/**/*.java")
1010
}
11-
plugins.withId("groovy") {
12-
groovy {
13-
licenseHeaderFile(rootProject.file("buildscripts/spotless.license.java"), "(package|import|class)")
14-
}
15-
}
11+
// commented out for now due to incompatibility with gradle cache configuration
12+
// plugins.withId("groovy") {
13+
// groovy {
14+
// licenseHeaderFile(rootProject.file("buildscripts/spotless.license.java"), "(package|import|class)")
15+
// }
16+
// }
1617
plugins.withId("scala") {
1718
scala {
1819
scalafmt()

gradle.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
org.gradle.parallel=true
22
org.gradle.caching=true
3+
org.gradle.configuration-cache=true
4+
org.gradle.configuration-cache.parallel=true
35

46
org.gradle.priority=low
57

opamp-client/build.gradle.kts

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import de.undercouch.gradle.tasks.download.DownloadExtension
1+
import java.io.FileOutputStream
2+
import java.io.InputStream
3+
import java.net.URL
24

35
plugins {
46
id("otel.java-conventions")
57
id("otel.publish-conventions")
68
id("otel.animalsniffer-conventions")
7-
id("de.undercouch.download") version "5.6.0"
89
id("com.squareup.wire") version "5.4.0"
910
}
1011

@@ -23,11 +24,11 @@ dependencies {
2324
testImplementation("com.squareup.okhttp3:mockwebserver3-junit5")
2425
}
2526

26-
val opampProtos = tasks.register<DownloadOpampProtos>("opampProtoDownload", download)
27-
opampProtos.configure {
27+
val opampProtos = tasks.register<DownloadAndExtractOpampProtos>("opampProtoDownload") {
2828
group = "opamp"
2929
outputProtosDir.set(project.layout.buildDirectory.dir("opamp/protos"))
30-
downloadedZipFile.set(project.layout.buildDirectory.file("intermediate/$name/release.zip"))
30+
downloadedZipFile.set(project.layout.buildDirectory.file("intermediate/opampProtoDownload/release.zip"))
31+
zipUrl.set("https://github.com/open-telemetry/opamp-spec/zipball/v0.14.0")
3132
}
3233

3334
wire {
@@ -37,8 +38,7 @@ wire {
3738
}
3839
}
3940

40-
abstract class DownloadOpampProtos @Inject constructor(
41-
private val download: DownloadExtension,
41+
abstract class DownloadAndExtractOpampProtos @Inject constructor(
4242
private val archiveOps: ArchiveOperations,
4343
private val fileOps: FileSystemOperations,
4444
) : DefaultTask() {
@@ -49,14 +49,20 @@ abstract class DownloadOpampProtos @Inject constructor(
4949
@get:Internal
5050
abstract val downloadedZipFile: RegularFileProperty
5151

52+
@get:Input
53+
abstract val zipUrl: Property<String>
54+
5255
@TaskAction
5356
fun execute() {
54-
val zipUrl = "https://github.com/open-telemetry/opamp-spec/zipball/v0.14.0"
57+
val url = URL(zipUrl.get())
58+
downloadedZipFile.get().asFile.parentFile.mkdirs()
5559

56-
download.run {
57-
src(zipUrl)
58-
dest(downloadedZipFile)
60+
url.openStream().use { input: InputStream ->
61+
downloadedZipFile.get().asFile.outputStream().use { output: FileOutputStream ->
62+
input.copyTo(output)
63+
}
5964
}
65+
6066
val protos = archiveOps.zipTree(downloadedZipFile).matching {
6167
setIncludes(listOf("**/*.proto"))
6268
}

0 commit comments

Comments
 (0)