You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Vincent Bergbauer <vi...@yahoo.com> on 2000/09/26 19:28:48 UTC
refid in property
Hello,
Now that path can have a reference id, it would be
convenient for properties to simply refer to them.
<path id="mypath">
<pathelement path="${lib.dir}/config"/>
<pathelement path="${lib.dir}/etc"/>
</path>
<property name="somepath" refid="mypath"/>
Such properties could then be used for filtering or
whatever you may need.
The only requirement on the referenced object, is that
it implements toString() in a meaningful way.
The changes to taskdefs/Property.java are quite
trivial (full source in Property.zip):
// Private Reference attribute
private Reference ref = null;
// Accessors
public void setRefid(Reference ref) {
this.ref = ref;
}
public Reference getRefid() {
return ref;
}
// Adding a bit to Execute()
public void execute() throws BuildException {
try {
// ...
if ((name != null) && (ref != null)) {
Object obj =
ref.getReferencedObject(getProject());
if (obj != null) {
addProperty(name, obj.toString());
}
}
} catch (Exception e) {
throw new BuildException(e, location);
}
}
Voila!
Note that it would be very useful for command line
arguments to behave like path:
<args id="myargs">
<arg "--coucou"/>
<arg "--cuckoo"/>
</args>
Cheers.
Vincent.
__________________________________________________
Do You Yahoo!?
Send instant messages & get email alerts with Yahoo! Messenger.
http://im.yahoo.com/
Re: refid in property
Posted by Stefan Bodewig <bo...@bost.de>.
Would one expect that given
<property name="dummy" id="dummyId" value="test" />
the following two constructs yield the same result
<property name="dummy2" value="${dummy}" />
<property name="dummy2" refid="dummyId" />
i.e. should Property get a toString method returning the value of the
property?
Stefan
PS: Vincent, please send a "diff -u" next time, a lot easier to apply
than copy/pasting code.