Class AbstractJavaGeneratorMojo

  • All Implemented Interfaces:
    org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo
    Direct Known Subclasses:
    ActorExecutionMojo, ApplyActorMojo

    public abstract class AbstractJavaGeneratorMojo
    extends AbstractAdamsMojo

    Abstract superclass for Mojos generating Java source

    Based on jaxb2-maven-plugin code.
    Author:
    Lennart Jörelid, FracPete (fracpete at waikato dot ac dot nz)
    • Field Detail

      • environmentClass

        @Parameter(defaultValue="adams.env.Environment",
                   required=true)
        protected String environmentClass

        The ADAMS environment class to use.

      • packageName

        @Parameter
        protected String packageName

        The package under which the source files will be generated.

    • Constructor Detail

      • AbstractJavaGeneratorMojo

        public AbstractJavaGeneratorMojo()
    • Method Detail

      • isReGenerationRequired

        protected boolean isReGenerationRequired()

        Java generation is required if any of the file products is outdated/stale.

        Specified by:
        isReGenerationRequired in class AbstractAdamsMojo
        Returns:
        true to indicate that this AbstractAdamsMojo should be run since its generated files were either stale or not present, and false otherwise.
      • generateCode

        protected abstract boolean generateCode()
                                         throws org.apache.maven.plugin.MojoExecutionException
        Generates the actual code.
        Returns:
        true if successfully generated
        Throws:
        org.apache.maven.plugin.MojoExecutionException - if code generation fails
      • performExecution

        protected boolean performExecution()
                                    throws org.apache.maven.plugin.MojoExecutionException,
                                           org.apache.maven.plugin.MojoFailureException

        Implement this method to perform this Mojo's execution. This method will only be called if !shouldExecutionBeSkipped() && isReGenerationRequired().

        Specified by:
        performExecution in class AbstractAdamsMojo
        Returns:
        true if the timestamp of the stale file should be updated.
        Throws:
        org.apache.maven.plugin.MojoExecutionException - if an unexpected problem occurs. Throwing this exception causes a "BUILD ERROR" message to be displayed.
        org.apache.maven.plugin.MojoFailureException - if an expected problem (such as a compilation failure) occurs. Throwing this exception causes a "BUILD FAILURE" message to be displayed.
      • getSources

        protected abstract List<URL> getSources()
        Override this method to acquire a List holding all URLs to the sources for which this AbstractJavaGeneratorMojo should generate Java files. Sources are assumed to be in the form given by the sourceType value.
        Returns:
        A non-null List holding URLs to sources for the code generation.
      • addGeneratedSourcesToProjectSourceRoot

        protected abstract void addGeneratedSourcesToProjectSourceRoot()
        Adds any directories containing the generated classes to the appropriate Project compilation sources; either TestCompileSourceRoot or CompileSourceRoot depending on the exact Mojo implementation of this AbstractJavaGeneratorMojo.