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 booleanaddJDKToLimitModulesToggle whether to add all modules in the java boot path to the limitModules setting.protected java.util.List<java.lang.String>addModulesUsually this is not necessary, cause this is handled automatically by the given dependencies.protected java.util.List<java.lang.String>argumentsCommand line arguments to pass to the main class if no arguments are specified by the launcher.protected java.lang.StringautomaticModulesFolderNameName of the automatic-modules folderprotected org.sonatype.plexus.build.incremental.BuildContextbuildContextThe JAR archiver needed for archiving the environments.protected java.lang.StringclassPathFolderNameName of the classpath folderprotected org.codehaus.plexus.context.Contextcontextprotected org.apache.maven.shared.dependency.graph.DependencyGraphBuilderdependencyGraphBuilderThe DependencyGraphBuilder component.protected java.lang.StringfinalNameName of the generated ZIP file in thetargetdirectory.protected booleanignoreAutomaticModulesFlag to ignore automatic modules.protected static java.lang.StringJMODSJust a constant for the jmods directory name.protected booleanjPacktoolMoveAutomaticModulesFlag if to move real modules from jpacktool-prepare goalprotected booleanjPacktoolMoveClassPathJarsFlag if to move classpath jars from jpacktool-prepare goalprotected booleanjPacktoolMoveRealModulesFlag if to move real modules from jpacktool-prepare goal.protected booleanjpacktoolPrepareUsedFlag if jpacktool-prepare goal has been used beforeprotected java.util.List<java.lang.String>jvmArgsJVM flags and options to pass to the application.protected java.util.List<java.lang.String>limitModulesLimit the universe of observable modules.protected org.apache.maven.shared.filtering.MavenFileFiltermavenFileFilterThe MavenFileFilter component.org.apache.maven.shared.filtering.MavenResourcesFilteringmavenResourcesFilteringThe MavenResourcesFiltering Component.protected java.util.List<java.lang.String>modulePathsInclude additional paths on the--module-pathoption.protected java.lang.StringmodulesFolderNameName of the modules folderprotected java.util.Collection<java.lang.String>modulesToAddprotected java.io.FileoutputDirectoryprotected PackagingResourcespackagingResourcesResources to package into the image or installable package.protected java.util.Collection<java.lang.String>pathsOfArtifactsprotected java.util.Collection<java.lang.String>pathsOfModulesprotected java.io.FilesourceJdkModulesSet the JDK location to create a Java custom runtime image.protected booleanunfilteredDependencyHandlingFall back to using old unfiltered maven dependency handling.Fields inherited from class net.agilhard.maven.plugins.jpacktool.base.mojo.AbstractTemplateToolMojo
outputDirectoyTemplates, templateGeneratorFields 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 voidaddSystemModulesFromJPackToolPrepare()add system modules from jpacktool-prepare goalprotected voidaddSystemModulesToLimitModules()protected voidaddToLimitModules(java.lang.String name)protected voidappendOrCreateJvmArgPath(java.lang.String opt1, java.lang.String opt2, java.lang.String value)protected voidcheckJpacktoolPrepareUsed()set jpacktoolPrepareUsed variable based on maven propertyvoidcontextualize(org.codehaus.plexus.context.Context context)protected java.lang.StringBuilderconvertSeparatedModulePathToPlatformSeparatedModulePath(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 voidexecuteResources()protected voidexecuteResources(java.io.File outputDirectory)protected voidfailIfProjectHasAlreadySetAnArtifact()protected abstract voidgenerateContent()protected voidgenerateContent(java.io.File outputDirectory)java.util.List<java.lang.String>getAddModules()java.util.List<java.lang.String>getArguments()java.lang.StringgetAutomaticModulesFolderName()org.sonatype.plexus.build.incremental.BuildContextgetBuildContext()java.io.FilegetBuildDirectory()java.lang.StringgetClassPathFolderName()protected java.lang.StringgetCommaSeparatedList(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.ContextgetContext()protected java.util.List<java.io.File>getDependenciesToLink()Get project dependencies as List of files to the artifacts.java.lang.StringgetFinalName()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.MavenFileFiltergetMavenFileFilter()org.apache.maven.shared.filtering.MavenResourcesFilteringgetMavenResourcesFiltering()protected java.util.Map<java.lang.String,java.io.File>getModulePathElements()java.util.List<java.lang.String>getModulePaths()java.lang.StringgetModulesFolderName()java.util.Collection<java.lang.String>getModulesToAdd()java.io.FilegetOutputDirectory()java.io.FilegetOutputDirectoyTemplates()PackagingResourcesgetPackagingResources()java.lang.StringgetPathSeparatedList(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.StringgetPlatformDependSeparateList(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.ZipArchivergetZipArchiver()protected booleanhasLimitModules()protected voidinitJPacktoolModel()initialize jpacktooModelbooleanisAddJDKToLimitModules()booleanisIgnoreAutomaticModules()booleanisjPacktoolMoveAutomaticModules()booleanisjPacktoolMoveClassPathJars()booleanisjPacktoolMoveRealModules()booleanisJpacktoolPrepareUsed()protected voidprepareModules(java.io.File jmodsFolder)protected voidprepareModules(java.io.File jmodsFolder, boolean useDirectory, boolean copyArtifacts, java.io.File moduleTempDirectory)protected booleanprojectHasAlreadySetAnArtifact()protected java.nio.file.PathresolveAndCreate(java.io.File dir, java.lang.String appFolderName, java.lang.String folderName)resolve to path and create directory if not exists.protected abstract voidupdateJvmArgs()protected voidupdateJvmArgs(java.lang.String appFolderName)protected voidupdateModel()Methods inherited from class net.agilhard.maven.plugins.jpacktool.base.mojo.AbstractTemplateToolMojo
generateFromTemplate, getTemplateGenerator, getTemplateMap, initTemplate, initTemplates, loadResourceFileIntoStringMethods 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 thetargetdirectory. 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-pathoption. 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.xmlfile.<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.xmlfile 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
unfilteredDependencyHandlingParameter.- 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
unfilteredDependencyHandlingParameter.- 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.MojoFailureExceptionorg.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.MojoFailureExceptionorg.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.MojoFailureExceptionorg.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:
getFinalNamein 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:
contextualizein 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
-