Package ru.akman.maven.plugins
Class BaseToolMojo
java.lang.Object
org.apache.maven.plugin.AbstractMojo
ru.akman.maven.plugins.BaseToolMojo
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled,org.apache.maven.plugin.Mojo
- Direct Known Subclasses:
JlinkMojo
public abstract class BaseToolMojo
extends org.apache.maven.plugin.AbstractMojo
Base class for creating a CLI tool Mojos.
-
Field Summary
Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected intexecCmdLine(org.codehaus.plexus.util.cli.Commandline cmdLine) Execute command line.protected intexecCmdLine(org.codehaus.plexus.util.cli.Commandline cmdLine, org.codehaus.plexus.util.cli.CommandLineUtils.StringStreamConsumer out, org.codehaus.plexus.util.cli.CommandLineUtils.StringStreamConsumer err) Execute command line with defined standard output/error streams.protected FileGet project base directory.protected FileGet project build directory.protected CharsetGet default charset.protected org.apache.maven.shared.model.fileset.util.FileSetManagerGet fileset manager.protected FileGet project output directory.protected org.apache.maven.plugin.BuildPluginManagerGet plugin manager.protected org.apache.maven.project.MavenProjectGet maven project.protected PropertiesGet project properties.protected org.apache.maven.execution.MavenSessionGet maven session.protected org.apache.maven.toolchain.ToolchainGet JDK toolchain from build context, i.e. the toolchain selected by maven-toolchains-plugin.protected org.apache.maven.toolchain.ToolchainManagerGet toolchain manager.protected List<org.apache.maven.toolchain.Toolchain>Get list of all JDK toolchains available in user settings independently from maven-toolchains-plugin.protected FileGet tool executable.protected FileGet tool home directory.protected org.apache.commons.lang3.JavaVersionGet tool corresponding java version.protected StringGet tool version.protected voidInit Mojo.Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContextMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.maven.plugin.Mojo
execute
-
Constructor Details
-
BaseToolMojo
public BaseToolMojo()
-
-
Method Details
-
getBaseDir
Get project base directory.- Returns:
- project base directory (that containing the pom.xml file)
-
getBuildDir
Get project build directory.- Returns:
- project build directory (${project.basedir}/target)
-
getOutputDir
Get project output directory.- Returns:
- project output directory (${project.build.directory}/classes)
-
getProperties
Get project properties.- Returns:
- project properties
-
getCharset
Get default charset.- Returns:
- default charset (${project.build.sourceEncoding})
-
getFileSetManager
protected org.apache.maven.shared.model.fileset.util.FileSetManager getFileSetManager()Get fileset manager.- Returns:
- fileset manager
-
getToolchains
Get list of all JDK toolchains available in user settings independently from maven-toolchains-plugin.- Returns:
- list of all JDK toolchains available in user settings
-
getToolchain
protected org.apache.maven.toolchain.Toolchain getToolchain()Get JDK toolchain from build context, i.e. the toolchain selected by maven-toolchains-plugin.- Returns:
- JDK toolchain from build context
-
getToolHomeDirectory
Get tool home directory.- Returns:
- tool home directory
-
getToolExecutable
Get tool executable.- Returns:
- tool executable
-
getToolVersion
Get tool version.- Returns:
- tool version
-
getToolJavaVersion
protected org.apache.commons.lang3.JavaVersion getToolJavaVersion()Get tool corresponding java version.- Returns:
- tool corresponding java version
-
getToolchainManager
protected org.apache.maven.toolchain.ToolchainManager getToolchainManager()Get toolchain manager.- Returns:
- toolchain manager
-
getPluginManager
protected org.apache.maven.plugin.BuildPluginManager getPluginManager()Get plugin manager.- Returns:
- plugin manager
-
getProject
protected org.apache.maven.project.MavenProject getProject()Get maven project.- Returns:
- maven project
-
getSession
protected org.apache.maven.execution.MavenSession getSession()Get maven session.- Returns:
- maven session
-
execCmdLine
protected int execCmdLine(org.codehaus.plexus.util.cli.Commandline cmdLine) throws org.codehaus.plexus.util.cli.CommandLineException Execute command line.- Parameters:
cmdLine- command line- Returns:
- exit code
- Throws:
org.codehaus.plexus.util.cli.CommandLineException- if any errors occurred while processing command line
-
execCmdLine
protected int execCmdLine(org.codehaus.plexus.util.cli.Commandline cmdLine, org.codehaus.plexus.util.cli.CommandLineUtils.StringStreamConsumer out, org.codehaus.plexus.util.cli.CommandLineUtils.StringStreamConsumer err) throws org.codehaus.plexus.util.cli.CommandLineException Execute command line with defined standard output/error streams.- Parameters:
cmdLine- command lineout- standard output, can be nullerr- standard error, can be null- Returns:
- exit code
- Throws:
org.codehaus.plexus.util.cli.CommandLineException- if any errors occurred while processing command line
-
init
protected void init(String toolName, File toolHomeDir, String toolBinDirName) throws org.apache.maven.plugin.MojoExecutionException Init Mojo.- Parameters:
toolName- the name of the tool (without extension)toolHomeDir- the tool home directorytoolBinDirName- the name of subdirectory where the tool live relative to the tool home directory- Throws:
org.apache.maven.plugin.MojoExecutionException- if any errors occurred while processing configuration parameters
-