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: Defining Properties in an Antlib
Date Fri, 06 Nov 2009 09:45:54 GMT
I only see an init macro which sets the values.

Jan



<project xmlns:my="antlib:my">
  <taskdef uri="antlib:my" resource="antlib.xml" classpath="."/>
  <my:init/>
  <my:hello/>
  <echoproperties prefix="my."/>
</project>


<antlib xmlns:current="ant:current">
  <macrodef name="init">
      <sequential>
          <property name="my.--flag--" value="set"/>
          <property name="my.text" value="Hello World"/>
      </sequential>
  </macrodef>
  <presetdef name="checkinit">
      <fail unless="my.--flag--" message="You have to call the 'init' task before using
any other."/>
  </presetdef>
  <macrodef name="hello">
      <sequential>
          <current:checkinit/>
          <echo message="Hello" taskname="hello"/>
      </sequential>
  </macrodef>
</antlib> 

>-----Urspr√ľngliche Nachricht-----
>Von: Dan Turkenkopf [mailto:dturkenk@gmail.com] 
>Gesendet: Donnerstag, 5. November 2009 19:28
>An: user@ant.apache.org
>Betreff: Defining Properties in an Antlib
>
>Is there anyway to define a single set of properties that can be shared
>across all macrodefs in a given antlib?
>
>I have a series of macros that all refer to the same jar 
>files.   I'd like
>to be able to define the locations in a single property within 
>the antlib
>(because the callers don't need to know the details).
>
>Right now, because Property doesn't extend AntlibDefinition, I 
>can't declare
>a property outside of a macrodef.  So I'm stuck declaring the 
>same property
>within each of the macrodefs.
>
>Is there a better way to accomplish the goal of DRY?
>
>Thanks,
>
>Dan Turkenkopf
>

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


Mime
View raw message