|
1 | 1 | plugins { |
2 | 2 | application |
3 | 3 | id("com.gradleup.shadow") |
4 | | - |
5 | 4 | id("otel.java-conventions") |
6 | | - |
7 | 5 | id("otel.publish-conventions") |
8 | 6 | } |
9 | 7 |
|
@@ -92,6 +90,39 @@ tasks { |
92 | 90 | } |
93 | 91 | } |
94 | 92 |
|
| 93 | +// This task copies the jar to a package dir for packaging. |
| 94 | +val copyJarForPackage by tasks.registering(Copy::class) { |
| 95 | + dependsOn(tasks.jar) |
| 96 | + |
| 97 | + // Clean target directory before copying |
| 98 | + doFirst { |
| 99 | + val targetDir = file("package/usr/local/bin") |
| 100 | + if (targetDir.exists()) { |
| 101 | + targetDir.deleteRecursively() |
| 102 | + } |
| 103 | + } |
| 104 | + |
| 105 | + from(tasks.jar.get().outputs.files) |
| 106 | + into("package/usr/local/bin") |
| 107 | + rename { "jmx-scraper.jar" } |
| 108 | +} |
| 109 | + |
| 110 | +// This task creates a tarball of the package directory. |
| 111 | +val createTarball by tasks.registering(Tar::class) { |
| 112 | + dependsOn(copyJarForPackage) |
| 113 | + archiveBaseName.set("opentelemetry-jmx-scraper") |
| 114 | + archiveVersion.set(project.version.toString()) |
| 115 | + archiveExtension.set("tar.gz") |
| 116 | + compression = Compression.GZIP |
| 117 | + // simply put it at the project root |
| 118 | + destinationDirectory.set(file("./")) |
| 119 | + |
| 120 | + from("package") { |
| 121 | + // preserve directory structure relative to package/ |
| 122 | + into("/") |
| 123 | + } |
| 124 | +} |
| 125 | + |
95 | 126 | // Don't publish non-shadowed jar (shadowJar is in shadowRuntimeElements) |
96 | 127 | with(components["java"] as AdhocComponentWithVariants) { |
97 | 128 | configurations.forEach { |
|
0 commit comments