Class AbstractAdamsMojo

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

    public abstract class AbstractAdamsMojo
    extends org.apache.maven.plugin.AbstractMojo
    Abstract Mojo which collects common infrastructure, required and needed by all subclass Mojos in the adams maven plugin codebase. Based on jaxb2-maven-plugin code.
    Author:
    Lennart Jörelid, FracPete (fracpete at waikato dot ac dot nz)
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static String NEWLINE
      Platform-independent newline control string.
      • Fields inherited from interface org.apache.maven.plugin.Mojo

        ROLE
    • Field Detail

      • NEWLINE

        public static final String NEWLINE
        Platform-independent newline control string.
    • Constructor Detail

      • AbstractAdamsMojo

        public AbstractAdamsMojo()
    • Method Detail

      • addResource

        protected abstract void addResource​(org.apache.maven.model.Resource resource)
        Adds the supplied Resource to the project using the appropriate scope (i.e. resource or testResource) depending on the exact implementation of this AbstractAdamsMojo.
        Parameters:
        resource - The resource to add.
      • getBuildContext

        protected final org.sonatype.plexus.build.incremental.BuildContext getBuildContext()
        The Plexus BuildContext is used to identify files or directories modified since last build, implying functionality used to define if java generation must be performed again.
        Returns:
        the active Plexus BuildContext.
      • getProject

        protected final org.apache.maven.project.MavenProject getProject()
        Returns:
        The active MavenProject.
      • getExecution

        public org.apache.maven.plugin.MojoExecution getExecution()
        Returns:
        The active MojoExecution.
      • execute

        public final void execute()
                           throws org.apache.maven.plugin.MojoExecutionException,
                                  org.apache.maven.plugin.MojoFailureException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
        org.apache.maven.plugin.MojoFailureException
      • shouldExecutionBeSkipped

        protected abstract boolean shouldExecutionBeSkipped()
        Implement this method to check if this AbstractAdamsMojo should skip executing altogether.
        Returns:
        true to indicate that this AbstractAdamsMojo should bail out of its execute method.
      • isReGenerationRequired

        protected abstract boolean isReGenerationRequired()
        Returns:
        true to indicate that this AbstractAdamsMojo should be run since its generated files were either stale or not present, and false otherwise.
      • performExecution

        protected abstract 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().

        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.
      • getOutputDirectory

        protected abstract File getOutputDirectory()
        Retrieves the directory where the generated files should be written to.
        Returns:
        the directory where the generated files should be written to.
      • getClasspath

        protected List<String> getClasspath()
                                     throws org.apache.maven.plugin.MojoExecutionException
        Returns the classpath parts that can be used for launching a Java process.
        Returns:
        the classpath parts
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • warnAboutIncorrectPluginConfiguration

        protected void warnAboutIncorrectPluginConfiguration​(String propertyName,
                                                             String description)
        Convenience method to invoke when some plugin configuration is incorrect. Will output the problem as a warning with some degree of log formatting.
        Parameters:
        propertyName - The name of the problematic property.
        description - The problem description.
      • logSystemPropertiesAndBasedir

        protected void logSystemPropertiesAndBasedir()
        Prints out the system properties to the Maven Log at Debug level.