Skip to content

Commit 8fe8458

Browse files
authored
Speed up no-inst jar creation (#333)
1 parent dd4f8d0 commit 8fe8458

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

static-instrumenter/agent-instrumenter/build.gradle.kts

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -64,27 +64,29 @@ tasks {
6464
}
6565
}
6666

67-
// TODO: the resulting jar contains both inst and unpacked inst,
68-
// but we need only the unpacked inst here
69-
val createNoInstAgent by registering(ShadowJar::class) {
70-
71-
configurations = listOf(javaagent)
72-
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
73-
67+
val createNoInstAgent by registering(Jar::class) {
7468
archiveClassifier.set("no-inst")
75-
76-
inputs.files.forEach {
77-
if (it.name.endsWith(".jar")) {
78-
from(zipTree(it)) {
79-
include("inst/")
80-
eachFile {
81-
// drop inst/
82-
relativePath = RelativePath(true, *relativePath.segments.drop(1).toTypedArray())
83-
rename("(.*)\\.classdata\$", "\$1.class")
69+
// source jar has no timestamps don't add any to the destination
70+
isPreserveFileTimestamps = false
71+
72+
from(zipTree(shadowJar.get().archiveFile)) {
73+
// renaming inst/ leaves behind empty directories
74+
includeEmptyDirs = false
75+
// skip to avoid duplicate entry error
76+
exclude("inst/META-INF/MANIFEST.MF")
77+
eachFile {
78+
if (path.startsWith("inst/")) {
79+
path = path.substring("inst/".length)
80+
if (path.endsWith(".classdata")) {
81+
path = path.substring(0, path.length - 4)
8482
}
8583
}
8684
}
8785
}
86+
87+
manifest {
88+
attributes(shadowJar.get().manifest.attributes)
89+
}
8890
}
8991

9092
withType<ShadowJar>().configureEach {

0 commit comments

Comments
 (0)