Class JPackagerMojo
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled,org.apache.maven.plugin.Mojo,org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable
@Mojo(name="jpackager",
requiresDependencyResolution=RUNTIME,
defaultPhase=PACKAGE,
requiresProject=true)
public class JPackagerMojo
extends AbstractPackageToolMojo
- Author:
- 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 java.io.FileappImageLocation of the predefined application image that is used to build an installable package.protected java.lang.StringappVersionVersion of the application.protected java.io.FilebuildRootPackageDirectory in which to use and place temporary files.protected java.lang.StringcategoryCategory or group of the applicationprotected booleancopyArtifactsFlag whether to copy artifact modules to the moduleTempDirectory.protected java.lang.StringcopyrightCopyright for the application.protected java.lang.StringdescriptionDescription of the application.protected java.io.FilefileAssociationsProperties file that contains list of key=value parameters that describe a file association.protected java.util.List<java.lang.String>filesList of files in the base directory.protected java.io.FileiconIcon of the application bundle.protected java.lang.StringidentifierMachine readable identifier of the application.protected java.io.FileinputDirectoryPackageThe output directory for the resulting Application Image or Package.protected java.lang.StringinstallDirQualified name of the application class to execute.protected java.lang.ExceptionlastExceptionprotected java.lang.StringlicenseFileThe license file, relative to the base directory.protected java.lang.StringmainClassQualified name of the application class to execute.protected java.lang.StringmainJarThe main JAR of the application.protected java.lang.StringmoduleMain module of the application.protected java.io.FilemoduleTempDirectoryTempDirectory where artifact modules are temporarily copied too.protected java.lang.StringnameName of the application.protected java.io.FileoutputDirectoryPackageThe output directory for the resulting Application Image or Package.protected java.lang.StringpackageTypeInstaller type of JPackager operation.protected java.lang.StringresourceDirThis argument defines the path (absolute or relative) to the resource directory which overrides jpackage resources, including icons, template files or other files.protected java.io.FileruntimeImageLocation of the predefined runtime image that is used to build an application image and installable package.protected java.io.FilesecondaryLauncherProperties file that contains a collection of options for a secondary launcher.protected booleanskipModulesIncludeSkip including of modules.protected booleanusingJDK11JpackagerFlag to indicate we are use JDK11 ported jpackager from the posting Filling the Packager gapprotected java.lang.StringvendorVendor of the application.Fields inherited from class net.agilhard.maven.plugins.jpacktool.base.mojo.AbstractPackageToolMojo
addJDKToLimitModules, addModules, arguments, automaticModulesFolderName, buildContext, classPathFolderName, context, dependencyGraphBuilder, finalName, ignoreAutomaticModules, JMODS, jPacktoolMoveAutomaticModules, jPacktoolMoveClassPathJars, jPacktoolMoveRealModules, jpacktoolPrepareUsed, jvmArgs, limitModules, mavenFileFilter, mavenResourcesFiltering, modulePaths, modulesFolderName, modulesToAdd, outputDirectory, packagingResources, pathsOfArtifacts, pathsOfModules, sourceJdkModules, unfilteredDependencyHandlingFields 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 JPackagerMojo() -
Method Summary
Modifier and Type Method Description voidcheckShouldSkip()protected voidcopyArtifactsToModuleTempDirectory()protected org.codehaus.plexus.util.cli.CommandlinecreateJPackageCommandLine(java.util.Collection<java.lang.String> pathsOfModules, java.util.Collection<java.lang.String> modulesToAdd)Build Commandline for JDK >= 12 jpackage commandprotected org.codehaus.plexus.util.cli.CommandlinecreateJPackagerCommandLine(java.util.Collection<java.lang.String> pathsOfModules, java.util.Collection<java.lang.String> modulesToAdd)Build Commandline for JDK11 backported jpackager commandprotected voidexecuteResources()voidexecuteToolMain()protected voidfailIfParametersAreNotValid()protected java.io.FilefindPackageFile(java.lang.String extension)protected voidgenerateContent()protected java.lang.StringgetExecutable()protected java.lang.StringgetJPackageExecutable()protected java.lang.StringgetJPackagerExecutable()protected voidifBuildRootDirectoryDoesNotExistcreateIt()protected voidifModuleTempDirectoryDoesNotExistCreateIt()protected voidifOutputDirectoryExistsDeleteIt()booleanisUsingJDK11Jpackager()protected voidmaySetPlatformDefaultType()protected voidmoveJarToInputAutomatic(java.nio.file.Path source)protected voidmoveJarToInputClasspath(java.nio.file.Path source)protected voidmoveJarToInputModule(java.nio.file.Path source)protected voidmoveJPacktoolJars()protected voidpublishPackageArtifacts()protected voidupdateJvmArgs()Methods inherited from class net.agilhard.maven.plugins.jpacktool.base.mojo.AbstractPackageToolMojo
addSystemModulesFromJPackToolPrepare, addSystemModulesToLimitModules, addToLimitModules, appendOrCreateJvmArgPath, checkJpacktoolPrepareUsed, contextualize, convertSeparatedModulePathToPlatformSeparatedModulePath, executeResources, failIfProjectHasAlreadySetAnArtifact, generateContent, getAddModules, getArguments, getAutomaticModulesFolderName, getBuildContext, getBuildDirectory, getClassPathFolderName, getCommaSeparatedList, getCompileClasspathElements, getContext, getDependenciesToLink, getFinalName, getJpacktoolModel, getJvmArgs, getLimitModules, getMavenFileFilter, getMavenResourcesFiltering, getModulePathElements, getModulePaths, getModulesFolderName, getModulesToAdd, getOutputDirectory, getOutputDirectoyTemplates, getPackagingResources, getPathSeparatedList, getPathsOfArtifacts, getPathsOfModules, getPlatformDependSeparateList, getZipArchiver, hasLimitModules, initJPacktoolModel, isAddJDKToLimitModules, isIgnoreAutomaticModules, isjPacktoolMoveAutomaticModules, isjPacktoolMoveClassPathJars, isjPacktoolMoveRealModules, isJpacktoolPrepareUsed, prepareModules, prepareModules, projectHasAlreadySetAnArtifact, resolveAndCreate, updateJvmArgs, updateModelMethods 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, createZipArchiveFromDirectory, execute, executeCommand, executeToolFinish, 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
-
packageType
@Parameter(property="jlink-jpackager.package-type", required=false, readonly=false) protected java.lang.String packageTypeInstaller type of JPackager operation.Valid values for <type> are "msi", "rpm", "deb", "dmg", "pkg", "pkg-app-store".
If <type> is omitted a value from the platform specific settings <linuxType>, <windowsType> or <macType> is being used.
-
outputDirectoryPackage
@Parameter(defaultValue="${project.build.directory}/jpackager-out", required=true, readonly=true) protected java.io.File outputDirectoryPackageThe output directory for the resulting Application Image or Package.--output <path> -
inputDirectoryPackage
@Parameter(defaultValue="${project.build.directory}/jpackager-in", required=true, readonly=true) protected java.io.File inputDirectoryPackageThe output directory for the resulting Application Image or Package.--output <path> -
buildRootPackage
@Parameter(defaultValue="${project.build.directory}/jpackager-build", required=true, readonly=false) protected java.io.File buildRootPackageDirectory in which to use and place temporary files.--build-root <path> -
moduleTempDirectory
@Parameter(defaultValue="${project.build.directory}/jpackager-jmods", required=true, readonly=false) protected java.io.File moduleTempDirectoryTempDirectory where artifact modules are temporarily copied too. -
copyArtifacts
@Parameter(defaultValue="true", required=true, readonly=false) protected boolean copyArtifactsFlag whether to copy artifact modules to the moduleTempDirectory.The default value is true. Setting this to false only works if there are no modules with classes in the module hierachy.
-
files
@Parameter(required=false, readonly=false) protected java.util.List<java.lang.String> filesList of files in the base directory. If omitted, all files from "input" directory (which is a mandatory argument in this case) will be packaged.--files <files> -
name
@Parameter(defaultValue="${project.name}", required=false, readonly=false) protected java.lang.String nameName of the application.--name <name> -
mainJar
@Parameter(required=false, readonly=false) protected java.lang.String mainJarThe main JAR of the application. This JAR should have the main-class, and is relative to the assembled application directory.--main-jar<jarname> -
mainClass
@Parameter(required=false, readonly=false) protected java.lang.String mainClassQualified name of the application class to execute.-class <className> -
appVersion
@Parameter(defaultValue="${project.version}", required=false, readonly=false) protected java.lang.String appVersionVersion of the application.Note a -SNAPSHOT or .SNAPSHOT is automatically deleted from the version when constructing the jpackage command line arguments.
--app-version <version> -
icon
@Parameter(required=false, readonly=false) protected java.io.File iconIcon of the application bundle.--icon <path> -
identifier
@Parameter(defaultValue="${project.groupId}.${project.artifactId}", required=false, readonly=false) protected java.lang.String identifierMachine readable identifier of the application. The format must be a DNS name in reverse order, such as com.example.myapplication.--identifier <identifier> -
fileAssociations
@Parameter(required=false, readonly=false) protected java.io.File fileAssociationsProperties file that contains list of key=value parameters that describe a file association. "extension", "mime-type", "icon", "description" can be used as keys for the association.--file-associations <path> -
secondaryLauncher
@Parameter(required=false, readonly=false) protected java.io.File secondaryLauncherProperties file that contains a collection of options for a secondary launcher.--secondary-launcher <path> -
runtimeImage
@Parameter(required=false, readonly=false) protected java.io.File runtimeImageLocation of the predefined runtime image that is used to build an application image and installable package.--runtime-image <path> -
appImage
@Parameter(required=false, readonly=false) protected java.io.File appImageLocation of the predefined application image that is used to build an installable package.--app-image <path> -
installDir
@Parameter(required=false, readonly=false) protected java.lang.String installDirQualified name of the application class to execute.-install-dir <path> -
licenseFile
@Parameter(required=false, readonly=false) protected java.lang.String licenseFileThe license file, relative to the base directory.--license-file <path> -
resourceDir
@Parameter(required=false, readonly=false) protected java.lang.String resourceDirThis argument defines the path (absolute or relative) to the resource directory which overrides jpackage resources, including icons, template files or other files. -
copyright
@Parameter(required=false, readonly=false) protected java.lang.String copyrightCopyright for the application.--copyright <text> -
description
@Parameter(defaultValue="${project.description}", required=false, readonly=false) protected java.lang.String descriptionDescription of the application.--description <text> -
category
@Parameter(required=false, readonly=false) protected java.lang.String categoryCategory or group of the application--category <text> -
vendor
@Parameter(defaultValue="${project.organization}", required=false, readonly=false) protected java.lang.String vendorVendor of the application.--vendor <text> -
module
@Parameter(required=false, readonly=false) protected java.lang.String moduleMain module of the application. This module must have the main-class, and be on the module path.--module <name> -
skipModulesInclude
@Parameter(defaultValue="false", required=false, readonly=false) protected boolean skipModulesIncludeSkip including of modules. -
usingJDK11Jpackager
protected boolean usingJDK11JpackagerFlag to indicate we are use JDK11 ported jpackager from the posting Filling the Packager gap -
lastException
protected java.lang.Exception lastException
-
-
Constructor Details
-
JPackagerMojo
public JPackagerMojo()
-
-
Method Details
-
getJPackageExecutable
protected java.lang.String getJPackageExecutable() throws java.io.IOException- Throws:
java.io.IOException
-
getJPackagerExecutable
protected java.lang.String getJPackagerExecutable() throws java.io.IOException- Throws:
java.io.IOException
-
isUsingJDK11Jpackager
public boolean isUsingJDK11Jpackager() -
checkShouldSkip
public void checkShouldSkip()- Overrides:
checkShouldSkipin classAbstractToolMojo
-
executeToolMain
public void executeToolMain() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException- Specified by:
executeToolMainin classAbstractToolMojo- Throws:
org.apache.maven.plugin.MojoExecutionExceptionorg.apache.maven.plugin.MojoFailureException
-
moveJarToInputClasspath
protected void moveJarToInputClasspath(java.nio.file.Path source) throws java.io.IOException- Throws:
java.io.IOException
-
moveJarToInputAutomatic
protected void moveJarToInputAutomatic(java.nio.file.Path source) throws java.io.IOException- Throws:
java.io.IOException
-
moveJarToInputModule
protected void moveJarToInputModule(java.nio.file.Path source) throws java.io.IOException- Throws:
java.io.IOException
-
moveJPacktoolJars
protected void moveJPacktoolJars() throws java.lang.Exception- Throws:
java.lang.Exception
-
maySetPlatformDefaultType
protected void maySetPlatformDefaultType() -
publishPackageArtifacts
protected void publishPackageArtifacts() -
findPackageFile
protected java.io.File findPackageFile(java.lang.String extension) -
copyArtifactsToModuleTempDirectory
protected void copyArtifactsToModuleTempDirectory() throws org.apache.maven.plugin.MojoExecutionException- Throws:
org.apache.maven.plugin.MojoExecutionException
-
getExecutable
protected java.lang.String getExecutable() throws org.apache.maven.plugin.MojoFailureException- Throws:
org.apache.maven.plugin.MojoFailureException
-
ifBuildRootDirectoryDoesNotExistcreateIt
protected void ifBuildRootDirectoryDoesNotExistcreateIt() throws org.apache.maven.plugin.MojoExecutionException- Throws:
org.apache.maven.plugin.MojoExecutionException
-
ifModuleTempDirectoryDoesNotExistCreateIt
protected void ifModuleTempDirectoryDoesNotExistCreateIt() throws org.apache.maven.plugin.MojoExecutionException- Throws:
org.apache.maven.plugin.MojoExecutionException
-
ifOutputDirectoryExistsDeleteIt
protected void ifOutputDirectoryExistsDeleteIt() throws org.apache.maven.plugin.MojoExecutionException- Throws:
org.apache.maven.plugin.MojoExecutionException
-
createJPackageCommandLine
protected org.codehaus.plexus.util.cli.Commandline createJPackageCommandLine(java.util.Collection<java.lang.String> pathsOfModules, java.util.Collection<java.lang.String> modulesToAdd) throws java.io.IOExceptionBuild Commandline for JDK >= 12 jpackage command- Parameters:
pathsOfModules- collected paths of modulesmodulesToAdd- collected modules to add- Returns:
- a Commandline
- Throws:
java.io.IOException- on i/o error
-
createJPackagerCommandLine
protected org.codehaus.plexus.util.cli.Commandline createJPackagerCommandLine(java.util.Collection<java.lang.String> pathsOfModules, java.util.Collection<java.lang.String> modulesToAdd) throws java.io.IOExceptionBuild Commandline for JDK11 backported jpackager command- Parameters:
pathsOfModules- collected paths of modulesmodulesToAdd- collected modules to add- Returns:
- a Commandline
- Throws:
java.io.IOException- on i/o error
-
failIfParametersAreNotValid
protected void failIfParametersAreNotValid() throws org.apache.maven.plugin.MojoFailureException- Throws:
org.apache.maven.plugin.MojoFailureException
-
updateJvmArgs
protected void updateJvmArgs() throws org.apache.maven.plugin.MojoFailureException- Specified by:
updateJvmArgsin classAbstractPackageToolMojo- Throws:
org.apache.maven.plugin.MojoFailureException
-
generateContent
protected void generateContent() throws org.apache.maven.plugin.MojoExecutionException- Specified by:
generateContentin classAbstractPackageToolMojo- Throws:
org.apache.maven.plugin.MojoExecutionException
-
executeResources
protected void executeResources() throws org.apache.maven.plugin.MojoExecutionException- Specified by:
executeResourcesin classAbstractPackageToolMojo- Throws:
org.apache.maven.plugin.MojoExecutionException
-