Custom incremental task: store something for next executions


I’m writing an incremental task to compile some files. Let’s suppose this case: two source files, Main and Lib, Main includes Lib.
When Lib is modified, I need to recompile Main.

I guess I should store some dependency graph somewhere, but I have no idea what is the best practice to do that with gradle:

  • Should I manage a file to hold this graph, and store it in the build directory => How to access the build directory from my task?
  • Can I store a Map<String, String> for this task/this project in gradle?
  • Or maybe there are some magic gradle mechanism to customize the FileChange detection ?

My task simply looks like that:

public abstract class GradleCompile extends DefaultTask
	abstract DirectoryProperty getInputDir();

	abstract DirectoryProperty getOutputDir();

	void compileShader(InputChanges inputChanges)
		final var inputDir = getInputDir();
		final var outputDir = getOutputDir();

		try (final var compiler = ShadercCompiler.newCompiler())
			for (final var change : inputChanges.getFileChanges(inputDir))
				if (change.getFileType() == FileType.FILE)
					compileFile(compiler, change, outputDir);
		} catch (final Exception e)