Class AbstractJLinkMojo
java.lang.Object
org.apache.maven.plugin.AbstractMojo
org.tentackle.maven.AbstractTentackleMojo
org.tentackle.maven.plugin.jlink.AbstractJLinkMojo
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo
- Direct Known Subclasses:
InitMojo, JLinkMojo, JPackageMojo
Base class for all mojos of the
tentackle-jlink-maven-plugin.- Author:
- harald
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringName of the destination subfolder containing the classpath artifacts.static final StringName of the destination subfolder containing the module-path artifacts.static final StringName of the destination subfolder containing the resources.protected BooleanControls the behavior if an automatic module is required.static final StringFile extension for ZIP files.Fields inherited from class AbstractTentackleMojo
charset, JDK_TOOLCHAIN, minLogLevel, verbosity, verbosityLevelFields inherited from interface org.apache.maven.plugin.Mojo
ROLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcopyArtifacts(JLinkResolver.Result result) Copies artifacts not already in the created jlink image to module- or classpath.protected voidCopies optional extra directories to the image directory.protected voidcopyResources(JLinkResolver.Result result) Copies the resources to theconfdirectory.protected voidcreateImage(JLinkResolver.Result result) Invokes the jlink tool and copies other artifacts and resources.protected voidcreateJLinkImage(JLinkResolver.Result result) Creates the jlink image.voidprotected abstract voidgenerateFiles(JLinkResolver.Result result) Generates additional files such as shell scripts or command files.Gets extra jre or jdk modules to add to the image.The zip file will be installed and deployed with an additional classifier showing the operating system and the platform.Gets the modules to exclude.Gets the optional extra deployment classifier.Gets optional extra classpath elements.Extra directories to copy to the image.Returns the policy if an automatic module is required.Gets the ZIP file's name without extension.
Invoked by theArtifactCreator.Gets the directory created by jlink holding the image.Gets the prefix to the jars and dirs in the runtime image.intGets the java major runtime version as a comparable integer.Gets the java runtime version used by the application.Gets the jdeps tool.org.codehaus.plexus.languages.java.jpms.LocationManagerGets the location manager to extract module information.Gets the name of the main class.Gets the name of the module holding the main class.org.apache.maven.project.MavenProjectHelperGets the project helper to attach artifacts.Gets the template directory.Gets the extra variables for templates or artifact generation.Gets the order how properties and variables override each other.org.codehaus.plexus.archiver.zip.ZipArchiverGets the archiver to zip the image.Gets the directory where to store the ZIP-file.protected voidinstallTemplate(String pluginTemplate, String projectTemplate, boolean overwrite) Installs the template with the given name.protected abstract voidinstallTemplates(boolean overwrite) Copies the templates to the template directory.booleanisClasspathDependency(org.apache.maven.artifact.Artifact artifact) Returns whether an artifact should be moved to the classpath explicitly.booleanReturns whether all application modules should go to the module path and not the image (modules) file.booleanisModulePathOnly(String moduleName) Returns whether the given module name should go to the module path and not the image (modules) file.booleanReturns whether the update feature is enabled.protected voidlogToolOutput(org.tentackle.common.ToolRunner runner) Logs theToolRunner's output at info level.voidprotected booleanvalidate()Methods inherited from class AbstractTentackleMojo
createFileSetManager, createPackageMap, determineEncoding, determineJavaToolVersion, determineVerbosity, execute, finishExecute, getCanonicalPath, getHostName, getIncludedFiles, getJavaHome, getMajorVersion, getMavenProject, getMavenSession, getMojoExecution, getPathRelativeToBasedir, getResourceDir, getResourceDirs, getSettings, getSettingsDecrypter, getToolchain, getToolchain, getToolchain, getToolchainManager, getToolFinder, installJavaLoggingHandler, isExecutionRecursive, isSkippedByDefault, loadResourceFileIntoString, toDescriptorNameMethods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Field Details
-
DEST_CLASSPATH
Name of the destination subfolder containing the classpath artifacts.- See Also:
-
DEST_MODULEPATH
Name of the destination subfolder containing the module-path artifacts.- See Also:
-
DEST_RESOURCES
Name of the destination subfolder containing the resources.- See Also:
-
ZIP_EXTENSION
-
failOnAutomaticRequired
Controls the behavior if an automatic module is required.- default: log such modules as warnings
- true: log as an error and let the build fail
- false: log as info
mainModuleis given.
-
-
Constructor Details
-
AbstractJLinkMojo
public AbstractJLinkMojo()
-
-
Method Details
-
getFinalName
Gets the ZIP file's name without extension.
Invoked by theArtifactCreator.- Returns:
- the final name
-
isWithUpdater
public boolean isWithUpdater()Returns whether the update feature is enabled.- Returns:
- true if generate artifacts with the auto-update feature
-
getFailOnAutomaticRequired
Returns the policy if an automatic module is required.- Returns:
- the policy, null if not configured
- See Also:
-
isModulePathOnly
public boolean isModulePathOnly()Returns whether all application modules should go to the module path and not the image (modules) file.- Returns:
- true if forced to mp folder
-
isModulePathOnly
Returns whether the given module name should go to the module path and not the image (modules) file.- Parameters:
moduleName- the name of the full-blown module- Returns:
- true if forced to mp folder
-
getZipDirectory
Gets the directory where to store the ZIP-file.- Returns:
- the ZIP target folder
-
getTemplateDir
Gets the template directory.- Returns:
- the directory holding the wizard templates
-
getImageDirectory
Gets the directory created by jlink holding the image.- Returns:
- the image dir, never null
-
getMainModule
Gets the name of the module holding the main class.- Returns:
- the main module, null or empty string to build an application running on the classpath
-
getMainClass
-
getLocationManager
public org.codehaus.plexus.languages.java.jpms.LocationManager getLocationManager()Gets the location manager to extract module information.- Returns:
- the JPMS manager
-
getProjectHelper
public org.apache.maven.project.MavenProjectHelper getProjectHelper()Gets the project helper to attach artifacts.- Returns:
- the project helper
-
getJdepsTool
-
getAddModules
-
getExcludeModules
-
getVariables
-
getVariablesPrecedence
Gets the order how properties and variables override each other.- Returns:
- default is system, maven, variables
-
getExtraClassifier
Gets the optional extra deployment classifier.- Returns:
- the extra classifier
-
getExtraClasspathElements
-
getExtraDirectories
-
getJavaRuntimeVersion
Gets the java runtime version used by the application.- Returns:
- the java version
-
getJavaMajorRuntimeVersion
public int getJavaMajorRuntimeVersion()Gets the java major runtime version as a comparable integer.- Returns:
- the major version
-
prepareExecute
public void prepareExecute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException- Overrides:
prepareExecutein classAbstractTentackleMojo- Throws:
org.apache.maven.plugin.MojoExecutionExceptionorg.apache.maven.plugin.MojoFailureException
-
executeImpl
public void executeImpl() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException- Specified by:
executeImplin classAbstractTentackleMojo- Throws:
org.apache.maven.plugin.MojoExecutionExceptionorg.apache.maven.plugin.MojoFailureException
-
getClassifier
The zip file will be installed and deployed with an additional classifier showing the operating system and the platform.- Returns:
- the classifier
- Throws:
org.apache.maven.plugin.MojoExecutionException- if no os.name
-
getImagePathPrefix
Gets the prefix to the jars and dirs in the runtime image.- Returns:
- the prefix, empty string if none (never null)
-
getZipArchiver
public org.codehaus.plexus.archiver.zip.ZipArchiver getZipArchiver()Gets the archiver to zip the image.- Returns:
- the archiver, never null
-
isClasspathDependency
public boolean isClasspathDependency(org.apache.maven.artifact.Artifact artifact) Returns whether an artifact should be moved to the classpath explicitly.- Parameters:
artifact- the artifact- Returns:
- true if move to classpath, else module-path
-
generateFiles
protected abstract void generateFiles(JLinkResolver.Result result) throws org.apache.maven.plugin.MojoExecutionException Generates additional files such as shell scripts or command files.- Parameters:
result- the resolver result- Throws:
org.apache.maven.plugin.MojoExecutionException- if generation failed
-
installTemplates
protected abstract void installTemplates(boolean overwrite) throws org.apache.maven.plugin.MojoExecutionException Copies the templates to the template directory.- Parameters:
overwrite- true if overwrite existing templates, false if install only missing- Throws:
org.apache.maven.plugin.MojoExecutionException- if installation failed
-
createImage
protected void createImage(JLinkResolver.Result result) throws org.apache.maven.plugin.MojoFailureException, org.apache.maven.plugin.MojoExecutionException Invokes the jlink tool and copies other artifacts and resources.- Parameters:
result- the resolver result- Throws:
org.apache.maven.plugin.MojoFailureExceptionorg.apache.maven.plugin.MojoExecutionException
-
createJLinkImage
protected void createJLinkImage(JLinkResolver.Result result) throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException Creates the jlink image.- Parameters:
result- the resolver info- Throws:
org.apache.maven.plugin.MojoExecutionException- if building the JPMS info failedorg.apache.maven.plugin.MojoFailureException- if jlink returned an error code
-
copyArtifacts
protected void copyArtifacts(JLinkResolver.Result result) throws org.apache.maven.plugin.MojoExecutionException Copies artifacts not already in the created jlink image to module- or classpath.- Parameters:
result- the resolver info- Throws:
org.apache.maven.plugin.MojoExecutionException- if copy failed
-
copyResources
protected void copyResources(JLinkResolver.Result result) throws org.apache.maven.plugin.MojoExecutionException Copies the resources to theconfdirectory.- Parameters:
result- the resolver info- Throws:
org.apache.maven.plugin.MojoExecutionException- if copy failed
-
copyExtraDirectories
protected void copyExtraDirectories() throws org.apache.maven.plugin.MojoExecutionExceptionCopies optional extra directories to the image directory.- Throws:
org.apache.maven.plugin.MojoExecutionException- if failed
-
validate
protected boolean validate() throws org.apache.maven.plugin.MojoExecutionException- Overrides:
validatein classAbstractTentackleMojo- Throws:
org.apache.maven.plugin.MojoExecutionException
-
installTemplate
protected void installTemplate(String pluginTemplate, String projectTemplate, boolean overwrite) throws org.apache.maven.plugin.MojoExecutionException Installs the template with the given name.- Parameters:
pluginTemplate- the plugin's name of the templateprojectTemplate- the project's name of the templateoverwrite- true if overwrite the existing template, false if leave unchanged- Throws:
org.apache.maven.plugin.MojoExecutionException- if installation failed
-
logToolOutput
protected void logToolOutput(org.tentackle.common.ToolRunner runner) Logs theToolRunner's output at info level.- Parameters:
runner- the ToolRunner
-