I want to pass ";;;" string as a string parameter in my Ant task:
<mytask param=";;;"/>
but Ant consider semicolon as a special symbol and raises an error
java.lang.IllegalArgumentException: Illegal group reference
how can I escape ; symbol to pass it to Ant?
p.s. also I found that I can't pass { symbol,
so I wonder what's the common way to escape characters in Ant?
I've tried "$;$;$;" but it's not working for me
UPDATE: sample code:
public class MyTask extends Task {
private String value;
public void setValue(String value) {
this.value = value;
}
public void execute() {
System.out.println(value);
}
}
and ant task:
<taskdef name="mytask" classpath="build/lib/CustomTasks.jar"
classname="MyTask"/>
<mytask value=";;;"/>
I have not any problem with this sample:
Output:
May be problem in implementation of
mytask
task?to escape semicolon use:
;
Refer to for complete list at: http://www.w3schools.com/TAGS/ref_ascii.asp
One note on passing special characters to ant in general:
I used to pass a password to ant SQL task but it failed on special characters such as @$#%^&*!
Switching & with &\amp; worked, but the other characters such as $ or # failed.
I ended up with replacing the password variable string directly inside the ant build file (using any search-replace script such as Linux's sed), rather than sending the parameter to the script using -D.
So if possible, don't waste your time on escaping or switching any special character you find - try to use an easier search-replace solution.