maven-surefire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From car...@apache.org
Subject svn commit: r395351 - in /maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/shell: CmdShell.java CommandShell.java Shell.java
Date Wed, 19 Apr 2006 19:02:38 GMT
Author: carlos
Date: Wed Apr 19 12:02:37 2006
New Revision: 395351

URL: http://svn.apache.org/viewcvs?rev=395351&view=rev
Log:
[MSUREFIRE-88] Brought more PLX-161 fixes from Plexus

Added:
    maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/shell/CmdShell.java
  (with props)
    maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/shell/CommandShell.java
  (with props)
    maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/shell/Shell.java
  (with props)

Added: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/shell/CmdShell.java
URL: http://svn.apache.org/viewcvs/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/shell/CmdShell.java?rev=395351&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/shell/CmdShell.java
(added)
+++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/shell/CmdShell.java
Wed Apr 19 12:02:37 2006
@@ -0,0 +1,54 @@
+package org.apache.maven.surefire.shell;
+
+import java.util.Arrays;
+import java.util.List;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+/**
+ * <p>
+ * Class with patches copied from plexus-utils with fix for PLX-161,
+ * as we can not upgrade plexus-utils until it's upgraded in core Maven
+ * </p>
+ * 
+ * TODO deprecate when plexus-utils 1.2 can be used
+ *
+ * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
+ */
+public class CmdShell
+    extends Shell
+{
+    public CmdShell()
+    {
+        setShellCommand( "cmd.exe" );
+        setShellArgs( new String[]{"/X", "/C"} );
+    }
+
+    /**
+     * Specific implementation that quotes the all the command line
+     */
+    public List getCommandLine( String executable, String[] arguments )
+    {
+        StringBuffer sb = new StringBuffer();
+        sb.append( "\"" );
+        sb.append( super.getCommandLine( executable, arguments ).get( 0 ) );
+        sb.append( "\"" );
+
+        return Arrays.asList( new String[]{sb.toString()} );
+    }
+
+}

Propchange: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/shell/CmdShell.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/shell/CmdShell.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/shell/CommandShell.java
URL: http://svn.apache.org/viewcvs/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/shell/CommandShell.java?rev=395351&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/shell/CommandShell.java
(added)
+++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/shell/CommandShell.java
Wed Apr 19 12:02:37 2006
@@ -0,0 +1,38 @@
+package org.apache.maven.surefire.shell;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+/**
+ * <p>
+ * Class with patches copied from plexus-utils with fix for PLX-161,
+ * as we can not upgrade plexus-utils until it's upgraded in core Maven
+ * </p>
+ * 
+ * TODO deprecate when plexus-utils 1.2 can be used
+ *
+ * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
+ */
+public class CommandShell
+    extends Shell
+{
+    public CommandShell()
+    {
+        setShellCommand( "command.com" );
+        setShellArgs( new String[]{"/C"} );
+    }
+
+}

Propchange: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/shell/CommandShell.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/shell/CommandShell.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/shell/Shell.java
URL: http://svn.apache.org/viewcvs/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/shell/Shell.java?rev=395351&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/shell/Shell.java
(added)
+++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/shell/Shell.java
Wed Apr 19 12:02:37 2006
@@ -0,0 +1,149 @@
+package org.apache.maven.surefire.shell;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.surefire.util.NestedRuntimeException;
+import org.codehaus.plexus.util.cli.CommandLineException;
+import org.codehaus.plexus.util.cli.Commandline;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * <p>
+ * Class with patches copied from plexus-utils with fix for PLX-161,
+ * as we can not upgrade plexus-utils until it's upgraded in core Maven
+ * </p>
+ * 
+ * TODO deprecate when plexus-utils 1.2 can be used
+ *
+ * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
+ */
+public class Shell
+{
+    private String shellCommand;
+
+    private String[] shellArgs;
+
+    /**
+     * Set the command to execute the shell (eg. COMMAND.COM, /bin/bash,...)
+     *
+     * @param shellCommand
+     */
+    public void setShellCommand( String shellCommand )
+    {
+        this.shellCommand = shellCommand;
+    }
+
+    /**
+     * Get the command to execute the shell
+     *
+     * @return
+     */
+    public String getShellCommand()
+    {
+        return shellCommand;
+    }
+
+    /**
+     * Set the shell arguments when calling a command line (not the executable arguments)
+     * (eg. /X /C for CMD.EXE)
+     *
+     * @param shellArgs
+     */
+    public void setShellArgs( String[] shellArgs )
+    {
+        this.shellArgs = shellArgs;
+    }
+
+    /**
+     * Get the shell arguments
+     *
+     * @return
+     */
+    public String[] getShellArgs()
+    {
+        return shellArgs;
+    }
+
+    /**
+     * Get the command line for the provided executable and arguments in this shell
+     *
+     * @param executable executable that the shell has to call
+     * @param arguments  arguments for the executable, not the shell
+     * @return List with one String object with executable and arguments quoted as needed
+     */
+    public List getCommandLine( String executable, String[] arguments )
+    {
+
+        List commandLine = new ArrayList();
+        try
+        {
+            StringBuffer sb = new StringBuffer();
+
+            if ( executable != null )
+            {
+                sb.append( Commandline.quoteArgument( executable ) );
+            }
+            for ( int i = 0; i < arguments.length; i++ )
+            {
+                sb.append( " " );
+                sb.append( Commandline.quoteArgument( arguments[i] ) );
+            }
+
+            commandLine.add( sb.toString() );
+        }
+        catch ( CommandLineException e )
+        {
+            throw new NestedRuntimeException( e );
+        }
+
+        return commandLine;
+    }
+
+    /**
+     * Get the full command line to execute, including shell command, shell arguments,
+     * executable and executable arguments
+     *
+     * @param executable executable that the shell has to call
+     * @param arguments  arguments for the executable, not the shell
+     * @return List of String objects, whose array version is suitable to be used as argument
+     *         of Runtime.getRuntime().exec()
+     */
+    public List getShellCommandLine( String executable, String[] arguments )
+    {
+
+        List commandLine = new ArrayList();
+
+        if ( getShellCommand() != null )
+        {
+            commandLine.add( getShellCommand() );
+        }
+
+        if ( getShellArgs() != null )
+        {
+            commandLine.addAll( Arrays.asList( getShellArgs() ) );
+        }
+
+        commandLine.addAll( getCommandLine( executable, arguments ) );
+
+        return commandLine;
+
+    }
+
+}

Propchange: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/shell/Shell.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/shell/Shell.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"



Mime
View raw message