You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Brett Porter (JIRA)" <ji...@codehaus.org> on 2007/02/23 08:06:21 UTC

[jira] Updated: (SUREFIRE-128) Argline splits on spaces, should not when quoted

     [ http://jira.codehaus.org/browse/SUREFIRE-128?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Brett Porter updated SUREFIRE-128:
----------------------------------

    Fix Version/s:     (was: 2.3)
                   2.4

> Argline splits on spaces, should not when quoted
> ------------------------------------------------
>
>                 Key: SUREFIRE-128
>                 URL: http://jira.codehaus.org/browse/SUREFIRE-128
>             Project: Maven Surefire
>          Issue Type: Bug
>    Affects Versions: 2.0 (2.2 plugin)
>            Reporter: Andrea Aime
>            Priority: Blocker
>             Fix For: 2.4
>
>
> I need to run surefire with the following argline:
> <argline>-javaagent:\"${user.home}\.m2\repository\aspectj\aspectjweaver\1.5.0\aspectjweaver-1.5.0.jar\"</argline>
> <argline>-javaagent:\"C:\Documents Settings\wolf\.m2\repository\aspectj\aspectjweaver\1.5.0\aspectjweaver-1.5.0.jar\"</argline>
> The problem is, ForkConfiguration splits the arguments blindly with StringUtils.split and the above turns into three
> separate arguments:
> -javaagent:"C:\Documents
> and 
> Settings\wolf\.m2\repository\aspectj\aspectjweaver\1.5.0\aspectjweaver-1.5.0.jar"
> And the the vm complains it cannot find the jar C:\Documents.
> When quoted, the split should not happen!
> The following method proved to support quoting properly when splitting on spaces (I'm using it in UmlGraph):
>  public static String[] tokenize(String s) {
> 	ArrayList<String> r = new ArrayList<String>();
> 	String remain = s;
> 	int n = 0, pos;
> 	remain = remain.trim();
> 	while (remain.length() > 0) {
> 	    if (remain.startsWith("\"")) {
> 		// Field in quotes
> 		pos = remain.indexOf('"', 1);
> 		if (pos == -1)
> 		    break;
> 		r.add(remain.substring(1, pos));
> 		if (pos + 1 < remain.length())
> 		    pos++;
> 	    } else {
> 		// Space-separated field
> 		pos = remain.indexOf(' ', 0);
> 		if (pos == -1) {
> 		    r.add(remain);
> 		    remain = "";
> 		} else
> 		    r.add(remain.substring(0, pos));
> 	    }
> 	    remain = remain.substring(pos + 1);
> 	    remain = remain.trim();
> 	    // - is used as a placeholder for empy fields
> 	    if (r.get(n).equals("-"))
> 		r.set(n, "");
> 	    n++;
> 	}
> 	return r.toArray(new String[0]);
>     }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira