Anna:

I think that you aren't doing everything that you think you are doing in this snippet. In particular, it appears as if nothing ever sets the isaFile property. And, because your printError target depends on the isaFile property being set, you will never get your error message.

If I do a little guessing, I think that you <condition> task should be:

<condition property="isaFile">
<and>
<isset property="present" /> <not> <isset property="isaDir" /> </not>
 </and>
 </condition>

Instead of:

 <condition property="isaDir">
 <and>
<isset property="present" /> <not> <isset property="isaFile" /> </not>
  </and>
  </condition>
In other words, I think that you want to set the isaFile property if 
${caratsharp.dir} exists but is NOT a directory, correct?

And, I think that you need to check for 3 things:

1. ${caratsharp.dir} doesn't exist at all ... that's an error.
2. ${carachsarp.dir} exists, but is not a directory (that is, it's a regular 
file) .... that's an error condition, too, isn't it?
3. ${caratsharp.dir} exists and is a directory .... this is what you want?

Here is, I think, a slightly modified version of your build.xml that, I think, 
does what you want .... maybe not in the most elegant way, but it is at least 
functional:

<target name="checkForCaratSharpDir">
 <available property="present" file="${caratsharp.dir}" />
 <available property="isaDir" file="${caratsharp.dir}" type="dir" />
 <condition property="isaFile">
   <and>
     <isset property="present" />
     <not>
       <isset property="isaDir" />
     </not>
   </and>
 </condition>
</target>

<target name="exists" depends="checkForCaratSharpDir" if="isaDir">
<echo message="${caratsharp.dir} exists" /> <antcall target="clean" /> <antcall target="prepare" /> <antcall target="jar" /> <antcall target="copy_jar" /> </target>
<target name="printError" depends="checkForCaratSharpDir" unless="present">
<echo message="${caratsharp.dir} does not exist" /> </target>
<target name="printFileError" depends="checkForCaratSharpDir" if="isaFile">
<echo message="${caratsharp.dir} is a file instead of a directory" /> </target> <target name="all" depends="exists,printError,printFileError" description="Cleans, compile then builds the JAR file." />
At least that's the way it looks to me ....

Good luck,

John



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

Reply via email to