Author: tchemit
Date: Wed Nov 13 20:35:00 2013
New Revision: 1541695

URL: http://svn.apache.org/r1541695
Log:
MSHARED-304 - Create a API for java tool

Added:
    
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/
    
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/AbstractJavaTool.java
   (with props)
    
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/AbstractJavaToolRequest.java
   (with props)
    
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/AbstractJavaToolResult.java
   (with props)
    
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/JavaTool.java
   (with props)
    
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/JavaToolException.java
   (with props)
    
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/JavaToolRequest.java
   (with props)
    
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/JavaToolResult.java
   (with props)
Modified:
    maven/shared/trunk/maven-shared-utils/pom.xml

Modified: maven/shared/trunk/maven-shared-utils/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/pom.xml?rev=1541695&r1=1541694&r2=1541695&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-utils/pom.xml (original)
+++ maven/shared/trunk/maven-shared-utils/pom.xml Wed Nov 13 20:35:00 2013
@@ -92,6 +92,13 @@
       <artifactId>jsr305</artifactId>
       <version>2.0.1</version>
     </dependency>
+    <!-- used for the javatool api -->
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-toolchain</artifactId>
+      <version>${mavenVersion}</version>
+      <scope>provided</scope>
+    </dependency>
   </dependencies>
 
   <build>

Added: 
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/AbstractJavaTool.java
URL: 
http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/AbstractJavaTool.java?rev=1541695&view=auto
==============================================================================
--- 
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/AbstractJavaTool.java
 (added)
+++ 
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/AbstractJavaTool.java
 Wed Nov 13 20:35:00 2013
@@ -0,0 +1,289 @@
+package org.apache.maven.shared.utils.cli.javatool;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.shared.utils.Os;
+import org.apache.maven.shared.utils.StringUtils;
+import org.apache.maven.shared.utils.cli.CommandLineException;
+import org.apache.maven.shared.utils.cli.CommandLineUtils;
+import org.apache.maven.shared.utils.cli.Commandline;
+import org.apache.maven.shared.utils.cli.StreamConsumer;
+import org.apache.maven.toolchain.Toolchain;
+import org.codehaus.plexus.logging.AbstractLogEnabled;
+
+import java.io.File;
+import java.io.InputStream;
+import java.util.Map;
+
+/**
+ * Abstract implementation of a {@link JavaTool}.
+ *
+ * @author Tony Chemit <che...@codelutin.com>
+ * @since 0.5
+ */
+public abstract class AbstractJavaTool<Request extends JavaToolRequest, Result 
extends JavaToolResult>
+    extends AbstractLogEnabled
+    implements JavaTool<Request, Result>
+{
+
+    /**
+     * The java tool name to find out in the jdk.
+     */
+    private final String javaToolName;
+
+    /**
+     * The location of the java tool executable file.
+     */
+    private String javaToolFile;
+
+    /**
+     * Optional toolChain used to find java tool executable file.
+     */
+    private Toolchain toolchain;
+
+    protected AbstractJavaTool( String javaToolName )
+    {
+        this.javaToolName = javaToolName;
+    }
+
+    /**
+     * Create the commandline object given the request.
+     *
+     * @param request      User request on the java tool
+     * @param javaToolFile Location of the java tool file to use
+     * @return the commandline
+     * @throws JavaToolException if could not create the command line from the 
request
+     */
+    protected abstract Commandline createCommandLine( Request request, String 
javaToolFile )
+        throws JavaToolException;
+
+    protected abstract Result createResult();
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getJavaToolName()
+    {
+        return javaToolName;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setToolchain( Toolchain toolchain )
+    {
+        this.toolchain = toolchain;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Result execute( Request request )
+        throws JavaToolException
+    {
+
+        if ( javaToolFile == null )
+        {
+
+            // find the java tool file to use
+            try
+            {
+                javaToolFile = findJavaToolExecutable();
+            }
+            catch ( Exception e )
+            {
+                throw new JavaToolException( "Error finding " + javaToolName + 
" executable. Reason: " + e.getMessage(),
+                                             e );
+            }
+        }
+
+        // creates the command line from the given request
+        Commandline cli = createCommandLine( request, javaToolFile );
+
+        // execute it
+        Result result = executeCommandLine( cli, request );
+
+        // return result
+        return result;
+    }
+
+    protected InputStream createSystemInputStream()
+    {
+        InputStream systemIn = new InputStream()
+        {
+
+            /**
+             * {@inheritDoc}
+             */
+            public int read()
+            {
+                return -1;
+            }
+
+        };
+        return systemIn;
+    }
+
+    protected Result executeCommandLine( Commandline cli, Request request )
+    {
+        if ( getLogger().isDebugEnabled() )
+        {
+            getLogger().debug( "Executing: " + cli );
+        }
+
+        Result result = createResult();
+
+        result.setCommandline( cli );
+
+        InputStream systemIn = createSystemInputStream();
+
+        StreamConsumer systemOut = createSystemOutStreamConsumer( request );
+
+        StreamConsumer systemErr = createSystemErrorStreamConsumer( request );
+
+        try
+        {
+            int resultCode = CommandLineUtils.executeCommandLine( cli, 
systemIn, systemOut, systemErr );
+
+            result.setExitCode( resultCode );
+        }
+        catch ( CommandLineException e )
+        {
+            result.setExecutionException( e );
+        }
+
+        return result;
+    }
+
+    protected StreamConsumer createSystemErrorStreamConsumer( Request request )
+    {
+        StreamConsumer systemErr = request.getSystemErrorStreamConsumer();
+
+        if ( systemErr == null )
+        {
+            systemErr = new StreamConsumer()
+            {
+
+                /**
+                 * {@inheritDoc}
+                 */
+                public void consumeLine( final String line )
+                {
+                    getLogger().warn( line );
+                }
+
+            };
+        }
+        return systemErr;
+    }
+
+    protected StreamConsumer createSystemOutStreamConsumer( Request request )
+    {
+        StreamConsumer systemOut = request.getSystemOutStreamConsumer();
+
+        if ( systemOut == null )
+        {
+
+            systemOut = new StreamConsumer()
+            {
+
+                /**
+                 * {@inheritDoc}
+                 */
+                public void consumeLine( final String line )
+                {
+                    getLogger().info( line );
+
+                }
+
+            };
+        }
+        return systemOut;
+    }
+
+    protected String findJavaToolExecutable()
+    {
+        String command = javaToolName + ( Os.isFamily( Os.FAMILY_WINDOWS ) ? 
".exe" : "" );
+
+        String executable = null;
+
+        if ( toolchain != null )
+        {
+            executable = toolchain.findTool( javaToolName );
+        }
+
+        if ( executable == null )
+        {
+            executable = findExecutable( command, System.getProperty( 
"java.home" ), "../bin", "bin", "../sh" );
+        }
+
+        if ( executable == null )
+        {
+
+            Map<String, String> env = System.getenv();
+
+            String[] variables = { "JDK_HOME", "JAVA_HOME" };
+
+            for ( String variable : variables )
+            {
+                executable = findExecutable( command, env.get( variable ), 
"bin", "sh" );
+                if ( executable != null )
+                {
+                    break;
+                }
+            }
+        }
+
+        if ( executable == null )
+        {
+            executable = command;
+        }
+
+        return executable;
+    }
+
+    /**
+     * Finds the specified command in any of the given sub directories of the 
specified JDK/JRE home directory.
+     *
+     * @param command The command to find, must not be <code>null</code>.
+     * @param homeDir The home directory to search in, may be 
<code>null</code>.
+     * @param subDirs The sub directories of the home directory to search in, 
must not be <code>null</code>.
+     * @return The (absolute) path to the command if found, <code>null</code> 
otherwise.
+     */
+    private String findExecutable( String command, String homeDir, String... 
subDirs )
+    {
+        String result = null;
+        if ( StringUtils.isNotEmpty( homeDir ) )
+        {
+            for ( String subDir : subDirs )
+            {
+                File file = new File( new File( homeDir, subDir ), command );
+
+                if ( file.isFile() )
+                {
+                    result = file.getAbsolutePath();
+                    break;
+                }
+            }
+        }
+
+        return result;
+    }
+}

Propchange: 
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/AbstractJavaTool.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/AbstractJavaTool.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: 
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/AbstractJavaToolRequest.java
URL: 
http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/AbstractJavaToolRequest.java?rev=1541695&view=auto
==============================================================================
--- 
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/AbstractJavaToolRequest.java
 (added)
+++ 
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/AbstractJavaToolRequest.java
 Wed Nov 13 20:35:00 2013
@@ -0,0 +1,75 @@
+package org.apache.maven.shared.utils.cli.javatool;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.shared.utils.cli.StreamConsumer;
+
+/**
+ * Abstract implementation of a {@link JavaToolRequest}.
+ *
+ * @author Tony Chemit <che...@codelutin.com>
+ * @since 0.5
+ */
+public class AbstractJavaToolRequest
+    implements JavaToolRequest
+{
+
+    /**
+     * Optional system out stream consumer used by the commandline execution.
+     */
+    private StreamConsumer systemOutStreamConsumer;
+
+    /**
+     * Optional system error stream consumer used by the commandline execution.
+     */
+    private StreamConsumer systemErrorStreamConsumer;
+
+    /**
+     * {@inheritDoc}
+     */
+    public StreamConsumer getSystemOutStreamConsumer()
+    {
+        return systemOutStreamConsumer;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public StreamConsumer getSystemErrorStreamConsumer()
+    {
+        return systemErrorStreamConsumer;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setSystemOutStreamConsumer( StreamConsumer 
systemOutStreamConsumer )
+    {
+        this.systemOutStreamConsumer = systemOutStreamConsumer;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setSystemErrorStreamConsumer( StreamConsumer 
systemErrorStreamConsumer )
+    {
+        this.systemErrorStreamConsumer = systemErrorStreamConsumer;
+    }
+}

Propchange: 
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/AbstractJavaToolRequest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/AbstractJavaToolRequest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: 
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/AbstractJavaToolResult.java
URL: 
http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/AbstractJavaToolResult.java?rev=1541695&view=auto
==============================================================================
--- 
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/AbstractJavaToolResult.java
 (added)
+++ 
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/AbstractJavaToolResult.java
 Wed Nov 13 20:35:00 2013
@@ -0,0 +1,97 @@
+package org.apache.maven.shared.utils.cli.javatool;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.shared.utils.cli.CommandLineException;
+import org.apache.maven.shared.utils.cli.Commandline;
+
+/**
+ * Abstract implementation of a {@link JavaToolResult}.
+ *
+ * @author Tony Chemit <che...@codelutin.com>
+ * @since 0.5
+ */
+public abstract class AbstractJavaToolResult
+    implements JavaToolResult
+{
+    /**
+     * The exception that prevented to execute the command line, will be 
<code>null</code> if jarSigner could be
+     * successfully started.
+     */
+    private CommandLineException executionException;
+
+    /**
+     * The exit code reported by the Maven invocation.
+     */
+    private int exitCode = Integer.MIN_VALUE;
+
+    /**
+     * The command line used to obtain this result.
+     */
+    private Commandline commandline;
+
+    /**
+     * {@inheritDoc}
+     */
+    public int getExitCode()
+    {
+        return exitCode;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Commandline getCommandline()
+    {
+        return commandline;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public CommandLineException getExecutionException()
+    {
+        return executionException;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setExitCode( int exitCode )
+    {
+        this.exitCode = exitCode;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setExecutionException( CommandLineException executionException 
)
+    {
+        this.executionException = executionException;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setCommandline( Commandline commandline )
+    {
+        this.commandline = commandline;
+    }
+}

Propchange: 
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/AbstractJavaToolResult.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/AbstractJavaToolResult.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: 
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/JavaTool.java
URL: 
http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/JavaTool.java?rev=1541695&view=auto
==============================================================================
--- 
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/JavaTool.java
 (added)
+++ 
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/JavaTool.java
 Wed Nov 13 20:35:00 2013
@@ -0,0 +1,70 @@
+package org.apache.maven.shared.utils.cli.javatool;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.toolchain.Toolchain;
+
+/**
+ * Describes a java tool, means a executable available in the jdk.
+ * <p/>
+ * The name of the tool ({@link #getJavaToolName()}) reflects the name of the 
executable that should exists as an
+ * executable in the jdk, like {@code jarsigner, keytool, javadoc, ...}.
+ * <p/>
+ * An abstract implementation of the {@link JavaTool} named {@link 
AbstractJavaTool} use the command line API to execute
+ * any user requests of this tool.
+ *
+ * @author Tony Chemit <che...@codelutin.com>
+ * @since 0.5
+ */
+public interface JavaTool<Request extends JavaToolRequest, Result extends 
JavaToolResult>
+{
+
+    /**
+     * Return the name of the java tool. This is exactly the name (without his 
extension) of the executable to
+     * find in the {@code jdk/bin} directory.
+     * <p/>
+     * For example: {@code jarsigner, keytoll, javadoc, ...}
+     *
+     * @return the name of the java tool.
+     */
+    String getJavaToolName();
+
+    /**
+     * Set an optional tool chain to find out the java tool executable 
location.
+     *
+     * @param toolchain optional tool chain to find out the java tool 
executable location.
+     */
+    void setToolchain( Toolchain toolchain );
+
+    /**
+     * Execute the input request and then returns the result of the execution.
+     * <p/>
+     * If could not create the java tool invocation, a {@link 
JavaToolException} will be thrown.
+     * <p/>
+     * If execution fails, then the result will have a none-zero {@link 
Result#getExitCode()} and his
+     * {@link Result#getExecutionException()} will be filled with the error, 
otherwise the exist code will be zero.
+     *
+     * @param request the request to perform
+     * @return the result of the tool execution
+     * @throws JavaToolException if could not create the java tool invocation
+     */
+    Result execute( Request request )
+        throws JavaToolException;
+}

Propchange: 
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/JavaTool.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/JavaTool.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: 
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/JavaToolException.java
URL: 
http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/JavaToolException.java?rev=1541695&view=auto
==============================================================================
--- 
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/JavaToolException.java
 (added)
+++ 
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/JavaToolException.java
 Wed Nov 13 20:35:00 2013
@@ -0,0 +1,47 @@
+package org.apache.maven.shared.utils.cli.javatool;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Signals an error during the construction of the command line used to invoke 
java tool, e.g. illegal invocation arguments.
+ * <p/>
+ * This should not be confused with a failure of the invoked java tool build 
itself which will be reported by means of a
+ * non-zero exit code.
+ *
+ * @author Tony Chemit <che...@codelutin.com>
+ * @version $Id$
+ * @see JavaToolResult#getExitCode()
+ * @since 0.5
+ */
+public class JavaToolException
+    extends Exception
+{
+    private static final long serialVersionUID = 1L;
+
+    public JavaToolException( String message )
+    {
+        super( message );
+    }
+
+    public JavaToolException( String message, Throwable cause )
+    {
+        super( message, cause );
+    }
+}

Propchange: 
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/JavaToolException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/JavaToolException.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: 
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/JavaToolRequest.java
URL: 
http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/JavaToolRequest.java?rev=1541695&view=auto
==============================================================================
--- 
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/JavaToolRequest.java
 (added)
+++ 
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/JavaToolRequest.java
 Wed Nov 13 20:35:00 2013
@@ -0,0 +1,66 @@
+package org.apache.maven.shared.utils.cli.javatool;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.shared.utils.cli.StreamConsumer;
+
+/**
+ * Specifies the minimum parameters used to control a {@link JavaTool} 
invocation.
+ *
+ * @author Tony Chemit <che...@codelutin.com>
+ * @since 0.5
+ */
+public interface JavaToolRequest
+{
+
+    /**
+     * Gets the value of the {@code systemOutStreamConsumer} field.
+     * <p/>
+     * This option field if filled is used by the commandline tool to consume 
system ouput stream of the jarsigner
+     * command.
+     *
+     * @return the value of the {@code systemOutStreamConsumer} field.
+     */
+    StreamConsumer getSystemOutStreamConsumer();
+
+    /**
+     * Gets the value of the {@code systemErrorStreamConsumer} field.
+     * <p/>
+     * This option field if filled is used by the commandline tool to consume 
system error stream of the jarsigner
+     * command.
+     *
+     * @return the value of the {@code systemErrorStreamConsumer} field.
+     */
+    StreamConsumer getSystemErrorStreamConsumer();
+
+    /**
+     * Sets the new given value to the field {@code systemOutStreamConsumer} 
of the request.
+     *
+     * @param systemOutStreamConsumer the new value of the field {@code 
systemOutStreamConsumer}.
+     */
+    void setSystemOutStreamConsumer( StreamConsumer systemOutStreamConsumer );
+
+    /**
+     * Sets the new given value to the field {@code systemErrorStreamConsumer} 
of the request.
+     *
+     * @param systemErrorStreamConsumer the new value of the field {@code 
systemErrorStreamConsumer}.
+     */
+    void setSystemErrorStreamConsumer( StreamConsumer 
systemErrorStreamConsumer );
+}

Propchange: 
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/JavaToolRequest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/JavaToolRequest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: 
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/JavaToolResult.java
URL: 
http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/JavaToolResult.java?rev=1541695&view=auto
==============================================================================
--- 
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/JavaToolResult.java
 (added)
+++ 
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/JavaToolResult.java
 Wed Nov 13 20:35:00 2013
@@ -0,0 +1,76 @@
+package org.apache.maven.shared.utils.cli.javatool;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.shared.utils.cli.CommandLineException;
+import org.apache.maven.shared.utils.cli.Commandline;
+
+/**
+ * Describes the result of a {@link JavaTool} invocation.
+ *
+ * @author Tony Chemit <che...@codelutin.com>
+ * @since 0.5
+ */
+public interface JavaToolResult
+{
+    /**
+     * Gets the command line used.
+     *
+     * @return The command line used
+     */
+    Commandline getCommandline();
+
+    /**
+     * Gets the exception that possibly occurred during the execution of the 
command line.
+     *
+     * @return The exception that prevented to invoke tool or 
<code>null</code> if the command line was successfully
+     *         processed by the operating system.
+     */
+    CommandLineException getExecutionException();
+
+    /**
+     * Gets the exit code from the tool invocation. A non-zero value indicates 
a build failure. <strong>Note:</strong>
+     * This value is undefined if {@link #getExecutionException()} reports an 
exception.
+     *
+     * @return The exit code from the tool invocation.
+     */
+    int getExitCode();
+
+    /**
+     * Sets the exit code reported by the tool invocation.
+     *
+     * @param exitCode The exit code reported by the tool invocation.
+     */
+    void setExitCode( int exitCode );
+
+    /**
+     * Sets the exception that prevented to execute the command line.
+     *
+     * @param executionException The exception that prevented to execute the 
command line, may be <code>null</code>.
+     */
+    void setExecutionException( CommandLineException executionException );
+
+    /**
+     * Set the commandline used to obtain this result.
+     *
+     * @param commandline the commandline used to obtain this result
+     */
+    void setCommandline( Commandline commandline );
+}

Propchange: 
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/JavaToolResult.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/JavaToolResult.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision


Reply via email to