Echoing out ant fileset to screen for Debugging
You can use the documented (honest, it’s in there somewhere…) toString helper: <echo message=”My build-path is ${toString:build-path}” />
You can use the documented (honest, it’s in there somewhere…) toString helper: <echo message=”My build-path is ${toString:build-path}” />
The whole Properties object returned by System.getProperties() is exposed by Ant. Try this: <echo>${user.dir}</echo>
The property file task is for editing properties files. It contains all sorts of nice features that allow you to modify entries. For example: <propertyfile file=”build.properties”> <entry key=”build_number” type=”int” operation=”+” value=”1″/> </propertyfile> I’ve incremented my build_number by one. I have no idea what the value was, but it’s now one greater than what it was … Read more
This statement: <property file=”${user.home}/build.properties”/> Reads a property file(i.e. all properties in that file), and does not set the property named file. This would be correct. You first set a property and then echo it: <property name=”file” value=”${user.home}/build.properties”/> <echo message=”${file}” />
An Ant target can have an optional if or unless clause. This means to execute the task only if the property is set, with an if clause, or is unset with the unless clause1. Interestingly, that if or unless clause is checked after any dependent task is first executed. This means, you can do this … Read more
(Wasn’t able to comment on the given answer, so have to make another answer) I realized that when launching Ant from Eclipse, you’ll have to add fork=”true” to the <java> task. Also, it was first not clear to me how to write nested jvmargs, so here goes an example: <java classname=”…” fork=”true”> <jvmarg value=”-Xdebug” /> … Read more
Java ships in 2 versions: JRE & SDK (used to be called JDK) The JRE in addition to not containing the compiler, also doesn’t contain all of the libraries available in the JDK (tools.jar is one of them) When you download Java at: http://java.sun.com/javase/downloads/index.jsp, make sure to select the JDK version and install it. If … Read more
Is this for an <exec> task? You can set environment variables when you run an <exec> task: <exec executable=”${my.command}”> <env key=”foo” value=”bar”/> <arg line=”some value”/> </exec> You can use <property environment=”env”/> to expand the path: <property environment=”env”/> <exec executable=”${my.command}”> <env key=”PATH” value=”${env.PATH}:${my.directory}”/> </exec> If this is for some custom task that requires an environment variable, … Read more
The same way you’d speed up any other code. Find out which tests take the most time, and see how they can be optimized. There are plenty of operations that can be slow, and if you do them 3000 times, it adds up. Sometimes, reusing data between tests is worthwhile (even if you’re not supposed … Read more
All your ant stuff will work fine except the javac task which needs the tools.jar, located in the /lib directory from the JDK, JRE is not sufficient in that case. Therefore the hint from ant : “Unable to find a javac compiler;…” When working with Eclipse the default setting points to your JRE installation. So, … Read more