Class AbstractPackageToolMojo

java.lang.Object
org.apache.maven.plugin.AbstractMojo
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo, org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable
Direct Known Subclasses:
JLinkMojo, JPackagerMojo

public abstract class AbstractPackageToolMojo
extends AbstractTemplateToolMojo
implements org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable
Author:
Karl Heinz Marbaise khmarbaise@apache.org, Bernd Eilers
  • Field Details

    • jvmArgs

      @Parameter(required=false, readonly=false) protected java.util.List<java.lang.String> jvmArgs
      JVM flags and options to pass to the application.

      --jvm-args <args>

    • arguments

      @Parameter(required=false, readonly=false) protected java.util.List<java.lang.String> arguments
      Command line arguments to pass to the main class if no arguments are specified by the launcher.

      --arguments <args>

    • packagingResources

      @Parameter protected PackagingResources packagingResources
      Resources to package into the image or installable package.

      You can use almost any configuration option that the Apache Maven Resources Plugin has on this setting.

      When filtering is set to true on a resource the Freemarker Java Template Engine is being used to filter the contents and some variables set by the packaging process are available to it.

      Hava a look at the Template Author's Guide for details on how to write templates.

    • sourceJdkModules

      @Parameter protected java.io.File sourceJdkModules
      Set the JDK location to create a Java custom runtime image.
    • JMODS

      protected static final java.lang.String JMODS
      Just a constant for the jmods directory name.
      See Also:
      Constant Field Values
    • finalName

      @Parameter(defaultValue="${project.build.finalName}", readonly=true) protected java.lang.String finalName
      Name of the generated ZIP file in the target directory. This will not change the name of the installed/deployed file.
    • ignoreAutomaticModules

      @Parameter(defaultValue="true") protected boolean ignoreAutomaticModules
      Flag to ignore automatic modules.
    • modulePaths

      @Parameter protected java.util.List<java.lang.String> modulePaths
      Include additional paths on the --module-path option. Project dependencies and JDK modules are automatically added.
    • limitModules

      @Parameter protected java.util.List<java.lang.String> limitModules
      Limit the universe of observable modules. The following gives an example of the configuration which can be used in the pom.xml file.
         <limitModules>
           <limitModule>mod1</limitModule>
           <limitModule>xyz</limitModule>
           .
           .
         </limitModules>
       

      This configuration is the equivalent of the command line option: --limit-modules <mod>[,<mod>...]

    • outputDirectory

      @Parameter(defaultValue="${project.build.outputDirectory}", required=true, readonly=true) protected java.io.File outputDirectory
    • addJDKToLimitModules

      @Parameter(defaultValue="false") protected boolean addJDKToLimitModules
      Toggle whether to add all modules in the java boot path to the limitModules setting.
    • jPacktoolMoveClassPathJars

      @Parameter(defaultValue="true") protected boolean jPacktoolMoveClassPathJars
      Flag if to move classpath jars from jpacktool-prepare goal
    • jPacktoolMoveAutomaticModules

      @Parameter(defaultValue="true") protected boolean jPacktoolMoveAutomaticModules
      Flag if to move real modules from jpacktool-prepare goal
    • jPacktoolMoveRealModules

      @Parameter(defaultValue="false") protected boolean jPacktoolMoveRealModules
      Flag if to move real modules from jpacktool-prepare goal. This can not be set to true when using jpackager because jpackager explicitly disallows modules in input directories.
    • addModules

      @Parameter protected java.util.List<java.lang.String> addModules

      Usually this is not necessary, cause this is handled automatically by the given dependencies.

      By using the --add-modules you can define the root modules to be resolved. The configuration in pom.xml file can look like this:

       <addModules>
         <addModule>mod1</addModule>
         <addModule>first</addModule>
         .
         .
       </addModules>
       

      The command line equivalent for jlink is: --add-modules <mod>[,<mod>...].

    • classPathFolderName

      @Parameter(defaultValue="jar") protected java.lang.String classPathFolderName
      Name of the classpath folder
    • automaticModulesFolderName

      @Parameter(defaultValue="jar_auto") protected java.lang.String automaticModulesFolderName
      Name of the automatic-modules folder
    • modulesFolderName

      @Parameter(defaultValue="jmods") protected java.lang.String modulesFolderName
      Name of the modules folder
    • unfilteredDependencyHandling

      @Parameter(defaultValue="false") protected boolean unfilteredDependencyHandling
      Fall back to using old unfiltered maven dependency handling.
    • buildContext

      @Component protected org.sonatype.plexus.build.incremental.BuildContext buildContext
      The JAR archiver needed for archiving the environments.
    • context

      protected org.codehaus.plexus.context.Context context
    • mavenResourcesFiltering

      @Component(role=org.apache.maven.shared.filtering.MavenResourcesFiltering.class, hint="default") public org.apache.maven.shared.filtering.MavenResourcesFiltering mavenResourcesFiltering
      The MavenResourcesFiltering Component.
    • mavenFileFilter

      @Component(role=org.apache.maven.shared.filtering.MavenFileFilter.class, hint="default") protected org.apache.maven.shared.filtering.MavenFileFilter mavenFileFilter
      The MavenFileFilter component.
    • dependencyGraphBuilder

      @Component(role=org.apache.maven.shared.dependency.graph.DependencyGraphBuilder.class, hint="maven31") protected org.apache.maven.shared.dependency.graph.DependencyGraphBuilder dependencyGraphBuilder
      The DependencyGraphBuilder component.
    • modulesToAdd

      protected java.util.Collection<java.lang.String> modulesToAdd
    • pathsOfModules

      protected java.util.Collection<java.lang.String> pathsOfModules
    • pathsOfArtifacts

      protected java.util.Collection<java.lang.String> pathsOfArtifacts
    • jpacktoolPrepareUsed

      protected boolean jpacktoolPrepareUsed
      Flag if jpacktool-prepare goal has been used before
  • Constructor Details

  • Method Details

    • checkJpacktoolPrepareUsed

      protected void checkJpacktoolPrepareUsed()
      set jpacktoolPrepareUsed variable based on maven property
    • initJPacktoolModel

      protected void initJPacktoolModel()
      initialize jpacktooModel
    • resolveAndCreate

      protected java.nio.file.Path resolveAndCreate​(java.io.File dir, java.lang.String appFolderName, java.lang.String folderName) throws java.io.IOException
      resolve to path and create directory if not exists.
      Parameters:
      dir - the parent directory
      appFolderName - the name of the application folder
      folderName - the name of the folder in the application folder
      Returns:
      the resolved path
      Throws:
      java.io.IOException - if i/o error occured
    • convertSeparatedModulePathToPlatformSeparatedModulePath

      protected java.lang.StringBuilder convertSeparatedModulePathToPlatformSeparatedModulePath​(java.lang.String pluginModulePath)
      This will convert a module path separated by either : or ; into a string which uses the platform depend path separator uniformly.
      Parameters:
      pluginModulePath - The module path.
      Returns:
      The platform separated module path.
    • getPlatformDependSeparateList

      protected java.lang.String getPlatformDependSeparateList​(java.util.Collection<java.lang.String> modulePaths)
      Convert a list into a string which is separated by platform depend path separator.
      Parameters:
      modulePaths - The list of elements.
      Returns:
      The string which contains the elements separated by File.pathSeparatorChar.
    • getCommaSeparatedList

      protected java.lang.String getCommaSeparatedList​(java.util.Collection<java.lang.String> modules)
      Convert a list into a
      Parameters:
      modules - The list of modules.
      Returns:
      The string with the module list which is separated by ,.
    • getPathSeparatedList

      public java.lang.String getPathSeparatedList​(java.util.Collection<java.lang.String> modules)
      Convert a list into a
      Parameters:
      modules - The list of modules.
      Returns:
      The string with the module list which is separated by ,.
    • getCompileClasspathElements

      protected java.util.List<java.io.File> getCompileClasspathElements​(org.apache.maven.project.MavenProject project)
      Get project dependencies as List of files to the artifacts.

      This is the old unfiltered maven dependency handling behaviour turn on with the unfilteredDependencyHandling Parameter.

      Parameters:
      project - the maven project
      Returns:
      list of file elements for artifacts.
    • getDependenciesToLink

      protected java.util.List<java.io.File> getDependenciesToLink() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException
      Get project dependencies as List of files to the artifacts.

      This is the new filtered maven dependency behaviour which can be turned off with the unfilteredDependencyHandling Parameter.

      Returns:
      list of file elements for artifacts.
      Throws:
      org.apache.maven.plugin.MojoExecutionException - on plugin execution error
      org.apache.maven.plugin.MojoFailureException - on plugin failure
    • getModulePathElements

      protected java.util.Map<java.lang.String,​java.io.File> getModulePathElements() throws org.apache.maven.plugin.MojoFailureException, org.apache.maven.plugin.MojoExecutionException
      Throws:
      org.apache.maven.plugin.MojoFailureException
      org.apache.maven.plugin.MojoExecutionException
    • prepareModules

      protected void prepareModules​(java.io.File jmodsFolder) throws org.apache.maven.plugin.MojoFailureException, org.apache.maven.plugin.MojoExecutionException
      Throws:
      org.apache.maven.plugin.MojoFailureException
      org.apache.maven.plugin.MojoExecutionException
    • prepareModules

      protected void prepareModules​(java.io.File jmodsFolder, boolean useDirectory, boolean copyArtifacts, java.io.File moduleTempDirectory) throws org.apache.maven.plugin.MojoFailureException, org.apache.maven.plugin.MojoExecutionException
      Throws:
      org.apache.maven.plugin.MojoFailureException
      org.apache.maven.plugin.MojoExecutionException
    • addSystemModulesFromJPackToolPrepare

      protected void addSystemModulesFromJPackToolPrepare()
      add system modules from jpacktool-prepare goal
    • failIfProjectHasAlreadySetAnArtifact

      protected void failIfProjectHasAlreadySetAnArtifact() throws org.apache.maven.plugin.MojoExecutionException
      Throws:
      org.apache.maven.plugin.MojoExecutionException
    • projectHasAlreadySetAnArtifact

      protected boolean projectHasAlreadySetAnArtifact()
    • hasLimitModules

      protected boolean hasLimitModules()
    • addToLimitModules

      protected void addToLimitModules​(java.lang.String name)
    • addSystemModulesToLimitModules

      protected void addSystemModulesToLimitModules() throws org.apache.maven.plugin.MojoExecutionException
      Throws:
      org.apache.maven.plugin.MojoExecutionException
    • appendOrCreateJvmArgPath

      protected void appendOrCreateJvmArgPath​(java.lang.String opt1, java.lang.String opt2, java.lang.String value)
    • updateJvmArgs

      protected abstract void updateJvmArgs() throws org.apache.maven.plugin.MojoFailureException
      Throws:
      org.apache.maven.plugin.MojoFailureException
    • updateJvmArgs

      protected void updateJvmArgs​(java.lang.String appFolderName) throws org.apache.maven.plugin.MojoFailureException
      Throws:
      org.apache.maven.plugin.MojoFailureException
    • updateModel

      protected void updateModel() throws org.apache.maven.plugin.MojoFailureException
      Throws:
      org.apache.maven.plugin.MojoFailureException
    • getContext

      public org.codehaus.plexus.context.Context getContext()
    • getJvmArgs

      public java.util.List<java.lang.String> getJvmArgs()
    • getArguments

      public java.util.List<java.lang.String> getArguments()
    • getOutputDirectoyTemplates

      public java.io.File getOutputDirectoyTemplates()
    • getPackagingResources

      public PackagingResources getPackagingResources()
    • getFinalName

      public java.lang.String getFinalName()
      Overrides:
      getFinalName in class AbstractToolMojo
    • getZipArchiver

      public org.codehaus.plexus.archiver.zip.ZipArchiver getZipArchiver()
    • getBuildContext

      public org.sonatype.plexus.build.incremental.BuildContext getBuildContext()
    • getMavenResourcesFiltering

      public org.apache.maven.shared.filtering.MavenResourcesFiltering getMavenResourcesFiltering()
    • getMavenFileFilter

      public org.apache.maven.shared.filtering.MavenFileFilter getMavenFileFilter()
    • isIgnoreAutomaticModules

      public boolean isIgnoreAutomaticModules()
    • getModulePaths

      public java.util.List<java.lang.String> getModulePaths()
    • getLimitModules

      public java.util.List<java.lang.String> getLimitModules()
    • getModulesToAdd

      public java.util.Collection<java.lang.String> getModulesToAdd()
    • getPathsOfModules

      public java.util.Collection<java.lang.String> getPathsOfModules()
    • getPathsOfArtifacts

      public java.util.Collection<java.lang.String> getPathsOfArtifacts()
    • getBuildDirectory

      public java.io.File getBuildDirectory()
    • getOutputDirectory

      public java.io.File getOutputDirectory()
    • isAddJDKToLimitModules

      public boolean isAddJDKToLimitModules()
    • isjPacktoolMoveClassPathJars

      public boolean isjPacktoolMoveClassPathJars()
    • isjPacktoolMoveAutomaticModules

      public boolean isjPacktoolMoveAutomaticModules()
    • isjPacktoolMoveRealModules

      public boolean isjPacktoolMoveRealModules()
    • getAddModules

      public java.util.List<java.lang.String> getAddModules()
    • getClassPathFolderName

      public java.lang.String getClassPathFolderName()
    • getAutomaticModulesFolderName

      public java.lang.String getAutomaticModulesFolderName()
    • getModulesFolderName

      public java.lang.String getModulesFolderName()
    • isJpacktoolPrepareUsed

      public boolean isJpacktoolPrepareUsed()
    • getJpacktoolModel

      public java.util.Map<java.lang.String,​java.lang.Object> getJpacktoolModel()
    • contextualize

      public void contextualize​(org.codehaus.plexus.context.Context context) throws org.codehaus.plexus.context.ContextException
      Specified by:
      contextualize in interface org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable
      Throws:
      org.codehaus.plexus.context.ContextException
    • generateContent

      protected abstract void generateContent() throws org.apache.maven.plugin.MojoExecutionException
      Throws:
      org.apache.maven.plugin.MojoExecutionException
    • generateContent

      protected void generateContent​(java.io.File outputDirectory) throws org.apache.maven.plugin.MojoExecutionException
      Throws:
      org.apache.maven.plugin.MojoExecutionException
    • executeResources

      protected void executeResources​(java.io.File outputDirectory) throws org.apache.maven.plugin.MojoExecutionException
      Throws:
      org.apache.maven.plugin.MojoExecutionException
    • executeResources

      protected abstract void executeResources() throws org.apache.maven.plugin.MojoExecutionException
      Throws:
      org.apache.maven.plugin.MojoExecutionException