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.File
appImage
Location of the predefined application image that is used to build an installable package.protected java.lang.String
appVersion
Version of the application.protected java.io.File
buildRootPackage
Directory in which to use and place temporary files.protected java.lang.String
category
Category or group of the applicationprotected boolean
copyArtifacts
Flag whether to copy artifact modules to the moduleTempDirectory.protected java.lang.String
copyright
Copyright for the application.protected java.lang.String
description
Description of the application.protected java.io.File
fileAssociations
Properties file that contains list of key=value parameters that describe a file association.protected java.util.List<java.lang.String>
files
List of files in the base directory.protected java.io.File
icon
Icon of the application bundle.protected java.lang.String
identifier
Machine readable identifier of the application.protected java.io.File
inputDirectoryPackage
The output directory for the resulting Application Image or Package.protected java.lang.String
installDir
Qualified name of the application class to execute.protected java.lang.Exception
lastException
protected java.lang.String
licenseFile
The license file, relative to the base directory.protected java.lang.String
mainClass
Qualified name of the application class to execute.protected java.lang.String
mainJar
The main JAR of the application.protected java.lang.String
module
Main module of the application.protected java.io.File
moduleTempDirectory
TempDirectory where artifact modules are temporarily copied too.protected java.lang.String
name
Name of the application.protected java.io.File
outputDirectoryPackage
The output directory for the resulting Application Image or Package.protected java.lang.String
packageType
Installer type of JPackager operation.protected java.lang.String
resourceDir
This 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.File
runtimeImage
Location of the predefined runtime image that is used to build an application image and installable package.protected java.io.File
secondaryLauncher
Properties file that contains a collection of options for a secondary launcher.protected boolean
skipModulesInclude
Skip including of modules.protected boolean
usingJDK11Jpackager
Flag to indicate we are use JDK11 ported jpackager from the posting Filling the Packager gapprotected java.lang.String
vendor
Vendor 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, unfilteredDependencyHandling
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 JPackagerMojo()
-
Method Summary
Modifier and Type Method Description void
checkShouldSkip()
protected void
copyArtifactsToModuleTempDirectory()
protected org.codehaus.plexus.util.cli.Commandline
createJPackageCommandLine(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.Commandline
createJPackagerCommandLine(java.util.Collection<java.lang.String> pathsOfModules, java.util.Collection<java.lang.String> modulesToAdd)
Build Commandline for JDK11 backported jpackager commandprotected void
executeResources()
void
executeToolMain()
protected void
failIfParametersAreNotValid()
protected java.io.File
findPackageFile(java.lang.String extension)
protected void
generateContent()
protected java.lang.String
getExecutable()
protected java.lang.String
getJPackageExecutable()
protected java.lang.String
getJPackagerExecutable()
protected void
ifBuildRootDirectoryDoesNotExistcreateIt()
protected void
ifModuleTempDirectoryDoesNotExistCreateIt()
protected void
ifOutputDirectoryExistsDeleteIt()
boolean
isUsingJDK11Jpackager()
protected void
maySetPlatformDefaultType()
protected void
moveJarToInputAutomatic(java.nio.file.Path source)
protected void
moveJarToInputClasspath(java.nio.file.Path source)
protected void
moveJarToInputModule(java.nio.file.Path source)
protected void
moveJPacktoolJars()
protected void
publishPackageArtifacts()
protected void
updateJvmArgs()
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, 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, 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:
checkShouldSkip
in classAbstractToolMojo
-
executeToolMain
public void executeToolMain() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException- Specified by:
executeToolMain
in classAbstractToolMojo
- Throws:
org.apache.maven.plugin.MojoExecutionException
org.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:
updateJvmArgs
in classAbstractPackageToolMojo
- Throws:
org.apache.maven.plugin.MojoFailureException
-
generateContent
protected void generateContent() throws org.apache.maven.plugin.MojoExecutionException- Specified by:
generateContent
in classAbstractPackageToolMojo
- Throws:
org.apache.maven.plugin.MojoExecutionException
-
executeResources
protected void executeResources() throws org.apache.maven.plugin.MojoExecutionException- Specified by:
executeResources
in classAbstractPackageToolMojo
- Throws:
org.apache.maven.plugin.MojoExecutionException
-