Request
- Tool-specific request typepublic abstract class AbstractJavaTool<Request extends JavaToolRequest> extends org.codehaus.plexus.logging.AbstractLogEnabled implements JavaTool<Request>
JavaTool
.Modifier and Type | Field and Description |
---|---|
private java.lang.String |
javaToolFile
The location of the java tool executable file.
|
private java.lang.String |
javaToolName
The java tool name to find out in the jdk.
|
private java.lang.Object |
toolchain
Optional toolChain used to find java tool executable file.
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractJavaTool(java.lang.String javaToolName) |
Modifier and Type | Method and Description |
---|---|
protected abstract Commandline |
createCommandLine(Request request,
java.lang.String javaToolFileLocation)
Create the command line object given the request.
|
protected JavaToolResult |
createResult() |
protected StreamConsumer |
createSystemErrorStreamConsumer(Request request) |
protected java.io.InputStream |
createSystemInputStream() |
protected StreamConsumer |
createSystemOutStreamConsumer(Request request) |
JavaToolResult |
execute(Request request)
Execute the input request and then returns the result of the execution.
|
protected JavaToolResult |
executeCommandLine(Commandline cli,
Request request) |
private java.lang.String |
findExecutable(java.lang.String command,
java.lang.String homeDir,
java.lang.String... subDirs)
Finds the specified command in any of the given sub directories of the specified JDK/JRE home directory.
|
protected java.lang.String |
findJavaToolExecutable() |
private java.lang.String |
findToolchainExecutable()
Run toolchain.findTool( javaToolName ); through reflection to avoid compile dependency on
Maven core.
|
java.lang.String |
getJavaToolName()
Return the name of the java tool.
|
void |
setToolchain(java.lang.Object toolchain)
Set an optional tool chain to find out the java tool executable location.
|
private final java.lang.String javaToolName
private java.lang.String javaToolFile
private java.lang.Object toolchain
protected AbstractJavaTool(java.lang.String javaToolName)
javaToolName
- The name of the java tool.protected abstract Commandline createCommandLine(Request request, java.lang.String javaToolFileLocation) throws JavaToolException
request
- User request on the java tooljavaToolFileLocation
- Location of the java tool file to useJavaToolException
- if could not create the command line from the requestpublic java.lang.String getJavaToolName()
Return the name of the java tool. This is exactly the name (without his extension) of the executable to
find in the jdk/bin
directory.
For example: jarsigner, keytool, javadoc, ...
getJavaToolName
in interface JavaTool<Request extends JavaToolRequest>
public void setToolchain(java.lang.Object toolchain)
setToolchain
in interface JavaTool<Request extends JavaToolRequest>
toolchain
- optional tool chain to find out the java tool executable location.
To avoid direct dependency on Maven core, this parameter is an Object that will be
used as Toolchain through reflectionpublic JavaToolResult execute(Request request) throws JavaToolException
Execute the input request and then returns the result of the execution.
If could not create the java tool invocation, a JavaToolException
will be thrown.
If execution fails, then the result will have a none-zero JavaToolResult.getExitCode()
and his
JavaToolResult.getExecutionException()
will be filled with the error, otherwise the exist code will be
zero.
execute
in interface JavaTool<Request extends JavaToolRequest>
request
- the request to performJavaToolException
- if could not create the java tool invocationprotected java.io.InputStream createSystemInputStream()
InputStream
protected JavaToolResult executeCommandLine(Commandline cli, Request request)
cli
- Commandline
request
- The request.JavaToolRequest
protected StreamConsumer createSystemErrorStreamConsumer(Request request)
request
- The request.StreamConsumer
protected StreamConsumer createSystemOutStreamConsumer(Request request)
request
- The request.StreamConsumer
protected JavaToolResult createResult()
protected java.lang.String findJavaToolExecutable()
private java.lang.String findToolchainExecutable()
private java.lang.String findExecutable(java.lang.String command, java.lang.String homeDir, java.lang.String... subDirs)
command
- The command to find, must not be null
.homeDir
- The home directory to search in, may be null
.subDirs
- The sub directories of the home directory to search in, must not be null
.null
otherwise.