I'm writing ant script that updates from an svn repo. However update doesn't work if I first haven't manually done a checkout from the repo.
I want the svnant to do the following: if svn checkout done, then update else do svn checkout and update.
I'm writing ant script that updates from an svn repo. However update doesn't work if I first haven't manually done a checkout from the repo.
I want the svnant to do the following: if svn checkout done, then update else do svn checkout and update.
Here are two ways - method1, method2 (use if statement from bash therefor is shorten then awkward ant property ). Both have same idea behind if there is .svn file then it means we are in checkout and we do update only, if .svn is missing we do need to make checkout.
<?xml version="1.0"?>
<project>
<target name="check-svn">
<available file=".svn" property="svn.present"/>
</target>
<target name="method1">
<antcall target="svnup"/>
<antcall target="svnco"/>
</target>
<target name="svnup" depends="check-svn" if="svn.present">
<exec executable="echo">
<arg value="svn update"/>
</exec>
</target>
<target name="svnco" depends="check-svn" unless="svn.present">
<exec executable="echo">
<arg value="svn checkout"/>
</exec>
</target>
<target name="method2">
<exec executable="bash">
<arg value="-c"/>
<arg value="if [ -e .svn ];then echo svn update; else echo svn checkout; fi"/>
</exec>
</target>
</project>
Bash way:
([ -e .svn ] && echo svn update) || echo svn checkout