ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Conor MacNeill" <>
Subject RE: antlib descriptor
Date Thu, 21 Feb 2002 23:40:13 GMT
> From: Jose Alberto Fernandez []

BTW, there is only one "n" in Conor.

> Connor you are misunderstanding what roles are
> designed for. They are not designed as a way to allow
> polymorphism of arguments to methods.

Well that is what most examples of Roles have been about. People talk about
ejbjar in this context a lot and I see that as something that is easily
solvable with polymorphic behaviour rather than needing the all the
machinery of roles. A simple method

addDeploymentTool(DeploymentTool tool)

should be enough.

Since <ejbjar> extension is one of your stated goals in defining roles, I
see considerable overlap.

> In all your examples, the objects you are trying to
> pass belong to one unique role, i.e data-type.
> Your proposal, make deal with polymorphic arguments,
> however it does not resolve the issue of roles like
> Tasks or datatypes. If we were to use your mechanism
> we will finish with build files like:
> <target ...>
>   <parallel>
>      <task ant:type="javac" .... />
>      <task ant:type="copy" .... />
>   </parallel>
> </target>

That doesn't happen in mutant because TaskContainer is still there and it
does get specific treatment. I don't see that as a problem. In mutant this
is not a problem and data types cannot be added to a task container unless
it specifically has a method to accept the datatype. The fact that works in
Ant1 is a byproduct of Ant1's design limitations. The problem with allowing
this to happen is it suggests things are possible which are not.

Consider this
<project name="paralleldata" basedir="." default="main">
  <target name="main">
      <fileset dir="..">
        <include name="**/*.xml"/>
      <echo message="hello"/>
      <echo message="hello"/>

In ant today, this seems to work but the fileset is useless. It is
misleading. It may even hide a mistake in the build if someone puts in a
slash and terminates an element prematurely.

In mutant you will get this
D:/antdev/bugs/paralleldata/build.xml:4: parallel does not support the
"fileset" nested element
Root cause: org.apache.ant.common.util.ExecutionException: parallel does not
support the "fileset" nested element

This is what happens with mutant today.

The underlying problem here is the fact that Ant1 tries to perform
configuration at parse time when it doesn't have enough information. For
some tasks it has to defer the config but it does that by making everything
a task.

Regularising treatment of datatypes and tasks in the core does not address
this. It will just cement the incorrect Ant1 behaviour. I don't see a need
to have the core behave that generically.

> You will have to make a special case for TaskContainer
> and we will be back on the same crappy spot we have
> been sitting for more than a year.

7 months actually.

> Now lets talk about POLYMORPHISM in its own right.
> In my opinion, the problem we have in ANT, if that we
> mix in the syntax of an element: the name of the
> element to use AND the name of the method to invoke.
> Polymorphism requires a way to diferentiate one from
> the other.
> Your approach provides that separation, so it solves
> the polymorphic issue. The thing I do not like about
> it is that it breaks completely any resemblance of
> DTD. In other words there is no way for AntStructure
> to generate a DTD. Why?, see the example:
>  <diff>
>      <fromFS ant:type="zipfileset"
> dir="htdocs/manual"
>  prefix="docs/user-guide"/>
>      <toFS ant:type="classfileset"
>  dir="build/classes">
>         <root classname=""/>
>      </toFS>
>  </diff>
> There is no way to define a DTD for <formFS> or <toFS>
> because its structure depends on the the value of
> 'ant:type' and not on the value of the tag.
> A much more XML friendly way would be to let the
> element describe the type and the attribute describe
> the method to use:
>  <diff>
>    <zipfileset ant:as="fromFS"  dir="htdocs/manual"
> prefix="docs/user-guide"/>
>    <classfileset ant:as="toFS" dir="build/classes">
>         <root classname=""/>
>    </classfileset>
>  </diff>

So you begin to taste the chocolate. The problem with the above is that it
is not easy to support references. Again from mutant

     <fromFS ant:refid="my.fileset"/>
     <toFS ant:refid="your.fileset"/>

I actually tried the "ant:as" approach but settled on the "ant:type" syntax
because of the above. It is more regular to align the nested element name
with the method.


To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message