Class AbstractJlinkMojo

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

    public abstract class AbstractJlinkMojo
    extends org.tentackle.maven.AbstractTentackleMojo
    Base jlink mojo.
    Author:
    harald
    • Field Summary

      • Fields inherited from class org.tentackle.maven.AbstractTentackleMojo

        charset, resourceDirs, verbosity, verbosityLevel
      • 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
      protected void copyArtifacts​(JlinkResolver.Result result)
      Copies artifacts not already in the created jlink image to module- or classpath.
      protected abstract void createImage​(JlinkResolver.Result result)
      Creates the application image.
      void executeImpl()  
      java.util.List<java.lang.String> getAddModules()
      Gets extra jre or jdk modules to add to the image.
      protected java.io.File getApplicationDirectory()
      Gets the application directory.
      java.util.List<java.lang.String> getExcludeModules()
      Gets modules to exclude.
      abstract java.io.File getImageDirectory()
      Gets the directory created by jlink holding the image.
      java.io.File getJdepsTool()
      Gets the jdeps tool.
      org.codehaus.plexus.languages.java.jpms.LocationManager getLocationManager()
      Gets the location manager to extract module information.
      java.lang.String getMainClass()
      Gets the name of the main class.
      java.lang.String getMainModule()
      Gets the name of the module holding the main class.
      java.lang.String getNameTemplate()
      Gets the name of the name template.
      org.apache.maven.project.MavenProjectHelper getProjectHelper()
      Gets the project helper to attach artifacts.
      java.lang.String getRunTemplate()
      Gets the name of the runner template.
      java.io.File getTemplateDir()
      Gets the template directory.
      java.lang.String getUpdateTemplate()
      Gets the name of the update template.
      protected void installTemplates()
      Copies the templates to the template directory.
      Overwrites any existing templates.
      boolean isClasspathDependency​(org.apache.maven.artifact.Artifact artifact)
      Returns whether an artifact should be moved to the classpath explicitly.
      void prepareExecute()  
      protected boolean validate()  
      • Methods inherited from class org.tentackle.maven.AbstractTentackleMojo

        determineEncoding, determineVerbosity, execute, findResourceDirs, finishExecute, getCanonicalPath, getMavenProject, getMavenSession, getPathRelativeToBasedir, getResourceDirName, getSettings, getSettingsDecrypter, getToolChain, getToolchainManager, getToolFinder, loadResourceFileIntoString
      • 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
    • Constructor Detail

      • AbstractJlinkMojo

        public AbstractJlinkMojo()
    • Method Detail

      • getTemplateDir

        public java.io.File getTemplateDir()
        Gets the template directory.
        Returns:
        the directory holding the wizard templates
      • getImageDirectory

        public abstract java.io.File getImageDirectory()
        Gets the directory created by jlink holding the image.
        Returns:
        the image dir, never null
      • getMainModule

        public java.lang.String getMainModule()
        Gets the name of the module holding the main class.
        Returns:
        the main module, null to build an application running on the classpath
      • getMainClass

        public java.lang.String getMainClass()
        Gets the name of the main class.
        Returns:
        the main class, never null
      • getLocationManager

        public org.codehaus.plexus.languages.java.jpms.LocationManager getLocationManager()
        Gets the location manager to extract module information.
        Returns:
        the JPMS manager
      • getProjectHelper

        public org.apache.maven.project.MavenProjectHelper getProjectHelper()
        Gets the project helper to attach artifacts.
        Returns:
        the project helper
      • getJdepsTool

        public java.io.File getJdepsTool()
        Gets the jdeps tool.
        Returns:
        the file, never null
      • getNameTemplate

        public java.lang.String getNameTemplate()
        Gets the name of the name template.
        Returns:
        the template to generate the name of the runner script
      • getRunTemplate

        public java.lang.String getRunTemplate()
        Gets the name of the runner template.
        Returns:
        the template to generate the runner script
      • getUpdateTemplate

        public java.lang.String getUpdateTemplate()
        Gets the name of the update template.
        Returns:
        the template to generate the update script, null if none
      • getAddModules

        public java.util.List<java.lang.String> getAddModules()
        Gets extra jre or jdk modules to add to the image.
        Returns:
        extra module names, never null
      • getExcludeModules

        public java.util.List<java.lang.String> getExcludeModules()
        Gets modules to exclude.
        Returns:
        excluded module names, never null
      • prepareExecute

        public void prepareExecute()
                            throws org.apache.maven.plugin.MojoExecutionException,
                                   org.apache.maven.plugin.MojoFailureException
        Overrides:
        prepareExecute in class org.tentackle.maven.AbstractTentackleMojo
        Throws:
        org.apache.maven.plugin.MojoExecutionException
        org.apache.maven.plugin.MojoFailureException
      • executeImpl

        public void executeImpl()
                         throws org.apache.maven.plugin.MojoExecutionException,
                                org.apache.maven.plugin.MojoFailureException
        Specified by:
        executeImpl in class org.tentackle.maven.AbstractTentackleMojo
        Throws:
        org.apache.maven.plugin.MojoExecutionException
        org.apache.maven.plugin.MojoFailureException
      • createImage

        protected abstract void createImage​(JlinkResolver.Result result)
                                     throws org.apache.maven.plugin.MojoExecutionException,
                                            org.apache.maven.plugin.MojoFailureException
        Creates the application image.
        Parameters:
        result - the resolver info
        Throws:
        org.apache.maven.plugin.MojoExecutionException - if building the JPMS info failed
        org.apache.maven.plugin.MojoFailureException - if jlink returned an error code
      • getApplicationDirectory

        protected java.io.File getApplicationDirectory()
        Gets the application directory.
        Returns:
        the destination base directory for the application
      • copyArtifacts

        protected void copyArtifacts​(JlinkResolver.Result result)
                              throws org.apache.maven.plugin.MojoExecutionException
        Copies artifacts not already in the created jlink image to module- or classpath.
        Parameters:
        result - the resolver info
        Throws:
        org.apache.maven.plugin.MojoExecutionException - if copy failed
      • validate

        protected boolean validate()
                            throws org.apache.maven.plugin.MojoExecutionException
        Overrides:
        validate in class org.tentackle.maven.AbstractTentackleMojo
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • isClasspathDependency

        public boolean isClasspathDependency​(org.apache.maven.artifact.Artifact artifact)
        Returns whether an artifact should be moved to the classpath explicitly.
        Parameters:
        artifact - the artifact
        Returns:
        true if move to classpath, else modulepath
      • installTemplates

        protected void installTemplates()
                                 throws org.apache.maven.plugin.MojoExecutionException
        Copies the templates to the template directory.
        Overwrites any existing templates.
        Throws:
        org.apache.maven.plugin.MojoExecutionException - if failed