Kelvin Chung
06/27/2024, 10:09 PMval task1 by tasks.registering(Zip::class) {
from(project.findProperty("sourcePath") as String?)
}
val task2 by tasks.registering(MyOtherTask::class) {
inputProperty.set(task1.flatMap { it.archiveFile }) // @get:InputFile
}
I'm seeing an error saying that inputProperty isn't properly set because the file doesn't exist; is it because of something relating to the configuration of task1 ? Should I work around this issue by subclassing Zip for task1?Vampire
06/27/2024, 10:27 PMZip would make any sense or change anything.
What is "the error saying" exactly?
Lightly quoted error messages are usually just increasing confusion, always provide a verbatim copy.
Best would be a build --scan URL, even better combined with an MCVE.Kelvin Chung
06/27/2024, 10:32 PMA problem was found with the cnfiguration of task 'task2' (type 'MyOtherTask').
- In plugin 'myPlugin' type 'MyOtherTask' property 'inputProperty' specifies file '<some file path>' which doesn't exist.
Reason: An input file was expected to be present but it doesn't existVampire
06/27/2024, 10:33 PMtask1 executing?Kelvin Chung
06/27/2024, 10:34 PMNO-SOURCE was reported, which is part of the problem, I suppose.Vampire
06/27/2024, 10:35 PMZip task does not want to create an empty Zip but skips its work if nothing is to be put inside the Zip, which then make task2 unhappy.Vampire
06/27/2024, 10:35 PMKelvin Chung
06/27/2024, 10:37 PMonlyIf to try and skip task2, that seems sane.Vampire
06/27/2024, 10:38 PMonlyIf is checked before that error is reported or after. (If the latter, there are further mitigation strategies)Kelvin Chung
06/27/2024, 10:54 PMonlyIf { task1.flatMap { it.archiveFile }.isPresent }
didn't work. I could try
onlyIf { task1.flatMap { it.archiveFile }.get().asFile.exists() }
but that seems wrong somehow.Vampire
06/27/2024, 10:55 PMisPresent is pointless.
That checks whether a value is configured and you configured a value.
The point is, that the file is not there that is configured.Vampire
06/27/2024, 10:56 PMflatMap though, you can directly use get().
onlyIf is executed at execution time.Vampire
06/27/2024, 10:57 PMKelvin Chung
06/27/2024, 11:05 PMtask1 or somesuch.Vampire
06/27/2024, 11:11 PMtask1 output property, but the own inputProperty, that should then probably work.Vampire
06/27/2024, 11:11 PMonlyIf is checked firstKelvin Chung
06/27/2024, 11:12 PMonlyIf { task1.get().didWork }
it looks OKVampire
06/27/2024, 11:13 PMVampire
06/27/2024, 11:13 PMVampire
06/27/2024, 11:13 PMonlyIf checkKelvin Chung
06/27/2024, 11:17 PMonlyIf block.Philip W
06/28/2024, 8:19 AMVampire
06/28/2024, 8:28 AM