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.AbstractMojo
Creates a Java parser from CUP definition, using CUP.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate CliCupInvoker(package private) FileSource directory of the cup files.(package private) StringRegular expression of the cup files in thecupSourceDirectory.private static final String(package private) static final StringDefault class name of the parser.(package private) static final StringDefault class name of symbols holder.private booleanWhether to force generation of parser and symbols.(package private) FileName of the directory into which CUP should generate the parser.private final Logger(package private) org.apache.maven.project.MavenProjectprivate static final StringIn a CUP definition, the Java package is introduce by thepackagekeyword.(package private) String(package private) booleanWhether to output the symbol constant code as aninterfacerather than as aclass.(package private) StringFields inherited from interface org.apache.maven.plugin.Mojo
ROLE -
Constructor Summary
ConstructorsConstructorDescriptionGenerateMojo(CliCupInvoker cupInvoker, org.apache.maven.plugin.logging.Log logger) -
Method Summary
Modifier and TypeMethodDescriptionvoidexecute()private StringfindJavaPackage(File cupFile) (package private) voidgenerateParser(File cupFile) private FilegetAbsolutePath(File path) Converts the specified path argument into an absolute path.private File[]Returns the cup source files.private booleanisGeneratedCodeOutdated(File cupFile, String javaPackage) (package private) com.google.common.base.Optional<String> optionalJavaPackage(String line) Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Field Details
-
PACKAGE_DEFINITION
In a CUP definition, the Java package is introduce by thepackagekeyword.- See Also:
-
DEFAULT_JAVA_PACKAGE
- See Also:
-
DEFAULT_PARSER_NAME
Default class name of the parser. Note that CUP uses a lower-case class name.- See Also:
-
DEFAULT_SYMBOLS_NAME
Default class name of symbols holder. Note that CUP uses a lower-case class name.- See Also:
-
cupSourceDirectory
Source directory of the cup files. -
cupSourceFilesFilter
Regular expression of the cup files in thecupSourceDirectory. -
generatedSourcesDirectory
@Parameter(defaultValue="${project.build.directory}/generated-sources/cup") File generatedSourcesDirectoryName of the directory into which CUP should generate the parser. -
symbolInterface
@Parameter(defaultValue="false") boolean symbolInterfaceWhether to output the symbol constant code as aninterfacerather than as aclass. -
symbolsName
-
parserName
-
mavenProject
@Parameter(property="project", required=true, readonly=true) org.apache.maven.project.MavenProject mavenProject -
force
@Parameter(defaultValue="false") private boolean forceWhether to force generation of parser and symbols. -
cupInvoker
-
log
-
-
Constructor Details
-
GenerateMojo
public GenerateMojo() -
GenerateMojo
GenerateMojo(CliCupInvoker cupInvoker, org.apache.maven.plugin.logging.Log logger)
-
-
Method Details
-
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(File cupFile) throws IOException, org.apache.maven.plugin.MojoExecutionException - Parameters:
cupFile- CUP definition file- Throws:
IOExceptionorg.apache.maven.plugin.MojoExecutionException
-
isGeneratedCodeOutdated
-
findJavaPackage
- Throws:
IOException
-
optionalJavaPackage
-
getSources
Returns the cup source files.- Returns:
- the files in the
cupSourceDirectorydirectory that matchcupSourceFilesFilter. - Throws:
org.apache.maven.plugin.MojoFailureException
-
getAbsolutePath
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.
-