Link checking with ant

Is there a way to check in ant that a link with a specific refid is defined somewhere?

For example, I need to verify that my.ref is defined before using it as follows.

<pathconvert property="my.prop" refid="my.ref">
...
</pathconvert>

I need to do this, as there are some build scripts in my project that are not under my control (in fact, I’m sometimes not allowed to view their contents).

These scripts should define this link. Unfortunately, I cannot assume that this link is defined for some reason.

So, I need to check it out and perform graceful error handling or some specific actions.

Is there any way to do this?

Update:

I found the right way to do it myself. This can be done using isreferencethe task item condition.

For instance:

<condition property="my.ref.defined">
    <isreference refid="my.ref"/>
</condition>
<fail unless="my.ref.defined" message="Reference my.ref not defined."/>
+5
2

, . :

<property name="my.prop" value="${toString:my.ref}" />
+3

, , ${ ant.refid: reference}, . Ant Manual, ${toString: reference}.

Ant Flaka =

 <project name="demo" xmlns:fl="antlib:it.haefelinger.flaka">
  <fl:fail message="Houston we have a problem" test="not has.property['ant.refid:my.ref']"/>

, , , , , , , , .

 <fl:when test="not has.property['ant.refid:my.ref']">
  ...
 </fl:when>

. Flaka

0

All Articles