[
http://jira.codehaus.org/browse/MJAVACC-30?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Benjamin Bentmann updated MJAVACC-30:
-------------------------------------
Attachment: stale-source-scanner.patch
Unfortunately, Plexus' SourceMapping does not offer a method like
getTargetFiles( File targetDir, File sourceDir, String source ) so my current
solution is not really pretty.
The new file JavaCCGrammarInfo is intended to replace JavaCCUtil (from which
most of its code is copied). In addition to determing the package name for a
parser file, it also gets the parser name. Having both pieces of information in
a single bean (and possibly avoiding multiple scans of the grammar file
contents) is the sole purpose of this class.
The algo to get the parser name is currently simplistic: It just assumes that
"MyParser.jj" produces "MyParser.java". A proper solution would be to get the
PARSER_BEGIN() statement from the grammar file. The corresponding Ant task also
follows the simplistic filename based approach and apparently works well
enough, so excuse my lazyness.
The major part of the (yet incomplete) patch is JavaCCSourceMapping. It is fed
with the source directory being scanned (to workaround the above mentioned
limitation of SourceMapping) and the package name configured for the plugin.
Now, JavaCCSourceMapping can point the StaleSourceScanner to the actual output
files of javacc.
To integrate this into the JavaCCMojo, the following changes to
computeStaleGrammars() should be sufficient:{code}
SourceMapping mapping = new JavaCCSourceMapping( sourceDir, packageName );
SourceInclusionScanner scanner = new StaleSourceScanner( staleMillis, includes,
excludes );
scanner.addSourceMapping( mapping );
{code}
Wouldn't this work for everybody?
> Use generated Java files themselves for stale source detection
> --------------------------------------------------------------
>
> Key: MJAVACC-30
> URL: http://jira.codehaus.org/browse/MJAVACC-30
> Project: Maven 2.x JavaCC Plugin
> Issue Type: Improvement
> Affects Versions: 2.2
> Environment: Maven 2.0.7, JDK 1.5.0_12, WinXP
> Reporter: Benjamin Bentmann
> Priority: Minor
> Attachments: stale-source-scanner.patch
>
>
> 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 {code}SuffixMapping mapping
> = new SuffixMapping( ".jj", ".jj" );{code} to {code}SuffixMapping mapping =
> new SuffixMapping( ".jj", ".java" );{code} 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.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email