The use case here was to check whether the path has already existed in SVN using ANT. I was staring on the script (shown below) for a very long time and wondering how could I improve the piece to make it more interesting and sexy.
<if>
<svnExists target="${svnPath}/MessageFlow/${tagname}" refid="svn.settings"/>
<then>
...
</then>
</if>
<if>
<not><svnExists target="${svnPath}/MessageFlow/${tagname}" refid="svn.settings"/></not>
<then>
...
</then>
</if>
After some rearrangement then I come out this piece:
<condition property="exists">
<svnExists target="${ svnPath}/MessageFlow/${tagname}" refid="svn.settings"/>
</condition>
<!—if exists is false -->
<if>
<not><equals arg1="${exists}" arg2="true"/></not>
<then>
...
</then>
</if>
<!—if exists is true -->
<if>
<equals arg1="${exists}" arg2="true"/>
<then>
...
</then>
</if>
The difference on the newer piece is that I've adopted
<condition> in the script and the result was keep in
exists property. Would it be better? Errrrr... It seems that a lot more code need to be done to achieve the same result.
No comments:
Post a Comment