Class AbstractPackageToolMojo
- 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
-
Nested Class Summary
Nested classes/interfaces inherited from class net.agilhard.maven.plugins.jpacktool.base.mojo.AbstractTemplateToolMojo
AbstractTemplateToolMojo.TemplateGenerator
-
Field Summary
Fields Modifier and Type Field Description protected boolean
addJDKToLimitModules
Toggle whether to add all modules in the java boot path to the limitModules setting.protected java.util.List<java.lang.String>
addModules
Usually this is not necessary, cause this is handled automatically by the given dependencies.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.protected java.lang.String
automaticModulesFolderName
Name of the automatic-modules folderprotected org.sonatype.plexus.build.incremental.BuildContext
buildContext
The JAR archiver needed for archiving the environments.protected java.lang.String
classPathFolderName
Name of the classpath folderprotected org.codehaus.plexus.context.Context
context
protected org.apache.maven.shared.dependency.graph.DependencyGraphBuilder
dependencyGraphBuilder
The DependencyGraphBuilder component.protected java.lang.String
finalName
Name of the generated ZIP file in thetarget
directory.protected boolean
ignoreAutomaticModules
Flag to ignore automatic modules.protected static java.lang.String
JMODS
Just a constant for the jmods directory name.protected boolean
jPacktoolMoveAutomaticModules
Flag if to move real modules from jpacktool-prepare goalprotected boolean
jPacktoolMoveClassPathJars
Flag if to move classpath jars from jpacktool-prepare goalprotected boolean
jPacktoolMoveRealModules
Flag if to move real modules from jpacktool-prepare goal.protected boolean
jpacktoolPrepareUsed
Flag if jpacktool-prepare goal has been used beforeprotected java.util.List<java.lang.String>
jvmArgs
JVM flags and options to pass to the application.protected java.util.List<java.lang.String>
limitModules
Limit the universe of observable modules.protected org.apache.maven.shared.filtering.MavenFileFilter
mavenFileFilter
The MavenFileFilter component.org.apache.maven.shared.filtering.MavenResourcesFiltering
mavenResourcesFiltering
The MavenResourcesFiltering Component.protected java.util.List<java.lang.String>
modulePaths
Include additional paths on the--module-path
option.protected java.lang.String
modulesFolderName
Name of the modules folderprotected java.util.Collection<java.lang.String>
modulesToAdd
protected java.io.File
outputDirectory
protected PackagingResources
packagingResources
Resources to package into the image or installable package.protected java.util.Collection<java.lang.String>
pathsOfArtifacts
protected java.util.Collection<java.lang.String>
pathsOfModules
protected java.io.File
sourceJdkModules
Set the JDK location to create a Java custom runtime image.protected boolean
unfilteredDependencyHandling
Fall back to using old unfiltered maven dependency handling.Fields inherited from class net.agilhard.maven.plugins.jpacktool.base.mojo.AbstractTemplateToolMojo
outputDirectoyTemplates, templateGenerator
Fields inherited from class net.agilhard.maven.plugins.jpacktool.base.mojo.AbstractToolMojo
buildDirectory, classpathArtifacts, excludedArtifacts, javaVersion, jdkToolchain, jpacktoolModel, jpacktoolPropertyPrefix, locationManager, mavenProjectHelper, outputDirectoryAutomaticJars, outputDirectoryClasspathJars, outputDirectoryJPacktool, outputDirectoryModules, project, session, shouldSkipReason, skip, systemModules, templateMap, toolchainManager, verbose, zipArchiver
-
Constructor Summary
Constructors Constructor Description AbstractPackageToolMojo()
-
Method Summary
Modifier and Type Method Description protected void
addSystemModulesFromJPackToolPrepare()
add system modules from jpacktool-prepare goalprotected void
addSystemModulesToLimitModules()
protected void
addToLimitModules(java.lang.String name)
protected void
appendOrCreateJvmArgPath(java.lang.String opt1, java.lang.String opt2, java.lang.String value)
protected void
checkJpacktoolPrepareUsed()
set jpacktoolPrepareUsed variable based on maven propertyvoid
contextualize(org.codehaus.plexus.context.Context context)
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.protected abstract void
executeResources()
protected void
executeResources(java.io.File outputDirectory)
protected void
failIfProjectHasAlreadySetAnArtifact()
protected abstract void
generateContent()
protected void
generateContent(java.io.File outputDirectory)
java.util.List<java.lang.String>
getAddModules()
java.util.List<java.lang.String>
getArguments()
java.lang.String
getAutomaticModulesFolderName()
org.sonatype.plexus.build.incremental.BuildContext
getBuildContext()
java.io.File
getBuildDirectory()
java.lang.String
getClassPathFolderName()
protected java.lang.String
getCommaSeparatedList(java.util.Collection<java.lang.String> modules)
Convert a list into aprotected java.util.List<java.io.File>
getCompileClasspathElements(org.apache.maven.project.MavenProject project)
Get project dependencies as List of files to the artifacts.org.codehaus.plexus.context.Context
getContext()
protected java.util.List<java.io.File>
getDependenciesToLink()
Get project dependencies as List of files to the artifacts.java.lang.String
getFinalName()
java.util.Map<java.lang.String,java.lang.Object>
getJpacktoolModel()
java.util.List<java.lang.String>
getJvmArgs()
java.util.List<java.lang.String>
getLimitModules()
org.apache.maven.shared.filtering.MavenFileFilter
getMavenFileFilter()
org.apache.maven.shared.filtering.MavenResourcesFiltering
getMavenResourcesFiltering()
protected java.util.Map<java.lang.String,java.io.File>
getModulePathElements()
java.util.List<java.lang.String>
getModulePaths()
java.lang.String
getModulesFolderName()
java.util.Collection<java.lang.String>
getModulesToAdd()
java.io.File
getOutputDirectory()
java.io.File
getOutputDirectoyTemplates()
PackagingResources
getPackagingResources()
java.lang.String
getPathSeparatedList(java.util.Collection<java.lang.String> modules)
Convert a list into ajava.util.Collection<java.lang.String>
getPathsOfArtifacts()
java.util.Collection<java.lang.String>
getPathsOfModules()
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.org.codehaus.plexus.archiver.zip.ZipArchiver
getZipArchiver()
protected boolean
hasLimitModules()
protected void
initJPacktoolModel()
initialize jpacktooModelboolean
isAddJDKToLimitModules()
boolean
isIgnoreAutomaticModules()
boolean
isjPacktoolMoveAutomaticModules()
boolean
isjPacktoolMoveClassPathJars()
boolean
isjPacktoolMoveRealModules()
boolean
isJpacktoolPrepareUsed()
protected void
prepareModules(java.io.File jmodsFolder)
protected void
prepareModules(java.io.File jmodsFolder, boolean useDirectory, boolean copyArtifacts, java.io.File moduleTempDirectory)
protected boolean
projectHasAlreadySetAnArtifact()
protected java.nio.file.Path
resolveAndCreate(java.io.File dir, java.lang.String appFolderName, java.lang.String folderName)
resolve to path and create directory if not exists.protected abstract void
updateJvmArgs()
protected void
updateJvmArgs(java.lang.String appFolderName)
protected void
updateModel()
Methods inherited from class net.agilhard.maven.plugins.jpacktool.base.mojo.AbstractTemplateToolMojo
generateFromTemplate, getTemplateGenerator, getTemplateMap, initTemplate, initTemplates, loadResourceFileIntoString
Methods inherited from class net.agilhard.maven.plugins.jpacktool.base.mojo.AbstractToolMojo
bytesToHex, checkShouldSkip, createZipArchiveFromDirectory, execute, executeCommand, executeToolFinish, executeToolMain, executeToolStart, getArtifactFile, getClasspathArtifacts, getExcludedArtifacts, getJavaVersion, getJdkToolchain, getJpacktoolPropertyPrefix, getLocationManager, getOutputDirectoryAutomaticJars, getOutputDirectoryClasspathJars, getOutputDirectoryJPacktool, getOutputDirectoryModules, getPluginVersion, getProject, getSession, getShouldSkipReason, getSystemModules, getToolchain, getToolchainManager, getToolExecutable, hasClassifier, isVerbose, publishJPacktoolProperties, publishSHA256, setShouldSkipReason
-
Field Details
-
jvmArgs
@Parameter(required=false, readonly=false) protected java.util.List<java.lang.String> jvmArgsJVM flags and options to pass to the application.--jvm-args <args>
-
arguments
@Parameter(required=false, readonly=false) protected java.util.List<java.lang.String> argumentsCommand line arguments to pass to the main class if no arguments are specified by the launcher.--arguments <args>
-
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 sourceJdkModulesSet the JDK location to create a Java custom runtime image. -
JMODS
protected static final java.lang.String JMODSJust a constant for the jmods directory name.- See Also:
- Constant Field Values
-
finalName
@Parameter(defaultValue="${project.build.finalName}", readonly=true) protected java.lang.String finalNameName of the generated ZIP file in thetarget
directory. This will not change the name of the installed/deployed file. -
ignoreAutomaticModules
@Parameter(defaultValue="true") protected boolean ignoreAutomaticModulesFlag to ignore automatic modules. -
modulePaths
@Parameter protected java.util.List<java.lang.String> modulePathsInclude additional paths on the--module-path
option. Project dependencies and JDK modules are automatically added. -
limitModules
@Parameter protected java.util.List<java.lang.String> limitModulesLimit the universe of observable modules. The following gives an example of the configuration which can be used in thepom.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 addJDKToLimitModulesToggle whether to add all modules in the java boot path to the limitModules setting. -
jPacktoolMoveClassPathJars
@Parameter(defaultValue="true") protected boolean jPacktoolMoveClassPathJarsFlag if to move classpath jars from jpacktool-prepare goal -
jPacktoolMoveAutomaticModules
@Parameter(defaultValue="true") protected boolean jPacktoolMoveAutomaticModulesFlag if to move real modules from jpacktool-prepare goal -
jPacktoolMoveRealModules
@Parameter(defaultValue="false") protected boolean jPacktoolMoveRealModulesFlag 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> addModulesUsually 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 classPathFolderNameName of the classpath folder -
automaticModulesFolderName
@Parameter(defaultValue="jar_auto") protected java.lang.String automaticModulesFolderNameName of the automatic-modules folder -
modulesFolderName
@Parameter(defaultValue="jmods") protected java.lang.String modulesFolderNameName of the modules folder -
unfilteredDependencyHandling
@Parameter(defaultValue="false") protected boolean unfilteredDependencyHandlingFall back to using old unfiltered maven dependency handling. -
buildContext
@Component protected org.sonatype.plexus.build.incremental.BuildContext buildContextThe 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 mavenResourcesFilteringThe MavenResourcesFiltering Component. -
mavenFileFilter
@Component(role=org.apache.maven.shared.filtering.MavenFileFilter.class, hint="default") protected org.apache.maven.shared.filtering.MavenFileFilter mavenFileFilterThe MavenFileFilter component. -
dependencyGraphBuilder
@Component(role=org.apache.maven.shared.dependency.graph.DependencyGraphBuilder.class, hint="maven31") protected org.apache.maven.shared.dependency.graph.DependencyGraphBuilder dependencyGraphBuilderThe 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 jpacktoolPrepareUsedFlag if jpacktool-prepare goal has been used before
-
-
Constructor Details
-
AbstractPackageToolMojo
public AbstractPackageToolMojo()
-
-
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.IOExceptionresolve to path and create directory if not exists.- Parameters:
dir
- the parent directoryappFolderName
- the name of the application folderfolderName
- 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.MojoFailureExceptionGet 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 errororg.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
-
getFinalName
public java.lang.String getFinalName()- Overrides:
getFinalName
in classAbstractToolMojo
-
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 interfaceorg.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
-