Details
Description
If I understand the StaleSourceScanner correctly, the parameter timestampDirectory should be unnecessary. The same effect of output generation only upon modified/updated grammar files could be achieved by comparing the timestamps of the grammar files against the timestamps of the java files (and not copies of the grammar files). The required code changes should be minimal, i.e. simply change lines like
SuffixMapping mapping = new SuffixMapping( ".jj", ".jj" );
to
SuffixMapping mapping = new SuffixMapping( ".jj", ".java" );
and pass the (base) output directory rather than the timestamp directory into computeStaleGrammars().
The proposed change should yield the same conditional output generation for the use case where the output directory is set to something under $
{basedir}/target. However, it should perform better for such use cases where the java files are generated into a non-temporary/version-controlled directory like ${basedir}/src/main/java. Currently, a "mvn clean generate-sources" will always trigger the generation of output regardless whether necessary or not because the timestamp files do not exist (any more). Taking the output files for the timestamp test should avoid this unwanted effect.
Issue Links
- relates to
-
PLXCOMP-85
Extend SourceMapping.getTargetFiles() to receive source directory
-
I think the problem is that the StaleSourceScanner compares files in matching directory structures. So what you are suggesting would work fine in most project setups, but in the occasional case where the package names of your generated files does not match the source location of the .jj files, the scanner would not be able to find them.
I think you would have to compare each file individually to get around this.