ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <Jan.Mate...@rzf.fin-nrw.de>
Subject AW: Could I bind an antlib to a xmlns via <taskdef>?
Date Tue, 23 May 2006 06:22:40 GMT
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:peter.kitt.reilly@gmail.com] 
>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, Jan.Materne@rzf.fin-nrw.de 
><Jan.Materne@rzf.fin-nrw.de> 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: user-unsubscribe@ant.apache.org For 
>additional 
>> commands, e-mail: user-help@ant.apache.org
>>
>>
>

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


Mime
View raw message