macrodef - ant nesting macro call -


i call macro inside element of macro. let's suppose have following macro:

<macrodef name="jc">     <attribute name="name" />     <attribute name="destdir" />     <element name="fileset-list" optional="false" />     <sequential>         <jar destfile="@{destdir}${file.separator}@{name}.jar" update="false">             <fileset-list />             <manifest>                 <attribute name="manifest-version" value="1.0" />                    </manifest>         </jar>     </sequential> </macrodef> 

and macro

<macrodef name="defaultfs" description="defines default fileset">     <attribute name="path" />     <sequential>         <fileset dir="${dir.build.classes}">             <include name="@{path}/**/*.class" />         </fileset>         <fileset dir="${src.ehs}">             <include name="@{path}/**/icons/**" />             <include name="@{path}/**/sounds/**" />             <include name="@{path}/**/*.gif" />             <include name="@{path}/**/*.png" />             <include name="@{path}/**/*.wav" />             <include name="@{path}/**/*.jpg" />             <include name="@{path}/**/*.properties" />             <include name="@{path}/**/*.xml" />             <include name="@{path}/**/jaxb.index" />         </fileset>     </sequential> </macrodef> 

i use these macros follow:

<jc destdir="${dir.build.jar}" name="thejar">     <fileset-list>         <defaultfs path="org/path/inner" />     </fileset-list> </jc> 

what following error message:

jar doesn't support nested "defaultfs" element. 

what wrong?

you try making macro call within main macro 'jc' , pass fileset path consider additional attribute

<macrodef name="jc">     <attribute name="name" />     <attribute name="destdir" />     <attribute name="fileset.path.to.consider" />     <sequential>         <jar destfile="@{destdir}${file.separator}@{name}.jar" update="false">             <defaultfs path="@{fileset.path.to.consider}"/>             <manifest>                 <attribute name="manifest-version" value="1.0" />             </manifest>         </jar>     </sequential> </macrodef> 

and main macro call :

<jc destdir="${dir.build.jar}" name="thejar" fileset.path.to.consider="org/path/inner"/> 

(not tested, give try )


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -