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 Details

    • PACKAGE_DEFINITION

      private static final String PACKAGE_DEFINITION
      In a CUP definition, the Java package is introduce by the package keyword.
      See Also:
    • DEFAULT_JAVA_PACKAGE

      private static final String DEFAULT_JAVA_PACKAGE
      See Also:
    • DEFAULT_PARSER_NAME

      static final String DEFAULT_PARSER_NAME
      Default class name of the parser. Note that CUP uses a lower-case class name.
      See Also:
    • DEFAULT_SYMBOLS_NAME

      static final String DEFAULT_SYMBOLS_NAME
      Default class name of symbols holder. Note that CUP uses a lower-case class name.
      See Also:
    • cupSourceDirectory

      @Parameter(defaultValue="${project.basedir}/src/main/cup") File cupSourceDirectory
      Source directory of the cup files.
    • cupSourceFilesFilter

      @Parameter(defaultValue=".*\\.cup") String cupSourceFilesFilter
      Regular expression of the cup files in the cupSourceDirectory.
    • generatedSourcesDirectory

      @Parameter(defaultValue="${project.build.directory}/generated-sources/cup") File generatedSourcesDirectory
      Name of the directory into which CUP should generate the parser.
    • symbolInterface

      @Parameter(defaultValue="false") boolean symbolInterface
      Whether to output the symbol constant code as an interface rather than as a class.
    • symbolsName

      @Parameter(defaultValue="sym") String symbolsName
    • parserName

      @Parameter(defaultValue="parser") 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 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

      private boolean isGeneratedCodeOutdated(File cupFile, String javaPackage)
    • findJavaPackage

      private String findJavaPackage(File cupFile) throws IOException
      Throws:
      IOException
    • optionalJavaPackage

      com.google.common.base.Optional<String> optionalJavaPackage(String line)
    • getSources

      private File[] getSources() throws org.apache.maven.plugin.MojoFailureException
      Returns the cup source files.
      Returns:
      the files in the cupSourceDirectory directory that match cupSourceFilesFilter.
      Throws:
      org.apache.maven.plugin.MojoFailureException
    • getAbsolutePath

      private File getAbsolutePath(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 be null.
      Returns:
      The absolute path corresponding to the input argument.