Slackbot
05/24/2023, 10:18 PMAdam
05/24/2023, 10:21 PMconfigurations.bundledApps.incoming.artifactFiles
to get the incoming files (or something similar - I often get muddled with area of Gradle)Andrew Tasso
05/24/2023, 10:30 PMconfigurations.bundledApps.incoming.files.each { file ->
distributions.main.contents {
from(zipTree(file)) {
into "tools"
}
}
}
Adam
05/24/2023, 10:41 PMeach {}
means Gradle loses the task dependency. Try using incoming.resolvedArtifacts
(or something like that, you want one that returns a Provider<>
), and you can unzip the files in a map {}
, then pass the result into the distributions contents
something like this:
distributions.main.contents {
from(configurations.bundledApps.incoming.resolvedArtifacts.map { files -> ... }) {
into "tools"
}
}
Vampire
05/24/2023, 11:42 PMAndrew Tasso
05/25/2023, 1:19 AMdistributions
declaration and it builds in correct order from(configurations.bundledApps.singleFile){ into "tools" }
Andrew Tasso
05/25/2023, 1:21 AMVampire
05/25/2023, 1:21 AMVampire
05/25/2023, 1:21 AMVampire
05/25/2023, 1:22 AMVampire
05/25/2023, 1:22 AMAndrew Tasso
05/25/2023, 6:30 PMzipTree
is what's breaking task order resolution. The consuming task knows where the file should be based upon the output of that task. But Gradle is not executing that task first.Vampire
05/25/2023, 6:57 PMAndrew Tasso
05/25/2023, 7:00 PMVampire
05/25/2023, 7:02 PMabstract class Unzip : TransformAction<Parameters> {
@get:Inject
protected abstract val fileSystem: FileSystemOperations
@get:Inject
protected abstract val archive: ArchiveOperations
@get:InputArtifact
abstract val inputArtifact: Provider<FileSystemLocation>
override fun transform(outputs: TransformOutputs) {
val input = inputArtifact.get().asFile
val output = outputs.dir(input.name)
fileSystem.sync {
from(archive.zipTree(input))
into(output)
if (parameters.stripTopLevelDirectory.getOrElse(false)) {
eachFile {
val segments = relativePath.segments
relativePath = RelativePath(
relativePath.isFile,
*segments.sliceArray(1 until segments.size)
)
}
}
}
}
interface Parameters : TransformParameters {
@get:Optional
@get:Input
val stripTopLevelDirectory: Property<Boolean>
}
}
Andrew Tasso
05/25/2023, 7:08 PM