ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peter reilly <lucyk...@eircom.net>
Subject Re: Namespaces in Ant
Date Sun, 04 May 2003 00:03:00 GMT
I would agree with most of what Nicola says. I think
that XML ns is a "heavy" solution for name clashing
of names defined in a antlib. Moreover I do not
think that the antlib needs to define a qualified name.
The "prefix" attribute idea of the <property/> task could
be used - even with the current <typedef/> command.

<typedef resource="net/sf/antcontrib/antcontrib.properties"
         prefix="antcontrib"/>

To quote for the XML NS specification, XML NS
is used to to define elements and attribute "that are defined
for and used by multiple software modules."

Antlib's define ant types which are new elements, but the
attributes and nested elements of those elements are still
figured out by the ant "software module" using reflection on
the classes the tags map to.

Costin's idea of using "jmx:..." as a NS URI, seems to be a better
fit for using XML NS.

I think that another idea would be the use case of documenting
the build script. Something like the equalivant to javadoc for
ant scripts. Something like this should be in xml, but it does
not need to be processed as part of a build.

Something like the following:

<project default="t" xmlns:antdoc="http://ant.apache.org/antdoc">
  
  <antdoc:comment>
    The target t is the default for this project
  </antdoc:comment>
    
  <target name="t">
    <antdoc:comment>This is simple test</antdoc:comment>
    <comment xmlns="http://ant.apache.org/antdoc">
      <this>this is an anddoc comment</this>
    </comment>
    <echo message="hello world"/>
    <antdoc:comment>
      The following should be an ok ant task
      <echo message="a message within an ant doc comment"/>
    </antdoc:comment>
    <comment xmlns="http://ant.apache.org/antdoc"
             xmlns:ant="http://ant.apache.org">
      <this>this is an antdoc element</this>
      <ant:echo ant:message="this is an ant echo command"
                antdoc:message="this is for antdoc"/>
    </comment>
  </target>
  
  <antdoc:ignore>
    <!-- These are test tasks and will not be shown in
         an ant doc report -->
    <target name="test">
      <echo>This is a test</echo>
    </target>
  </antdoc:ignore>
  
</project>

Attached is a  patch (cvs diff -u) to ProjectHelper2 to allow
the above. - the code is a quick hack - an idea may be to
allow NS URI handler plugins...

Cheers,
Peter
Nicola Ken Barozzi wrote:
> Costin Manolache wrote, On 03/05/2003 16.14:
>> Nicola Ken Barozzi wrote:
...
>>>I think that XML namespaces really make things much more difficult to
>>>write and understand. One thing I don't like in Jelly is just this
use
>>>of namespaces, where all scripts seem cluttered and simply difficult
to
>>>read.
> 
>> I agree - in most small build files, with few libraries and no
conflicting
>> names it is simpler to not use ns. 
> 
>> I don't think anyone is sugesting to make ns required for 1.6 ( we
need
>> to keep backward compat ). Even for antlibs, I think the ns should be
an
>> option.

>Ok, but namespaces are a "heavy" way of doing separation. ATM I don't 
>think that that it's good if they are not always used (and I don't like
>much to see them used).

>>>This is why I favor that Antlibs work similarly to java imports,
where
>>>there are no prefixes *except* when specified, and then I would *not*
>>>make prefixes free, but use the "standars" full name for that Antlib.
> 
>> Can you give an example ?

>Sure.

>Every antlib descriptor should contain not only the names of the tasks 
>but also the namespace of the antlib.
>When Ant loads the tasks, it does it with two names, so that the task 
>can be called with short or the fully qualified name.
>Example:
>
>   <antlib location="antcontrib.jar"/>
>
>   <!-- I can call it on both ways -->
>   <if/>
>   <antcontrib.if/>
>
>In the case that a library declares a task with the same name of one 
>already loaded, Ant should load the fully qualified name version and 
>change the short-name version to output an error about clashing names.





Mime
View raw message