Created
February 8, 2012 16:07
-
-
Save nicholashagen/1770746 to your computer and use it in GitHub Desktop.
Trimming Spaces in Ant
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- task to trim spaces on properties in Ant via inline javascript (requires 1.7+) --> | |
<!-- NOTE that properties in Ant are immutable so you must define the variable with a different name --> | |
<target name="trim-properties"> | |
<script language="javascript"> | |
<![CDATA[ | |
var myproperty= project.getProperty("myproperty"); | |
if (myproperty!= null) { | |
project.setProperty("myproperty.trimmed", myproperty.trim()) | |
} | |
]]> | |
</script> | |
<echo>myproperty now set to -${myproperty.trimmed}-</echo> | |
</target> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Awesome!
however i just tried it out and it failed for me on openSUSE (Factory) with ant 1.9.2 and java version "1.7.0_45" (OpenJDK)... adding
manager="javax"
as described here: http://ant.apache.org/manual/Tasks/script.html fixed the issue for me.