Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use wildcard in Ant's Available command

Tags:

java

ant

I'm using an Ant build script to collate my Eclipse-based application for distribution.

One step of the build is to check that the correct libraries are present in the build folders. I currently use the Ant command for this. Unfortunately, I have to amend the script each time I switch to a new Eclipse build (since the version numbers will have updated).

I don't need to check the version numbers, I just need to check that the file's there.

So, how do I check for:

org.eclipse.rcp_3.5.0.*

instead of:

org.eclipse.rcp_3.5.0.v20090519-9SA0FwxFv6x089WEf-TWh11

using Ant?

cheers, Ian

like image 572
ianmayo Avatar asked Jul 02 '09 08:07

ianmayo


2 Answers

You mean, something like (based on the pathconvert task, after this idea):

<target name="checkEclipseRcp">
  <pathconvert property="foundRcp" setonempty="false" pathsep=" ">
    <path>
      <fileset dir="/folder/folder/eclipse"
               includes="org.eclipse.rcp_3.5.0.*" />
    </path>
  </pathconvert>
</target>

<target name="process" depends="checkEclipseRcp" if="foundRcp">
  <!-- do something -->
</target>
like image 136
VonC Avatar answered Oct 13 '22 00:10

VonC


A slightly shorter and more straightforward approach with resourcecount condition:

<target name="checkEclipseRcp">
    <condition property="foundRcp">
        <resourcecount when="greater" count="0">
            <fileset file="/folder/folder/eclipse/org.eclipse.rcp_3.5.0.*"/>
        </resourcecount>
    </condition>
</target>

<target name="process" depends="checkEclipseRcp" if="foundRcp">
  <!-- do something -->
</target>
like image 45
Vadzim Avatar answered Oct 13 '22 00:10

Vadzim