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
-
Method Summary
Modifier and TypeMethodDescriptionprotected int
execCmdLine
(org.codehaus.plexus.util.cli.Commandline cmdLine) Execute command line.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) Execute command line with defined standard output/error streams.protected File
Get project base directory.protected File
Get project build directory.protected Charset
Get default charset.protected org.apache.maven.shared.model.fileset.util.FileSetManager
Get fileset manager.protected File
Get project output directory.protected org.apache.maven.plugin.BuildPluginManager
Get plugin manager.protected org.apache.maven.project.MavenProject
Get maven project.protected Properties
Get project properties.protected org.apache.maven.execution.MavenSession
Get maven session.protected org.apache.maven.toolchain.Toolchain
Get JDK toolchain from build context, i.e. the toolchain selected by maven-toolchains-plugin.protected org.apache.maven.toolchain.ToolchainManager
Get 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 File
Get tool executable.protected File
Get tool home directory.protected org.apache.commons.lang3.JavaVersion
Get tool corresponding java version.protected String
Get tool version.protected void
Init Mojo.Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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
-