My grammer resides in src/main/sablecc/a/b/c/X.grammar and will be
copied to the target/ directory for stale detection.
This will not work correctly because the "StaleSourceScanner" will try
to match
src/main/sablecc/a/b/c/X.grammar with target/a/b/c/X.grammar which does
not exist, on the next call.
FIX: create the correct package-structure in /target
[SableCCMojo]
// must create the same package-structure as the grammar
FileUtils.copyFileToDirectory(grammar, new
File(timestampDirectory));
private Set computeStaleGrammars() throws MojoExecutionException
{
SuffixMapping mapping = new SuffixMapping( ".grammar", ".grammar"
);
SourceInclusionScanner scanner = new StaleSourceScanner(
staleMillis );
scanner.addSourceMapping( mapping );
File outDir = new File( timestampDirectory );
Set staleSources = new HashSet();
File sourceDir = new File( sourceDirectory );
try
{
staleSources.addAll( scanner.getIncludedSources( sourceDir,
outDir ) );
}
catch ( InclusionScanException e )
{
throw new MojoExecutionException( "Error scanning source root:
\'" + sourceDir + "\' for stale grammars to reprocess.", e );
}
return staleSources;
}