Class AbstractTentackleMojo

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

    public abstract class AbstractTentackleMojo
    extends org.apache.maven.plugin.AbstractMojo
    Base tentackle mojo.
    Author:
    harald
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.String charset
      The encode used to read and write files.
      protected java.util.List<java.lang.String> resourceDirs
      List of resource dirs.
      protected java.lang.String verbosity
      The verbosity.
      One of "default", "info" or "debug".
      protected org.wurbelizer.misc.Verbosity verbosityLevel
      mapped verbosity level.
      • Fields inherited from interface org.apache.maven.plugin.Mojo

        ROLE
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void determineEncoding()
      Determines the encode charset.
      void determineVerbosity()
      sets the verbosity.
      void execute()  
      abstract void executeImpl()
      Implements the execution.
      TT-mojos must override this method instead of execute().
      void findResourceDirs()
      Finds all resource directories.
      void finishExecute()
      Finishes the execution.
      The method is invoked after executeImpl().
      java.lang.String getCanonicalPath​(java.io.File dir)
      Gets the canonical path of diven directory.
      org.apache.maven.project.MavenProject getMavenProject()
      Gets the maven project.
      org.apache.maven.execution.MavenSession getMavenSession()
      Gets the maven session.
      java.lang.String getPathRelativeToBasedir​(java.lang.String path)
      Gets the path relative to the basedir.
      Parent dirs of the basedir will also be tried.
      java.lang.String getResourceDirName​(java.lang.String dirName)
      Checks if given directory resides in resources.
      org.apache.maven.settings.Settings getSettings()
      Gets the maven settings.
      org.apache.maven.settings.crypto.SettingsDecrypter getSettingsDecrypter()
      Decrypter for credentials in settings.xml.
      org.apache.maven.toolchain.Toolchain getToolChain()
      Gets the toolchain.
      org.apache.maven.toolchain.ToolchainManager getToolchainManager()
      Gets the toolchain manager.
      ToolFinder getToolFinder()
      Gets the toolfinder to locate tools like java, jdeps, jlink, etc.
      java.lang.String loadResourceFileIntoString​(java.lang.String path)
      Loads a resource file into a string.
      void prepareExecute()
      Prepares the execution.
      Invoked before validate().
      protected boolean validate()
      Checks the configuration.
      • Methods inherited from class org.apache.maven.plugin.AbstractMojo

        getLog, getPluginContext, setLog, setPluginContext
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • verbosity

        @Parameter(defaultValue="${tentackle.verbosity}")
        protected java.lang.String verbosity
        The verbosity.
        One of "default", "info" or "debug". Debus is also turned on (if not set explicitly) by Maven's global debug flag (see command line switch -X).
      • charset

        @Parameter(defaultValue="${project.build.sourceEncoding}")
        protected java.lang.String charset
        The encode used to read and write files.
      • verbosityLevel

        protected org.wurbelizer.misc.Verbosity verbosityLevel
        mapped verbosity level.
      • resourceDirs

        protected java.util.List<java.lang.String> resourceDirs
        List of resource dirs.
    • Constructor Detail

      • AbstractTentackleMojo

        public AbstractTentackleMojo()
    • Method Detail

      • getMavenProject

        public org.apache.maven.project.MavenProject getMavenProject()
        Gets the maven project.
        Returns:
        the project, never null
      • getSettings

        public org.apache.maven.settings.Settings getSettings()
        Gets the maven settings.
        Returns:
        the settings from settings.xml
      • getSettingsDecrypter

        public org.apache.maven.settings.crypto.SettingsDecrypter getSettingsDecrypter()
        Decrypter for credentials in settings.xml.
        Returns:
        the settings decrypter
      • getMavenSession

        public org.apache.maven.execution.MavenSession getMavenSession()
        Gets the maven session.
        Returns:
        the session, never null
      • getToolchainManager

        public org.apache.maven.toolchain.ToolchainManager getToolchainManager()
        Gets the toolchain manager.
        Returns:
        the manager, never null
      • getToolChain

        public org.apache.maven.toolchain.Toolchain getToolChain()
        Gets the toolchain.
        Returns:
        the toolchain, null if none
      • 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
      • prepareExecute

        public void prepareExecute()
                            throws org.apache.maven.plugin.MojoExecutionException,
                                   org.apache.maven.plugin.MojoFailureException
        Prepares the execution.
        Invoked before validate().
        Throws:
        org.apache.maven.plugin.MojoExecutionException - if an unexpected problem occurs.
        org.apache.maven.plugin.MojoFailureException - if an expected problem occurs.
      • executeImpl

        public abstract void executeImpl()
                                  throws org.apache.maven.plugin.MojoExecutionException,
                                         org.apache.maven.plugin.MojoFailureException
        Implements the execution.
        TT-mojos must override this method instead of execute(). This method is only invoked if validation succeeds.
        Throws:
        org.apache.maven.plugin.MojoExecutionException - if an unexpected problem occurs
        org.apache.maven.plugin.MojoFailureException - if an expected problem (such as a compilation failure) occurs
        See Also:
        prepareExecute()
      • finishExecute

        public void finishExecute()
                           throws org.apache.maven.plugin.MojoExecutionException,
                                  org.apache.maven.plugin.MojoFailureException
        Finishes the execution.
        The method is invoked after executeImpl().
        Throws:
        org.apache.maven.plugin.MojoExecutionException - if an unexpected problem occurs.
        org.apache.maven.plugin.MojoFailureException - if an expected problem occurs.
      • determineEncoding

        public void determineEncoding()
        Determines the encode charset.
      • determineVerbosity

        public void determineVerbosity()
        sets the verbosity.
      • getPathRelativeToBasedir

        public java.lang.String getPathRelativeToBasedir​(java.lang.String path)
        Gets the path relative to the basedir.
        Parent dirs of the basedir will also be tried.
        Parameters:
        path - the absolute path
        Returns:
        the shortened path
      • findResourceDirs

        public void findResourceDirs()
        Finds all resource directories.
      • getResourceDirName

        public java.lang.String getResourceDirName​(java.lang.String dirName)
        Checks if given directory resides in resources.
        Parameters:
        dirName - the directory name
        Returns:
        the resource dir, null if not a resource
      • getCanonicalPath

        public java.lang.String getCanonicalPath​(java.io.File dir)
                                          throws org.apache.maven.plugin.MojoExecutionException
        Gets the canonical path of diven directory.
        Parameters:
        dir - the directory
        Returns:
        the path
        Throws:
        org.apache.maven.plugin.MojoExecutionException - if failed
      • validate

        protected boolean validate()
                            throws org.apache.maven.plugin.MojoExecutionException
        Checks the configuration.
        Returns:
        true if continue with execution, false to skip
        Throws:
        org.apache.maven.plugin.MojoExecutionException - if validation failed
      • getToolFinder

        public ToolFinder getToolFinder()
        Gets the toolfinder to locate tools like java, jdeps, jlink, etc.
        Returns:
        the toolfinder
      • loadResourceFileIntoString

        public java.lang.String loadResourceFileIntoString​(java.lang.String path)
                                                    throws org.apache.maven.plugin.MojoExecutionException
        Loads a resource file into a string.
        Parameters:
        path - the path to the resource file
        Returns:
        the contents
        Throws:
        org.apache.maven.plugin.MojoExecutionException