You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Brian Kuhn <bn...@gmail.com> on 2005/10/13 17:59:39 UTC

look up property value inside custom condition...

Hi all,

I'm writing a custom condition that needs to get the value of a property in
the project. How do I get a reference to the project from a condition? In a
custom task, I would call this.getProject().getProperty("foo"). Since
condition is an interface, I have no such option.

Thanks,
Brian

Re: look up property value inside custom condition...

Posted by Dominique Devienne <dd...@gmail.com>.
My question would be more why do your custom condition need to access
an arbitrary property. If it needs some input, it should take it in
the form of an attribute setter and use that. --DD

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: look up property value inside custom condition...

Posted by Jeffrey E Care <ca...@us.ibm.com>.
Have you tried implementing the "setProject(oata.Project)" method? One of 
the committers could say for sure, but I think the introspector will call 
that method, even if the class in question does not extend from 
oata.ProjectComponent...

JEC
-- 
Jeffrey E. Care (carej@us.ibm.com)
WebSphere v7 Release Engineer
WebSphere Build Tooling Lead (Project Mantis)


Brian Kuhn <bn...@gmail.com> wrote on 10/13/2005 12:51:28 PM:

> Yeah, I think that's the 'old' way of writing conditions. It's pretty 
much
> like writing a task. I was hoping to extend
> org.apache.tools.ant.taskdefs.condition.Equals, which extends
> java.lang.Object and implements
> org.apache.tools.ant.taskdefs.condition.Condition. It doesn't look like
> that's going to work. I got it to work using the groovy ant task anyway.
> Thanks for the input.
> 
> -Brian
> 
> 
> On 10/13/05, Jeffrey E Care <ca...@us.ibm.com> wrote:
> >
> > IIRC so long as your condition impl. class extends form
> > oata.ProjectComponent you can get a handle to the project. One way to 
do
> > this would be to extend oata.taskdefs.condition.ConditionBase
> >
> > --
> > Jeffrey E. Care (carej@us.ibm.com)
> > WebSphere v7 Release Engineer
> > WebSphere Build Tooling Lead (Project Mantis)
> >
> >
> > Brian Kuhn <bn...@gmail.com> wrote on 10/13/2005 11:59:39 AM:
> >
> > > Hi all,
> > >
> > > I'm writing a custom condition that needs to get the value of a 
property
> > in
> > > the project. How do I get a reference to the project from a 
condition?
> > In a
> > > custom task, I would call this.getProject().getProperty("foo"). 
Since
> > > condition is an interface, I have no such option.
> > >
> > > Thanks,
> > > Brian
> >
> >

Re: look up property value inside custom condition...

Posted by Matt Benson <gu...@yahoo.com>.
Hmm. to throw another iron in the fire, Ant uses
reflection to detect a setProject(oata.Project) method
on... anything.  So you could just do that if you
don't want the baggage.

HTH,
Matt

--- Brian Kuhn <bn...@gmail.com> wrote:

> Yeah, I think that's the 'old' way of writing
> conditions. It's pretty much
> like writing a task. I was hoping to extend
> org.apache.tools.ant.taskdefs.condition.Equals,
> which extends
> java.lang.Object and implements
> org.apache.tools.ant.taskdefs.condition.Condition.
> It doesn't look like
> that's going to work. I got it to work using the
> groovy ant task anyway.
> Thanks for the input.
> 
> -Brian
> 
> 
> On 10/13/05, Jeffrey E Care <ca...@us.ibm.com>
> wrote:
> >
> > IIRC so long as your condition impl. class extends
> form
> > oata.ProjectComponent you can get a handle to the
> project. One way to do
> > this would be to extend
> oata.taskdefs.condition.ConditionBase
> >
> > --
> > Jeffrey E. Care (carej@us.ibm.com)
> > WebSphere v7 Release Engineer
> > WebSphere Build Tooling Lead (Project Mantis)
> >
> >
> > Brian Kuhn <bn...@gmail.com> wrote on 10/13/2005
> 11:59:39 AM:
> >
> > > Hi all,
> > >
> > > I'm writing a custom condition that needs to get
> the value of a property
> > in
> > > the project. How do I get a reference to the
> project from a condition?
> > In a
> > > custom task, I would call
> this.getProject().getProperty("foo"). Since
> > > condition is an interface, I have no such
> option.
> > >
> > > Thanks,
> > > Brian
> >
> >
> 



		
__________________________________ 
Yahoo! Music Unlimited 
Access over 1 million songs. Try it free.
http://music.yahoo.com/unlimited/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: look up property value inside custom condition...

Posted by Brian Kuhn <bn...@gmail.com>.
Yeah, I think that's the 'old' way of writing conditions. It's pretty much
like writing a task. I was hoping to extend
org.apache.tools.ant.taskdefs.condition.Equals, which extends
java.lang.Object and implements
org.apache.tools.ant.taskdefs.condition.Condition. It doesn't look like
that's going to work. I got it to work using the groovy ant task anyway.
Thanks for the input.

-Brian


On 10/13/05, Jeffrey E Care <ca...@us.ibm.com> wrote:
>
> IIRC so long as your condition impl. class extends form
> oata.ProjectComponent you can get a handle to the project. One way to do
> this would be to extend oata.taskdefs.condition.ConditionBase
>
> --
> Jeffrey E. Care (carej@us.ibm.com)
> WebSphere v7 Release Engineer
> WebSphere Build Tooling Lead (Project Mantis)
>
>
> Brian Kuhn <bn...@gmail.com> wrote on 10/13/2005 11:59:39 AM:
>
> > Hi all,
> >
> > I'm writing a custom condition that needs to get the value of a property
> in
> > the project. How do I get a reference to the project from a condition?
> In a
> > custom task, I would call this.getProject().getProperty("foo"). Since
> > condition is an interface, I have no such option.
> >
> > Thanks,
> > Brian
>
>

Re: look up property value inside custom condition...

Posted by Jeffrey E Care <ca...@us.ibm.com>.
IIRC so long as your condition impl. class extends form 
oata.ProjectComponent you can get a handle to the project. One way to do 
this would be to extend oata.taskdefs.condition.ConditionBase

-- 
Jeffrey E. Care (carej@us.ibm.com)
WebSphere v7 Release Engineer
WebSphere Build Tooling Lead (Project Mantis)


Brian Kuhn <bn...@gmail.com> wrote on 10/13/2005 11:59:39 AM:

> Hi all,
> 
> I'm writing a custom condition that needs to get the value of a property 
in
> the project. How do I get a reference to the project from a condition? 
In a
> custom task, I would call this.getProject().getProperty("foo"). Since
> condition is an interface, I have no such option.
> 
> Thanks,
> Brian