Details
-
Bug
-
Status: Closed
-
Blocker
-
Resolution: Duplicate
-
2.0 (2.2 plugin)
-
None
-
None
-
None
Description
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("\""))
else {
// Space-separated field
pos = remain.indexOf(' ', 0);
if (pos == -1)
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.equals("-"))
r.set(n, "");
n++;
}
return r.toArray(new String[0]);
}
Attachments
Issue Links
- depends upon
-
SUREFIRE-55 Incorrect splitting of command line arguments in ForkConfiguration
- Closed