java - Ant build.xml file unable to use a property in the fileset element -


i using ant build.xml build simple war file.

<?xml version="1.0" ?>  <project name="cellar" default="war">    <target name="init">     <property file="${user.home}/build.properties"/>     <property name="app.name" value="${ant.project.name}"/>     <property name="src.dir" location="src"/>     <property name="lib.dir" location="lib"/>     <property name="build.dir" location="build"/>     <property name="dist.dir" location="dist"/>     <property name="classes.dir" location="${build.dir}/classes"/>      <mkdir dir="${build.dir}"/>     <mkdir dir="${dist.dir}" />   </target>    <path id="classpath">     <fileset dir="lib">       <include name="*.jar"/>     </fileset>   </path>    <target name="compile" depends="init" >     <javac destdir="${classes.dir}" debug="true" srcdir="${src.dir}">       <classpath refid="classpath"/>     </javac>   </target>    <target name="war" depends="compile" >     <war destfile="${dist.dir}/${app.name}.war" webxml="${src.dir}/main/webapp/web-inf/web.xml">         <fileset dir="${src.dir}/main/webapp/"/>         <lib dir="${lib.dir}"/>         <classes dir="${classes.dir}"/>     </war>   </target>    <target name="clean">     <delete dir="${dist.dir}" />     <delete dir="${build.dir}" />   </target>  </project> 

the ant build.xml shown above works perfectly. in path tag if replace dir="lib" dir="${lib.dir}" (within fileset tags) build fails , error shown below

build failed c:\java\code\cellar\build.xml:22: c:\java\code\cellar\${lib.dir} not exist.

does know why happens?

the classpath defined when build file loaded, whereas properties defined when init target executed.

move properties definition outside of init target, or move fileset definition in target executed after init executed.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -