Yes,
it is painful!

It is a pity that we have to use xmlns for namespace resolution of
task/type names.

I would rather do something like:

<loadantlib classpath="jars/example.jar"/>

<example-hello/>

Where example.jar contains a manifest entry like:

ant-prefix: example
example-antlib: a/b/c/antlib.xml



Peter

On 5/23/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:

Thanks that works.


<project xmlns:myns="antlib:com.acme.ant.antlib">
    <taskdef uri="antlib:com.acme.ant.antlib"
             resource="com/acme/ant/antlib/antlib.xml"
                 classpath="path/to/antlib.jar"/>


So I have the following mappings:
* xml namespace (on project tag) maps to the antlib-URI
* the antlib-URI (uri on taskdef) maps to the resource (on taskdef) on the
given classpath (on taskdef).


Jan

>-----Ursprüngliche Nachricht-----
>Von: Peter Reilly [mailto:[EMAIL PROTECTED]
>Gesendet: Montag, 22. Mai 2006 14:00
>An: Ant Users List
>Betreff: Re: Could I bind an antlib to a xmlns via <taskdef>?
>
>Hi Jan,
>
>You are forgetting to bind the xmlns namespace to a URI.
>
>
><project xmlns:example="antlib: a.b.c" .../>
>    <taskdef resource="a/b/c/antlib.xml"
>             uri="antlib:a.b.c"
>                    classpath="jars/example.jar"/>
>      <example:hello/>
>
>Peter
>
>
>On 5/22/06, [EMAIL PROTECTED]
><[EMAIL PROTECTED]> wrote:
>>
>> I created an antlib for a bundle of tasks/macrodefs. Including via
>>     <project xmlns:ccm="antlib:...">
>> works, but then
>> - I have to add the antlib to the global Ant installation
>> (%ANT_HOME%/lib; %USER_HOME%/.ant/lib)
>>   which means the build is not reliable after a checkout on a clean
>> machine [1] or
>> - modify the start command (ant.bat; %ANT_OPTS%;
>> %USER_HOME%/ant_{pre|post}.bat) which makes
>>   that machine different from the other in the team.
>>
>> I would prefer having the antlib in the project directory
>and bind the
>> antlib with the given classpath inside the buildfile.
>>
>>
>>
>>
>>   <typedef resource="antlib:..." uri="ccm"
>> classpath="../../build/antlib.jar"/>
>>   <ccm:start user="${user}" pwd="${pwd}" database="${db}"/> this
>> results in
>>   The prefix "ccm" for element "ccm:start" is not bound.
>>     at
>>
>org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:2
>> 33
>> )
>>     at
>>
>org.apache.tools.ant.helper.ProjectHelper2.parse (ProjectHelper2.java:1
>> 40
>> )
>>     at
>>
>org.apache.tools.ant.ProjectHelper.configureProject(ProjectHelper.java
>> :9
>> 1)
>>     at org.apache.tools.ant.Main.runBuild (Main.java:653)
>>     --- Nested Exception ---
>>     at
>>
>org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unk
>> no
>> wn Source)
>>     ...
>>     at
>org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
>>         at
>>
>org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:2
>> 17
>> )
>>
>>
>>
>> I think this is because the error occurs while parsing and the
>> <taskdef> would be executed after that.
>>
>> Does anyone see a possibility to load the antlib from inside the
>> buildfile?
>>
>>
>> Jan
>>
>>
>> [1]
>>
>http://martinfowler.com/articles/continuousIntegration.html#MaintainAS
>> in
>> gleSourceRepository.
>>     "The basic rule of thumb is that you should be able to
>walk up to
>> the project with a virgin machine,
>>     do a checkout, and be able to fully build the system."
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED] For
>additional
>> commands, e-mail: [EMAIL PROTECTED]
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Reply via email to