Roded Bahat
07/25/2024, 3:39 AMVampire
07/25/2024, 10:33 AMNO-SOURCE, it also did not download your file, because it was skipped.
And if it is skipped with NO-SOURCE it means you do have inputs declared with "skip when empty".
Whether you really want your task cacheable you should think twice. Each time you download you could get a different result. If you make the task cacheable, you always get the cached result.Roded Bahat
07/25/2024, 11:07 AMproject.tasks.register , I guess I could create an input file containing the URL.Vampire
07/25/2024, 11:50 AMVampire
07/25/2024, 11:51 AMNO-SOURCE it did not run anyway and should have input files defined that are empty. How exactly do you declare the task in whole?Roded Bahat
07/25/2024, 3:25 PMreturn project.tasks.register("downloadCompilerPackage") {
doFirst {
...
}
doLast {
...
}
}
I was surprised too about how it assumes that it should have sourcesVampire
07/25/2024, 4:48 PMRoded Bahat
07/25/2024, 5:46 PMreturn project.tasks.register("downloadKaitaiCompiler") {
doFirst {
locksService.getLock("downloadKaitaiPackage").withLock {
pluginResources.kaitaiRootDirectory.mkdirs()
if (!pluginResources.kaitaiRootCompilerZip.exists()) {
project.uri("...")
.toURL()
.openStream()
.use { inputStream -> inputStream.copyTo(FileOutputStream(pluginResources.kaitaiRootCompilerZip)) }
}
}
}
doLast {
locksService.getLock("extractKaitaiPackage").withLock {
if (!pluginResources.kaitaiRootCompilerDirectory.exists()) {
project.copy {
from(project.zipTree(pluginResources.kaitaiRootCompilerZip))
into(pluginResources.kaitaiRootCompilerDirectory)
}
}
val classLoader: ClassLoader = KaitaiPlugin::class.java.classLoader
PluginUtils.copyResourceFile(
classLoader,
"io/model9/backup/gradle/kaitai/kaitai.sh",
pluginResources.kaitaiScriptFile.absolutePath,
true)
}
}
}
Might be a bit hackish. I'm using a service to make sure this task does not run in parallel where it shouldn't.Vampire
07/26/2024, 3:14 PMNO-SOURCE, so you probably configure more to it later.Vampire
07/26/2024, 3:15 PMdoFirst and doLast the line inputs.files().skipWhenEmpty(), then it will indeed always be skipped with NO-SOURCE and never download the fileRoded Bahat
07/26/2024, 3:49 PMoutputs.dir(pluginResources.kaitaiRootDirectory)
outputs.cacheIf { true }
Sorry for the possible mixup.
Next, I'll try declaring the task's inputs as the URL and the outputs as above to try to get the task to cache and never skip. I'll also do as you suggest with regards to to the service usage.
As always, many thanks for the help @Vampire. Your assistance is really invaluable. I'll report back with findings.Vampire
07/26/2024, 3:51 PMNO-SOURCE is about inputs, not outputs.
If there were not inputs defined, those two lines should make the task cacheable indeed afairRoded Bahat
07/26/2024, 4:07 PMRoded Bahat
07/27/2024, 5:20 AMRoded Bahat
07/27/2024, 5:22 AMPluginUtils.copyResourceFile(
classLoader,
"io/model9/backup/gradle/kaitai/kaitai.sh",
pluginResources.kaitaiScriptFile.absolutePath,
true)
This is part of a task which copies a resource from the plugin's classpath into the project's build folder.
Is there a way to define its inputs properly?
Or should I just never cache it to make sure that changes in the script resource will always be applied?Vampire
07/27/2024, 8:55 AMoutputs.upToDateWhen { true } or similar, so to be on the safe side, just try it.Vampire
07/27/2024, 8:56 AM-i you are also told exactly why a task is out of dateRoded Bahat
07/27/2024, 5:30 PM