in jelly-tags/antlr/src/main/java/org/apache/commons/jelly/tags/antlr/AntlrTag.java [53:118]
public void doTag(final XMLOutput output) throws MissingAttributeException, JellyTagException
{
if ( this.outputDir == null )
{
throw new MissingAttributeException( "outputDir" );
}
invokeBody( output );
Iterator grammarIter = this.grammars.iterator();
String eachGrammar = null;
String sourceDir = (String) getContext().getVariable( "maven.antlr.src.dir" );
File grammar = null;
while ( grammarIter.hasNext() )
{
eachGrammar = ((String) grammarIter.next()).trim();
grammar = new File( sourceDir,
eachGrammar );
File generated = getGeneratedFile( grammar.getPath() );
if ( generated.exists() )
{
if ( generated.lastModified() > grammar.lastModified() )
{
// it's more recent, skip.
return;
}
}
if ( ! generated.getParentFile().exists() )
{
generated.getParentFile().mkdirs();
}
String[] args = new String[]
{
"-o",
generated.getParentFile().getPath(),
grammar.getPath(),
};
SecurityManager oldSm = System.getSecurityManager();
System.setSecurityManager( NoExitSecurityManager.INSTANCE );
try
{
Tool.main( args );
}
catch (SecurityException e)
{
if ( ! e.getMessage().equals( "exitVM-0" ) )
{
throw new JellyTagException( e );
}
}
finally
{
System.setSecurityManager( oldSm );
}
}
}