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) File
Source directory of the cup files.(package private) String
Regular expression of the cup files in thecupSourceDirectory
.private static final String
(package private) static final String
Default class name of the parser.(package private) static final String
Default class name of symbols holder.private boolean
Whether to force generation of parser and symbols.(package private) File
Name of the directory into which CUP should generate the parser.private final Logger
(package private) org.apache.maven.project.MavenProject
private static final String
In a CUP definition, the Java package is introduce by thepackage
keyword.(package private) String
(package private) boolean
Whether to output the symbol constant code as aninterface
rather than as aclass
.(package private) String
Fields 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 TypeMethodDescriptionvoid
execute()
private String
findJavaPackage
(File cupFile) (package private) void
generateParser
(File cupFile) private File
getAbsolutePath
(File path) Converts the specified path argument into an absolute path.private File[]
Returns the cup source files.private boolean
isGeneratedCodeOutdated
(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 thepackage
keyword.- 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 aninterface
rather 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.MojoExecutionException
org.apache.maven.plugin.MojoFailureException
-
generateParser
void generateParser(File cupFile) throws IOException, org.apache.maven.plugin.MojoExecutionException - Parameters:
cupFile
- CUP definition file- Throws:
IOException
org.apache.maven.plugin.MojoExecutionException
-
isGeneratedCodeOutdated
-
findJavaPackage
- Throws:
IOException
-
optionalJavaPackage
-
getSources
Returns the cup source files.- Returns:
- the files in the
cupSourceDirectory
directory 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.
-