By "input KtFiles" I'm referring to the files: List<KtFile> parameters in CodeGeneratorExtension.doAnalysis(...) and CodeGeneratorExtension.onAnalysisCompleted(...).
For any given compilation, on the very first round of analysis/generation, the files parameter will roughly correspond to the incremental files from Gradle's InputChanges instance.
We should treat these files as changed because:
If they're also in our internal cache, with the same contents (MD5 hash), then there must be some reason that Gradle decided to pass them as input again and the compiler agreed. This is most likely because of a classpath change, either in a dependency project or an external library.
In this case, since Anvil uses classpath discovery to generate binding modules and merged interfaces, its expected output can easily change even if the source files in that module haven't.
If they come from InputChanges, they're changed by definition.
If they're input files, then we'll be generating code for them again anyway and it will be up-to-date.
With this change, a source file is considered to be unchanged (eligible for restoration) if it exists on the disk and in the cache with the same content hash and it wasn't passed as an input file. Since they aren't inputs, they won't be passed to the code generators, and we need to restore any downstream generated files from the cache.
fixes #898
By "input
KtFile
s" I'm referring to thefiles: List<KtFile>
parameters inCodeGeneratorExtension.doAnalysis(...)
andCodeGeneratorExtension.onAnalysisCompleted(...)
.For any given compilation, on the very first round of analysis/generation, the
files
parameter will roughly correspond to the incremental files from Gradle'sInputChanges
instance.We should treat these files as changed because:
If they're also in our internal cache, with the same contents (MD5 hash), then there must be some reason that Gradle decided to pass them as input again and the compiler agreed. This is most likely because of a classpath change, either in a dependency project or an external library.
In this case, since Anvil uses classpath discovery to generate binding modules and merged interfaces, its expected output can easily change even if the source files in that module haven't.
If they come from
InputChanges
, they're changed by definition.If they're input files, then we'll be generating code for them again anyway and it will be up-to-date.
With this change, a source file is considered to be unchanged (eligible for restoration) if it exists on the disk and in the cache with the same content hash and it wasn't passed as an input file. Since they aren't inputs, they won't be passed to the code generators, and we need to restore any downstream generated files from the cache.