I'd like to be able to define java system properties in the build.xml file. For example I need to set a proxy (socksProxyHost) for the <scp> task that runs within the virtual machine ant runs in. Until now, the only way to do this is to give the properties to the ant call itself or define it for my ant installation. But I want to define them in the build.xml file itself. A simple way to do this would be to allow the <sysproperty> element as a direct child of the <project> element. Evaluating the element would call System.getProperties.setProperty(key, value) making that system property available for all other tasks withing ant.
For the particular problem of proxy setup (and it is a problem, especially on roaming laptops), what is wrong with the <setproxy> task?
The only problem with <setproxy> is that I did not look for something like that :-) Thanks, it solved my problem, so I'm reducing priority for this enhancement. It still sounds like a good idea to me, though, so the enhancement is still open.
We have found a need for something similar, to configure the XML parser that underlies an operation for which we use the <xslt> task. We have a pretty trivial ant task implementation that allows us to invoke: <setSystemProperty key="org.apache.xerces.xni.parser.XMLParserConfiguration" value="org.apache.xerces.parsers.XIncludeParserConfiguration" /> prior to XSLT, and this then allows us to convert docbook (with xincludes) to HTML using ant's xslt task. No doubt there are other inventive uses for being able to set system properties, so we'd like to add a +1 to having this as a standard feature in ant. For the record, or for anyone else that wants something similar, our task is implemented as: /** A simple Ant task to set a System property. */ public class SetProp extends Task { private String _key = null; private String _value = null; public void execute() throws BuildException { System.setProperty(_key, _value); } public void setKey(final String key) { _key = key; } public void setValue(final String value) { _value = value; } }