Package jflex.maven.plugin.cup
Class GenerateMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- jflex.maven.plugin.cup.GenerateMojo
-
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled,org.apache.maven.plugin.Mojo
@Mojo(name="generate", defaultPhase=GENERATE_SOURCES, threadSafe=false) public class GenerateMojo extends org.apache.maven.plugin.AbstractMojoCreates a Java parser from CUP definition, using CUP.
-
-
Field Summary
Fields Modifier and Type Field Description private CliCupInvokercupInvoker(package private) java.io.FilecupSourceDirectorySource directory of the cup files.(package private) java.lang.StringcupSourceFilesFilterRegular expression of the cup files in thecupSourceDirectory.private static java.lang.StringDEFAULT_JAVA_PACKAGE(package private) static java.lang.StringDEFAULT_PARSER_NAMEDefault class name of the parser.(package private) static java.lang.StringDEFAULT_SYMBOLS_NAMEDefault class name of symbols holder.private booleanforceWhether to force generation of parser and symbols.(package private) java.io.FilegeneratedSourcesDirectoryName of the directory into which CUP should generate the parser.private Loggerlog(package private) org.apache.maven.project.MavenProjectmavenProjectprivate static java.lang.StringPACKAGE_DEFINITIONIn a CUP definition, the Java package is introduce by thepackagekeyword.(package private) java.lang.StringparserName(package private) booleansymbolInterfaceWhether to output the symbol constant code as aninterfacerather than as aclass.(package private) java.lang.StringsymbolsName
-
Constructor Summary
Constructors Constructor Description GenerateMojo()GenerateMojo(CliCupInvoker cupInvoker, org.apache.maven.plugin.logging.Log logger)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidexecute()private java.lang.StringfindJavaPackage(java.io.File cupFile)(package private) voidgenerateParser(java.io.File cupFile)private java.io.FilegetAbsolutePath(java.io.File path)Converts the specified path argument into an absolute path.private java.io.File[]getSources()Returns the cup source files.private booleanisGeneratedCodeOutdated(java.io.File cupFile, java.lang.String javaPackage)(package private) com.google.common.base.Optional<java.lang.String>optionalJavaPackage(java.lang.String line)
-
-
-
Field Detail
-
PACKAGE_DEFINITION
private static final java.lang.String PACKAGE_DEFINITION
In a CUP definition, the Java package is introduce by thepackagekeyword.- See Also:
- Constant Field Values
-
DEFAULT_JAVA_PACKAGE
private static final java.lang.String DEFAULT_JAVA_PACKAGE
- See Also:
- Constant Field Values
-
DEFAULT_PARSER_NAME
static final java.lang.String DEFAULT_PARSER_NAME
Default class name of the parser. Note that CUP uses a lower-case class name.- See Also:
- Constant Field Values
-
DEFAULT_SYMBOLS_NAME
static final java.lang.String DEFAULT_SYMBOLS_NAME
Default class name of symbols holder. Note that CUP uses a lower-case class name.- See Also:
- Constant Field Values
-
cupSourceDirectory
@Parameter(defaultValue="${project.basedir}/src/main/cup") java.io.File cupSourceDirectorySource directory of the cup files.
-
cupSourceFilesFilter
@Parameter(defaultValue=".*\\.cup") java.lang.String cupSourceFilesFilter
Regular expression of the cup files in thecupSourceDirectory.
-
generatedSourcesDirectory
@Parameter(defaultValue="${project.build.directory}/generated-sources/cup") java.io.File generatedSourcesDirectoryName of the directory into which CUP should generate the parser.
-
symbolInterface
@Parameter(defaultValue="false") boolean symbolInterface
Whether to output the symbol constant code as aninterfacerather than as aclass.
-
symbolsName
@Parameter(defaultValue="sym") java.lang.String symbolsName
-
parserName
@Parameter(defaultValue="parser") java.lang.String parserName
-
mavenProject
@Parameter(property="project", required=true, readonly=true) org.apache.maven.project.MavenProject mavenProject
-
force
@Parameter(defaultValue="false") private boolean force
Whether to force generation of parser and symbols.
-
cupInvoker
private CliCupInvoker cupInvoker
-
log
private final Logger log
-
-
Constructor Detail
-
GenerateMojo
public GenerateMojo()
-
GenerateMojo
GenerateMojo(CliCupInvoker cupInvoker, org.apache.maven.plugin.logging.Log logger)
-
-
Method Detail
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException- Throws:
org.apache.maven.plugin.MojoExecutionExceptionorg.apache.maven.plugin.MojoFailureException
-
generateParser
void generateParser(java.io.File cupFile) throws java.io.IOException, org.apache.maven.plugin.MojoExecutionException- Parameters:
cupFile- CUP definition file- Throws:
java.io.IOExceptionorg.apache.maven.plugin.MojoExecutionException
-
isGeneratedCodeOutdated
private boolean isGeneratedCodeOutdated(java.io.File cupFile, java.lang.String javaPackage)
-
findJavaPackage
private java.lang.String findJavaPackage(java.io.File cupFile) throws java.io.IOException- Throws:
java.io.IOException
-
optionalJavaPackage
com.google.common.base.Optional<java.lang.String> optionalJavaPackage(java.lang.String line)
-
getSources
private java.io.File[] getSources() throws org.apache.maven.plugin.MojoFailureExceptionReturns the cup source files.- Returns:
- the files in the
cupSourceDirectorydirectory that matchcupSourceFilesFilter. - Throws:
org.apache.maven.plugin.MojoFailureException
-
getAbsolutePath
private java.io.File getAbsolutePath(java.io.File path)
Converts the specified path argument into an absolute path. If the path is relative like "src/main/jflex", it is resolved against the base directory of the mavenProject (in constrast, File.getAbsoluteFile() would resolve against the current directory which may be different, especially during a reactor build).- Parameters:
path- The path argument to convert, may benull.- Returns:
- The absolute path corresponding to the input argument.
-
-