ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Reilly <peter.rei...@corvil.com>
Subject Re: Assign new value to an existing property
Date Fri, 30 Apr 2004 18:12:58 GMT
Nick_Gianakas@sybari.com wrote:

>Thanks Peter.  The external task I'm using is cpptask w/ Ant 1.6.1
>So all I have to do is drop the jar in the appropriate lib directory and 
>reference it w/ the namespace?
>
>  
>
Unfortunally not, as the cpptasks does not yet have an antlib.xml in 
it's jar file.

You can do one of three things:
1) make a common.xml containing

        <taskdef resource="cpptasks.tasks"
                 uri="antlib:net.sf.antcontrib.cpptasks"/>
        <typedef resource="cpptasks.types"
                 uri="antlib:net.sf.antcontrib.cpptasks"/>

In the build file do:

<project xmlns:cpp="antlib:net.sf.antcontrib.cpptasks">
   <import file="${user.home}/common.xml"/>
   <cpp:cc ..../>

2) make a site antlib jar file containing an antlib
with the following macro:
<macrodef name="init">
    <sequential>
        <!-- no antlib.xml in cpptasks yet! -->
        <taskdef resource="cpptasks.tasks"
                 uri="antlib:net.sf.antcontrib.cpptasks"/>
        <typedef resource="cpptasks.types"
                 uri="antlib:net.sf.antcontrib.cpptasks"/>

    </sequential>
  </macrodef>
and drop this into ~/.ant/lib

the build file will now look like;
<project xmlns:cpp="antlib:net.sf.antcontrib.cpptasks"
         xmlns:site="antlib:com.company.site.anttasks">
  <site:init/>
  <cpp:cc ..../>

  
3) unjar the cpptasks.jar file and add the antlib.xml
file to net/sf/antcontrib/cpptasks directory and rejar
the file.
The antlib.xml would look like this:
<antlib>
        <taskdef resource="cpptasks.tasks"
                 uri="antlib:net.sf.antcontrib.cpptasks"/>
        <typedef resource="cpptasks.types"
                 uri="antlib:net.sf.antcontrib.cpptasks"/>
<antlib>

Peter

>Regards,
>Nick G.
>
>
>
>
>
>
>Peter Reilly <peter.reilly@corvil.com>
>04/30/2004 12:48 PM
>Please respond to "Ant Users List"
> 
>        To:     Ant Users List <user@ant.apache.org>
>        cc: 
>        Subject:        Re: Assign new value to an existing property
>
>
>In ant 1.6, the idea is to use xml namespaces
>to trigger loading of third party (and in a near
>future ant release ant optional) tasks and types.
>
>The reason for this is allow different ant task
>libraries to use their own names - so for example
>one could use the name "filter" for a type
>without checking to see it is already used by
>other ant libraries.
>
>When this was initially consided by the ant-dev
>mailing list, it was decided to use xml namespace
>to select the namespace rather than use some ad-hoc
>scheme (like using a prefix).
>
>With an antlib, all one needs to do is drop
>the jar file containing the tasks/types and any
>needed extra jar file into $ANT_HOME/lib or
>into ~/.ant/lib, and use the tasks without doing
>any <typedef/> or <taskdef/>.
>
>The namespace URI (Uniform Resource Identifier) for
>these  antlibs are of the form - "antlib:"<java package name>.
>
>So to use ant-contrib tasks, place the ant-contrib.jar file into
>~/.ant/lib. and use the tasks in the build file:
>
><project default="shelltest" xmlns:ac="antlib:net.sf.antcontrib">
>  <target name="shelltest">
>    <ac:shellscript>
>      ls -lrta
>    </ac:shellscript>
>   </target>
></project>
>
>One of the problems with using XML NS, is that it can look
>confusing and it can be tricky sometimes to know which is
>the correct prefix to use.
>
>For example:
><project default="iftest" xmlns:ac="antlib:net.sf.antcontrib">
>  <target name="iftest">
>   <ac:if>
>      <ac:or>
>         <ac:equals arg1="/home/peter" arg2="${user.home}"/>
>         <ac:equals arg1="/home/preilly" arg2="${user.home}"/>
>       </ac:or>
>       <ac:then>
>          <echo>User is "peter"</echo>
>       </ac:then>
>   </ac:if>
>   </target>
></project>
> 
>
>Peter
>
>Nick_Gianakas@sybari.com wrote:
>
>  
>
>>Hi Matt,
>>
>>Now that you mention it, I wonder if someone has any suggestions as to 
>>    
>>
>not 
>  
>
>>requiring the <taskdef> either.  Is there some Ant properties file I can 
>>edit to add external tasks so they don't have to be referenced explicitly 
>>    
>>
>
>  
>
>>in my build.xml?  My work is internal only so I'm not worried about 
>>distribution issues.
>>
>>Regards,
>>Nick G.
>>
>>
>>
>>
>>
>>
>>Matt Benson <gudnabrsam@yahoo.com>
>>04/30/2004 10:02 AM
>>Please respond to "Ant Users List"
>>
>>       To:     Ant Users List <user@ant.apache.org>
>>       cc: 
>>       Subject:        RE: Assign new value to an existing property
>>
>>
>>--- Matt Benson <gudnabrsam@yahoo.com> wrote:
>>
>>
>>    
>>
>>>If you are able to add the ant-contrib jar to
>>>ANT_HOME/lib, then firstly, you don't need the
>>>nested
>>><classpath> in the <taskdef> above. Also, with later
>>>ant-contrib distributions, there are other options,
>>>including any of the various <antlib> loading
>>>possibilities.  See the manual for examples which
>>>include the use of ant-contrib in particular.
>>>
>>>
>>>      
>>>
>>To clarify, I was mostly discussing antlib namespaces
>>there... ant-contrib's included <antlib> definition
>>simply delegates to its properties file(s), IIRC.  I
>>simply find that the antlib namespace stuff is terse
>>and convenient to use.
>>
>>-Matt
>>
>>
>>
>>
>>__________________________________
>>Do you Yahoo!?
>>Win a $20,000 Career Makeover at Yahoo! HotJobs 
>>http://hotjobs.sweepstakes.yahoo.com/careermakeover 
>>
>>---------------------------------------------------------------------
>>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
>>
>>
>>
>>
>>
>>    
>>
>
>
>---------------------------------------------------------------------
>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
>
>
>
>  
>


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


Mime
View raw message