You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by John Francis <jf...@his.co.uk> on 2009/05/12 17:21:09 UTC
API for setting a property reference?
Hi,
Is there a way to programmatically (i.e. using the API) set the id of a
property in Ant, so I can reference it via refid later on?
( Similar to "Java Development with Ant" first edition pp 80-81 but in code
)
<property name="param" value="changes" />
<property name="changes" value="What I want" id="changes.prop" />
<property name="selector" value="${param}" />
<property name="Message" refid="${selector}.prop"/>
<echo message="Message = ${Message}"/>
Thanks
----------------------------------------------------------------------------
--------------
This message is private and confidential. If you have received this message
in error, please notify postmaster@his.co.uk and remove it from your system.
Please carry out your own virus check before opening attachments.
HISL Limited is a limited company registered in England and Wales.
Registered Number: 3202995. VAT number: 729-6256-05.
Registered Office: Chestnut Farm, Jill Lane, Sambourne, Redditch B96 6ES
----------------------------------------------------------------------------
--------------
Re: API for setting a property reference?
Posted by Michael Ludwig <mi...@gmx.de>.
John Francis schrieb am 12.05.2009 um 17:24:44 (+0100):
> given a build.xml ...
>
> <project name="Test" default="test" basedir=".">
> <target name="test">
> <property name="param" value="123" />
> <namespace.MyTask/>
> And the java code for the task ...
>
> package namespace;
> public class MyTask extends Task
I had to add a <taskdef> in order to get this to run:
<taskdef name="namespace.MyTask" classname="namespace.MyTask"/>
It could also have been:
<taskdef name="my-task" classname="namespace.MyTask"/>
<!-- and then call it like this: -->
<my-task/>
Is there some auto-lookup feature for classes that attempts dynamic
class loading for something like <namespace.MyTask/>, i.e. element name
corresponding to classname?
Or did you just omit the <taskdef> for brevity?
Michael Ludwig
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
RE: API for setting a property reference?
Posted by John Francis <jf...@his.co.uk>.
Thanks,
so given a build.xml ...
<project name="Test" default="test" basedir=".">
<target name="test">
<property name="param" value="123" />
<namespace.MyTask/>
<property name="ParamProp" refid="${param}.prop"/>
<echo message="ParamProp = ${ParamProp}"/>
</target>
</project>
And the java code for the task ...
package namespace;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
public class MyTask extends Task
{
@Override
public void execute() throws BuildException
{
getProject().addReference("123.prop", "franjipan");
}
}
I get "franipan" echo'd...
----------------------------------------------------------------------------
--------------
This message is private and confidential. If you have received this message
in error, please notify postmaster@his.co.uk and remove it from your system.
Please carry out your own virus check before opening attachments.
HISL Limited is a limited company registered in England and Wales.
Registered Number: 3202995. VAT number: 729-6256-05.
Registered Office: Chestnut Farm, Jill Lane, Sambourne, Redditch B96 6ES
----------------------------------------------------------------------------
--------------
-----Original Message-----
From: Stefan Bodewig [mailto:bodewig@apache.org]
Sent: 12 May 2009 16:52
To: user@ant.apache.org
Subject: Re: API for setting a property reference?
On 2009-05-12, John Francis <jf...@his.co.uk> wrote:
> Is there a way to programmatically (i.e. using the API) set the id
> of a property in Ant, so I can reference it via refid later on?
Project#addReference is what you are looking for.
Stefan
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For additional
commands, e-mail: user-help@ant.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: API for setting a property reference?
Posted by Stefan Bodewig <bo...@apache.org>.
On 2009-05-12, John Francis <jf...@his.co.uk> wrote:
> Is there a way to programmatically (i.e. using the API) set the id of a
> property in Ant, so I can reference it via refid later on?
Project#addReference is what you are looking for.
Stefan
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
RE: API for setting a property reference?
Posted by John Francis <jf...@his.co.uk>.
Thanks, ?but I need to set the id of the original property not the refid on
a property that references it?
----------------------------------------------------------------------------
--------------
This message is private and confidential. If you have received this message
in error, please notify postmaster@his.co.uk and remove it from your system.
Please carry out your own virus check before opening attachments.
HISL Limited is a limited company registered in England and Wales.
Registered Number: 3202995. VAT number: 729-6256-05.
Registered Office: Chestnut Farm, Jill Lane, Sambourne, Redditch B96 6ES
----------------------------------------------------------------------------
--------------
-----Original Message-----
From: Cole, Derek E [mailto:derek.e.cole@lmco.com]
Sent: 12 May 2009 16:27
To: Ant Users List
Subject: RE: API for setting a property reference?
Look at the property class in the Ant API. There is a setRefId method that
might do what you're talking about.
-----Original Message-----
From: John Francis [mailto:jfrancis@his.co.uk]
Sent: Tuesday, May 12, 2009 11:21 AM
To: user@ant.apache.org
Subject: API for setting a property reference?
Hi,
Is there a way to programmatically (i.e. using the API) set the id of a
property in Ant, so I can reference it via refid later on?
( Similar to "Java Development with Ant" first edition pp 80-81 but in code
)
<property name="param" value="changes" /> <property name="changes"
value="What I want" id="changes.prop" /> <property name="selector"
value="${param}" /> <property name="Message" refid="${selector}.prop"/>
<echo message="Message = ${Message}"/>
Thanks
------------------------------------------------------------------------
----
--------------
This message is private and confidential. If you have received this message
in error, please notify postmaster@his.co.uk and remove it from your system.
Please carry out your own virus check before opening attachments.
HISL Limited is a limited company registered in England and Wales.
Registered Number: 3202995. VAT number: 729-6256-05.
Registered Office: Chestnut Farm, Jill Lane, Sambourne, Redditch B96 6ES
------------------------------------------------------------------------
----
--------------
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For additional
commands, e-mail: user-help@ant.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
RE: API for setting a property reference?
Posted by "Cole, Derek E" <de...@lmco.com>.
Look at the property class in the Ant API. There is a setRefId method
that might do what you're talking about.
-----Original Message-----
From: John Francis [mailto:jfrancis@his.co.uk]
Sent: Tuesday, May 12, 2009 11:21 AM
To: user@ant.apache.org
Subject: API for setting a property reference?
Hi,
Is there a way to programmatically (i.e. using the API) set the id
of a
property in Ant, so I can reference it via refid later on?
( Similar to "Java Development with Ant" first edition pp 80-81 but in
code
)
<property name="param" value="changes" />
<property name="changes" value="What I want" id="changes.prop" />
<property name="selector" value="${param}" />
<property name="Message" refid="${selector}.prop"/>
<echo message="Message = ${Message}"/>
Thanks
------------------------------------------------------------------------
----
--------------
This message is private and confidential. If you have received this
message
in error, please notify postmaster@his.co.uk and remove it from your
system.
Please carry out your own virus check before opening attachments.
HISL Limited is a limited company registered in England and Wales.
Registered Number: 3202995. VAT number: 729-6256-05.
Registered Office: Chestnut Farm, Jill Lane, Sambourne, Redditch B96 6ES
------------------------------------------------------------------------
----
--------------
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org