You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by pe...@apache.org on 2006/09/28 22:03:56 UTC
svn commit: r451000 - in /ant/core/trunk/src:
main/org/apache/tools/ant/taskdefs/
main/org/apache/tools/ant/taskdefs/condition/
tests/junit/org/apache/tools/ant/
Author: peterreilly
Date: Thu Sep 28 13:03:55 2006
New Revision: 451000
URL: http://svn.apache.org/viewvc?view=rev&rev=451000
Log:
Make conditionbase a Task.
?was there any reason that this was not done for ant 1.6?
Modified:
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/ConditionTask.java
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/WaitFor.java
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/ConditionBase.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/LocationTest.java
Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/ConditionTask.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/ConditionTask.java?view=diff&rev=451000&r1=450999&r2=451000
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/ConditionTask.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/ConditionTask.java Thu Sep 28 13:03:55 2006
@@ -43,10 +43,6 @@
private String value = "true";
private String alternative = null;
- public ConditionTask() {
- super("condition");
- }
-
/**
* The name of the property to set. Required.
* @param p the name of the property
Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/WaitFor.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/WaitFor.java?view=diff&rev=451000&r1=450999&r2=451000
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/WaitFor.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/WaitFor.java Thu Sep 28 13:03:55 2006
@@ -59,10 +59,6 @@
private long checkEveryMultiplier = 1L;
private String timeoutProperty;
- public WaitFor() {
- super("waitfor");
- }
-
/**
* Set the maximum length of time to wait.
* @param time a <code>long</code> value
Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/ConditionBase.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/ConditionBase.java?view=diff&rev=451000&r1=450999&r2=451000
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/ConditionBase.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/ConditionBase.java Thu Sep 28 13:03:55 2006
@@ -23,7 +23,7 @@
import org.apache.tools.ant.Project;
import org.apache.tools.ant.DynamicElement;
import org.apache.tools.ant.ComponentHelper;
-import org.apache.tools.ant.ProjectComponent;
+import org.apache.tools.ant.Task;
import org.apache.tools.ant.taskdefs.Available;
import org.apache.tools.ant.taskdefs.Checksum;
import org.apache.tools.ant.taskdefs.UpToDate;
@@ -35,39 +35,18 @@
*
* @since Ant 1.4
*/
-public abstract class ConditionBase extends ProjectComponent
+public abstract class ConditionBase extends Task
implements DynamicElement {
private static final String CONDITION_ANTLIB
= "antlib:org.apache.tools.ant.types.conditions:";
/**
- * name of the component
- */
- private String taskName="condition";
-
- /**
*
*/
private Vector conditions = new Vector();
/**
- * Simple constructor.
- */
- protected ConditionBase() {
- taskName = "component";
- }
-
- /**
- * Constructor that takes the name of the task in the task name.
- * @param taskName
- * @since Ant 1.7
- */
- protected ConditionBase(String taskName) {
- this.taskName = taskName;
- }
-
- /**
* Count the conditions.
*
* @return the number of conditions in the container
@@ -85,27 +64,6 @@
*/
protected final Enumeration getConditions() {
return conditions.elements();
- }
-
- /**
- * Sets the name to use in logging messages.
- *
- * @param name The name to use in logging messages.
- * Should not be <code>null</code>.
- * @since Ant 1.7
- */
- public void setTaskName(String name) {
- this.taskName = name;
- }
-
- /**
- * Returns the name to use in logging messages.
- *
- * @return the name to use in logging messages.
- * @since Ant 1.7
- */
- public String getTaskName() {
- return taskName;
}
/**
Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/LocationTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/LocationTest.java?view=diff&rev=451000&r1=450999&r2=451000
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/LocationTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/LocationTest.java Thu Sep 28 13:03:55 2006
@@ -46,8 +46,7 @@
public void testConditionTask() {
executeTarget("testConditionTask");
- TaskAdapter ta = (TaskAdapter) getProject().getReference("cond");
- ConditionTask c = (ConditionTask) ta.getProxy();
+ ConditionTask c = (ConditionTask) getProject().getReference("cond");
assertFalse(c.getLocation() == Location.UNKNOWN_LOCATION);
assertFalse(c.getLocation().getLineNumber() == 0);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org
Re: svn commit: r451000 - in /ant/core/trunk/src:
main/org/apache/tools/ant/taskdefs/
main/org/apache/tools/ant/taskdefs/condition/ tests/junit/org/apache/tools/ant/
Posted by Antoine Levy-Lambert <an...@gmx.de>.
Hi,
one of the ideas which is nearly always guiding me when I program is that if you depict pears as oranges in your code it is generating a bad smell and might fail on you later.
maybe we need a generic way to adapt a condition to become a task, for instance
<conditionadapter>
<if>
<and>
<isset property="blue sky"/>
<waitfor .../>
</and>
</if>
<then>
</then>
<else>
</else>
</conditionadapter>
the then and else tags would be the equivalent of <sequential/> in macrodef.
Uhhmm. Maybe the above already exists in ant-contrib somehow ?
Antoine
-------- Original-Nachricht --------
Datum: Fri, 29 Sep 2006 11:50:42 +0100
Von: Steve Loughran <st...@apache.org>
An: Ant Developers List <de...@ant.apache.org>
Betreff: Re: svn commit: r451000 - in /ant/core/trunk/src: main/org/apache/tools/ant/taskdefs/ main/org/apache/tools/ant/taskdefs/condition/ tests/junit/org/apache/tools/ant/
> Antoine Levy-Lambert wrote:
> > Hello Peter,
> >
> > -------- Original-Nachricht --------
> > Datum: Fri, 29 Sep 2006 09:44:44 +0100
> > Von: "Peter Reilly" <pe...@gmail.com>
> > An: "Ant Developers List" <de...@ant.apache.org>
> > Betreff: Re: svn commit: r451000 - in /ant/core/trunk/src:
> main/org/apache/tools/ant/taskdefs/ main/org/apache/tools/ant/taskdefs/condition/
> tests/junit/org/apache/tools/ant/
> >> there are some issues remaining. I cannot find the e-mail,
> >> but someone was
> >> talking about needing to do some work-arounds for <condition> in
> >> processing tasks in a nested sequential,
> > it would be interesting to find out which problem this was exactly
>
> It was me. I have a <functionaltest> task that does functional testing;
> and a FaultingWaitFor task that reimplemented waitfor as a task
> (throwing a fault of the condition wasnt met by the timeout)
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org
Re: svn commit: r451000 - in /ant/core/trunk/src: main/org/apache/tools/ant/taskdefs/
main/org/apache/tools/ant/taskdefs/condition/ tests/junit/org/apache/tools/ant/
Posted by Steve Loughran <st...@apache.org>.
Antoine Levy-Lambert wrote:
> Hello Peter,
>
> -------- Original-Nachricht --------
> Datum: Fri, 29 Sep 2006 09:44:44 +0100
> Von: "Peter Reilly" <pe...@gmail.com>
> An: "Ant Developers List" <de...@ant.apache.org>
> Betreff: Re: svn commit: r451000 - in /ant/core/trunk/src: main/org/apache/tools/ant/taskdefs/ main/org/apache/tools/ant/taskdefs/condition/ tests/junit/org/apache/tools/ant/
>> there are some issues remaining. I cannot find the e-mail,
>> but someone was
>> talking about needing to do some work-arounds for <condition> in
>> processing tasks in a nested sequential,
> it would be interesting to find out which problem this was exactly
It was me. I have a <functionaltest> task that does functional testing;
and a FaultingWaitFor task that reimplemented waitfor as a task
(throwing a fault of the condition wasnt met by the timeout)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org
Re: svn commit: r451000 - in /ant/core/trunk/src: main/org/apache/tools/ant/taskdefs/ main/org/apache/tools/ant/taskdefs/condition/ tests/junit/org/apache/tools/ant/
Posted by Antoine Levy-Lambert <an...@gmx.de>.
Hello Peter,
let's get Ant 1.7 out quickly then so that we can also do Ant 1.8. :-)
> In ant 1.8, all conditions will be resolved by using void add(Condition
x),
> so tasks that want to have nested conditions just need to extend Task and
> implement add(Condition x).
>
> Peter
>
Antoine
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org
Re: svn commit: r451000 - in /ant/core/trunk/src: main/org/apache/tools/ant/taskdefs/ main/org/apache/tools/ant/taskdefs/condition/ tests/junit/org/apache/tools/ant/
Posted by Peter Reilly <pe...@gmail.com>.
On 9/29/06, Antoine Levy-Lambert <an...@gmx.de> wrote:
>
> Hello Peter,
>
> -------- Original-Nachricht --------
> Datum: Fri, 29 Sep 2006 09:44:44 +0100
> Von: "Peter Reilly" <pe...@gmail.com>
> An: "Ant Developers List" <de...@ant.apache.org>
> Betreff: Re: svn commit: r451000 - in /ant/core/trunk/src:
> main/org/apache/tools/ant/taskdefs/
> main/org/apache/tools/ant/taskdefs/condition/
> tests/junit/org/apache/tools/ant/
> > there are some issues remaining. I cannot find the e-mail,
> > but someone was
> > talking about needing to do some work-arounds for <condition> in
> > processing tasks in a nested sequential,
> it would be interesting to find out which problem this was exactly
>
>
> Was the email you are talking about the one from Alexey Solofnenko saying
> we cannot macrodef a condition ?
No it was steves .. see his message.
The discussion was about using ConditionBase in antunit and the consequences
of doing this.
http://marc.theaimsgroup.com/?l=ant-dev&m=115928696418366&w=2
>
> You suggested to add an elements tag to macrodef. This seems cleaner than
> to say that condition are tasks and are allowed in the sequential element.
I am not trying to say that conditions are tasks...
It is the tasks that extend ConditionBase that cause the problem. As they
extend
ConditionBase, they are not instances of oata.Task, but they are taskdefed
as tasks, so
ant provides an internal TaskAdapter to allow them to be used as tasks in
some situations.
The TaskAdapter has a pointer the the object instance, which gets used for
setting attributes
and elements, but not for other cases like references.
At one stage (for a few hours), <fail> extended ConditionBase to get access
to the conditions. I pointed out that this was not a good idea as 1) it was
not backward compatible 2) the resultant xml was a little ambigeous. The
solution was to have a nested element <condition> in <fail>, this nested
element extended ConditionBase.
> also a reference to a <condition> returns a TaskAdapter and not
> > a
> > Condition:
> >
> > TaskAdapter ta = (TaskAdapter) getProject().getReference("cond");
> > ConditionTask c = (ConditionTask) ta.getProxy();
> >
> Why does a reference to a condition return a taskadapter ? This sounds
> like a bug. Where is the faulty piece of code ? Was it like that already in
> Ant 1.6 ?
See above, it is like this in ant1.6 and is true for all taskadapted tasks.
I am not
too sure if it is a bug.
> >
> > As there is not much benefit for the change, I can roll-back the change.
> >
> May be
Ok, I am convinced agree that it is not a good idea....
The reason is the example you provide in the ant-contrib example:
<and>
<isset property="blue sky"/>
<waitfor .../>
</and>
<waitfor> is not meant to be used as a condition (although it extends
conditionbase).
In ant 1.8, all conditions will be resolved by using void add(Condition x),
so tasks that want to have nested conditions just need to extend Task and
implement add(Condition x).
Peter
> > Peter
> >
> >
> Antoine
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org
>
>
Re: svn commit: r451000 - in /ant/core/trunk/src:
main/org/apache/tools/ant/taskdefs/
main/org/apache/tools/ant/taskdefs/condition/ tests/junit/org/apache/tools/ant/
Posted by Antoine Levy-Lambert <an...@gmx.de>.
Hello Peter,
-------- Original-Nachricht --------
Datum: Fri, 29 Sep 2006 09:44:44 +0100
Von: "Peter Reilly" <pe...@gmail.com>
An: "Ant Developers List" <de...@ant.apache.org>
Betreff: Re: svn commit: r451000 - in /ant/core/trunk/src: main/org/apache/tools/ant/taskdefs/ main/org/apache/tools/ant/taskdefs/condition/ tests/junit/org/apache/tools/ant/
> there are some issues remaining. I cannot find the e-mail,
> but someone was
> talking about needing to do some work-arounds for <condition> in
> processing tasks in a nested sequential,
it would be interesting to find out which problem this was exactly
Was the email you are talking about the one from Alexey Solofnenko saying we cannot macrodef a condition ?
http://marc.theaimsgroup.com/?l=ant-dev&m=115928696418366&w=2
You suggested to add an elements tag to macrodef. This seems cleaner than to say that condition are tasks and are allowed in the sequential element.
> also a reference to a <condition> returns a TaskAdapter and not
> a
> Condition:
>
> TaskAdapter ta = (TaskAdapter) getProject().getReference("cond");
> ConditionTask c = (ConditionTask) ta.getProxy();
>
Why does a reference to a condition return a taskadapter ? This sounds like a bug. Where is the faulty piece of code ? Was it like that already in Ant 1.6 ?
>
> As there is not much benefit for the change, I can roll-back the change.
>
May be
> Peter
>
>
Antoine
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org
Re: svn commit: r451000 - in /ant/core/trunk/src: main/org/apache/tools/ant/taskdefs/ main/org/apache/tools/ant/taskdefs/condition/ tests/junit/org/apache/tools/ant/
Posted by Peter Reilly <pe...@gmail.com>.
On 9/29/06, Antoine Levy-Lambert <an...@gmx.de> wrote:
>
> Hello Peter,
>
> I would like simply to understand why you did this change. What does this
> bring us ?
>
> A class that does not have an execute method is semantically not a task.
> So I would also say that such a class should not extend Task.
There are a number of tasks that extend conditionbase - <condition>,
<waitfor>, and the <ac:if> task.
They do cause some issues - ant 1.7 had addresses some of these by adding
taskname and location
information, but there are some issues remaining. I cannot find the e-mail,
but someone was
talking about needing to do some work-arounds for <condition> in processing
tasks in a nested
sequenial, also a reference to a <condition> returns a TaskAdapter and not a
Condition:
TaskAdapter ta = (TaskAdapter) getProject().getReference("cond");
ConditionTask c = (ConditionTask) ta.getProxy();
Can we find a way to get whatever you want to achieve by this change in a
> way which makes sense semantically ? I remember we were discussing before
> about maybe declaring conditions with typedefs. Would this be something
> which would address your concerns ?
No, this is a dirrerent issue.
Regards,
>
> Antoine
> -------- Original-Nachricht --------
> Datum: Fri, 29 Sep 2006 05:31:10 +0200
> Von: Stefan Bodewig <bo...@apache.org>
> An: dev@ant.apache.org
> Betreff: Re: svn commit: r451000 - in /ant/core/trunk/src:
> main/org/apache/tools/ant/taskdefs/
> main/org/apache/tools/ant/taskdefs/condition/
> tests/junit/org/apache/tools/ant/
>
> > On Thu, 28 Sep 2006, <pe...@apache.org> wrote:
> >
> > > Make conditionbase a Task.
> > > ?was there any reason that this was not done for ant 1.6?
> >
> > When I brought the whole condition eco-system into 1.4, I decided
> > against extending Task because some of the conditions themselves
> > extend ConditionBase as well. When you make ConditionBase extend Task
> > this suddenly turns <and>, <or> and <not> into tasks.
Only if they are typedef'ed.
>
> > I also don't think it's a good idea to extend task but not provide an
> > implementation of execute().
True, but the implementation of execute() can be to do nothing - i.e. treat
me as a type, or process everything in addConfigured() callbacks.
>
> > Stefan
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> > For additional commands, e-mail: dev-help@ant.apache.org
As there is not much benefit for the change, I can roll-back the change.
Peter
---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org
Re: svn commit: r451000 - in /ant/core/trunk/src:
main/org/apache/tools/ant/taskdefs/
main/org/apache/tools/ant/taskdefs/condition/ tests/junit/org/apache/tools/ant/
Posted by Antoine Levy-Lambert <an...@gmx.de>.
Hello Peter,
I would like simply to understand why you did this change. What does this bring us ?
A class that does not have an execute method is semantically not a task. So I would also say that such a class should not extend Task.
Can we find a way to get whatever you want to achieve by this change in a way which makes sense semantically ? I remember we were discussing before about maybe declaring conditions with typedefs. Would this be something which would address your concerns ?
Regards,
Antoine
-------- Original-Nachricht --------
Datum: Fri, 29 Sep 2006 05:31:10 +0200
Von: Stefan Bodewig <bo...@apache.org>
An: dev@ant.apache.org
Betreff: Re: svn commit: r451000 - in /ant/core/trunk/src: main/org/apache/tools/ant/taskdefs/ main/org/apache/tools/ant/taskdefs/condition/ tests/junit/org/apache/tools/ant/
> On Thu, 28 Sep 2006, <pe...@apache.org> wrote:
>
> > Make conditionbase a Task.
> > ?was there any reason that this was not done for ant 1.6?
>
> When I brought the whole condition eco-system into 1.4, I decided
> against extending Task because some of the conditions themselves
> extend ConditionBase as well. When you make ConditionBase extend Task
> this suddenly turns <and>, <or> and <not> into tasks.
>
> I also don't think it's a good idea to extend task but not provide an
> implementation of execute().
>
> Stefan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org
Re: svn commit: r451000 - in /ant/core/trunk/src:
main/org/apache/tools/ant/taskdefs/
main/org/apache/tools/ant/taskdefs/condition/
tests/junit/org/apache/tools/ant/
Posted by Stefan Bodewig <bo...@apache.org>.
On Thu, 28 Sep 2006, <pe...@apache.org> wrote:
> Make conditionbase a Task.
> ?was there any reason that this was not done for ant 1.6?
When I brought the whole condition eco-system into 1.4, I decided
against extending Task because some of the conditions themselves
extend ConditionBase as well. When you make ConditionBase extend Task
this suddenly turns <and>, <or> and <not> into tasks.
I also don't think it's a good idea to extend task but not provide an
implementation of execute().
Stefan
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org