Martmists
08/18/2025, 12:18 PMproject.providers.exec { ... }.result.get()?Martin
08/18/2025, 12:22 PMExec task. Just because I like reasonning in terms of tasks. But there might be other optionsMartmists
08/18/2025, 12:22 PMMartin
08/18/2025, 12:24 PMConfigurableFileCollection as input and uses ProcessBuilder to run N separate processesMartin
08/18/2025, 12:24 PMVampire
08/18/2025, 12:25 PMProcessBuilder?René
08/18/2025, 12:25 PMMartin
08/18/2025, 12:25 PMMartin
08/18/2025, 12:25 PMVampire
08/18/2025, 12:26 PMExecOperations and use exec on it, that also is a drop-in replacement behavior- and api-wise to project.execMartin
08/18/2025, 12:26 PMMartmists
08/18/2025, 12:26 PM@TaskAction
fun run() {
val bundler = bundler.get().asFile
val minifier = minifier.get().asFile
val doMinify = minify.get()
val requireRoot = sourceDirectory.get().asFile.absolutePath
for ((inFile, outFile) in inputFiles.files.zip(outputFiles.files)) {
project.providers.exec {
executable(bundler)
args("bundle", inFile.absolutePath)
args("-p", "${requireRoot}/?.lua")
args("-p", "${requireRoot}/?/init.lua")
args("-o", outFile.absolutePath)
}.result.get()
if (doMinify) {
val minifiedStream = ByteArrayOutputStream()
project.providers.exec {
executable(minifier)
args("-f")
args(outFile.absolutePath)
standardOutput = minifiedStream
}.result.get()
outFile.writeText(minifiedStream.toString())
}
}
}Vampire
08/18/2025, 12:27 PMExecOperations but, it needs a bit of boilerplate or the usage of an internal function to get it.
You could in that case use provider.exec yes, if you are aware of the laziness and that you do not see the output in the build log unless you print it out in the end.Vampire
08/18/2025, 12:27 PMFor more context, here's my current snippetWell, that is a proper task class, so inject
ExecOperations and use exec on it đŸ™‚Vampire
08/18/2025, 12:28 PMproviders.exec is also fine.Vampire
08/18/2025, 12:28 PMproject in the task actionVampire
08/18/2025, 12:29 PMVampire
08/18/2025, 12:29 PMProviderFactory and use exec on thatMartmists
08/18/2025, 12:29 PMVampire
08/18/2025, 12:29 PMVampire
08/18/2025, 12:30 PM@get:Inject
protected abstract val execOperations: ExecOperationsVampire
08/18/2025, 12:30 PMMartmists
08/18/2025, 12:31 PMVampire
08/18/2025, 12:32 PMInject?Vampire
08/18/2025, 12:32 PMjavax.inject.Inject it should beMartmists
08/18/2025, 12:32 PM