Hi guys,
Please help me with an issue. I have the following code snippet:
class ProcessDescriptors extends DefaultTask {
@InputFiles
FileCollection descriptorsFiles
@OutputDirectory
DirectoryProperty outputDir
ProcessDescriptors() {
outputDir = getProject().objects.directoryProperty()
descriptorsFiles = getProject().objects.fileCollection()
}
@TaskAction
void exec()
{
def tmpFile = new File(temporaryDir, 'kitslist.txt')
tmpFile.withWriter { writer ->
descriptorsFiles.each { line ->
writer.println line
}
}
project.javaexec {
main = 'com.util.DescriptorTranslator'
classpath = project.configurations.someConfiguration
args = ["@$tmpFile", "-d", outputDir.get()]
}
}
}
//used like this
task compileKitsDescriptors(type: ProcessDescriptors) {
outputDir = file("${workspaceRoot}/compile/");
descriptorsFiles = project.fileTree(dir: projectDir,
includes: ["**/source/**/descr/**/*.xml", "DBA/main/resources/**/descr/**/*.xml"],
excludes: ["SOMEDIR/**", "**/source/**/myxml.xml", "**/source/**/mydir/**"])
}
The issue with this the task is that when I pass a fileTree to descriptorsFiles property it scans the base directory for files twice: during up-to-date check and when used. So the question: Is there is any way to store its state once evaluated? Using Gradle 5.6.2