I have a custom task that compiles Sass stylesheets. These stylesheets can contain various “@import”-Statements, that usually point somewhere within a “node_modules” directory. “node_modules” in the parent directories will also be considered, as per NodeJS “require” semantics. There may also be transitive imports.
Therefore, it’s difficult for me to predict which files should be considered inputs for my task. I tried adding
$projectDir/**/*.scss, but not unsurprisingly, that leads to some overhead, each Sass-Task then takes about 700ms to consider its inputs, even if it is UP-TO-DATE.
I can however easily hook into the Sass compiler and get notified about all imports, so I can provide the list of input files after the task has been run. But Gradle of course needs the information beforehand to decide if it should run the task at all. Is there a good way to hook this up with Gradle?