01 Jun
Posted by: Brandon Harper in: A Day In The Life Of, Ant, ColdFusion, Culture, Java, Languages, Tips, Hacks, & Tricks, Tools
Last week I decided it was time to start looking at integrating the check-out of code from Subversion as a part of my build process for the various projects I work on. Turns out, it’s pretty easy.
Download the CLI Subversion client and install it. You may need to reboot afterwards (I rebooted my machine in the process of getting this to work, so it’s possible that the path variable changed then.)
Below are a few snips from one of my build.xml files which pull the code out of Subversion using the CLI client. It probably won’t be formatted correctly (something seems to be tripping up the code tag), but I’ll check it out later.
<property name=”root.dir” value=”${basedir}”/>
<property name=”root.src” value=”c:\wwwroot”/>
<property name=”root.dev” value=”c:\wwwroot”/>
<property name=”root.buildpath” value=”c:\Builds”/>
<property name=”root.backuppath” value=”c:\Backups\Code” />
<property name=”root.testingpath” value=”\servername\path”/>
<property name=”project.name” value=”ThisProject” />
<property name=”project.dev.root” value=”${root.dev}${project.name}”/>
<property name=”project.build.root” value=”${root.buildpath}${project.name}”/>
<property name=”project.backup.root” value=”${root.backup}${project.name}” />
<property name=”project.testing.root” value=”${root.testing}${project.name}”/>
<property name=”svn.rooturl” value=”svn://svnurlhere/”/>
<property name=”svn.username” value=”svnusername”/>
<property name=”svn.password” value=”svnpassword”/>
<property name=”svn.projecturl” value=”${svn.rooturl}${project.name}/trunk/”/>
<property name=”svn.revision” value=”HEAD”/>
<target name=”cleanBuild” description=”Cleans the build directory”>
<delete dir=”${project.build.root}” />
</target>
<target name=”createBuildDir” description=”Creates the build directory”>
<mkdir dir=”${project.build.root}” />
</target>
<target name=”makeBuild” description=”Pulls code from Subversion into the build directory” depends=”cleanBuild,createBuildDir,checkoutBuild”>
</target>
<target name=”checkoutBuild” description=”Pulls code from Subversion into the build directory”>
<exec executable=”svn”>
<arg line=”co ${svn.projecturl} ${project.build.root} -r ${svn.revision} –username ${svn.username} –password ${svn.password}”/>
</exec>
</target>
3 Responses
Joe Rinehart
17|Jun|2005 1Hey Brandon,
Thanks for posting this - saved me a bundle of time figuring it out myself this morning. I just googled “subversion ant,” and you were #3 with exactly what I needed to do.
-Joe
Brandon Harper
20|Jun|2005 2Hey Joe,
It wasn’t uber difficult or anything, but a timesaver that I figured someone else would find useful– glad it helped you out!
I’ve been taking a look at Model-Glue lately and find it to to be fairly intriguing. Lately I’ve been writing a lot of back-end (only a management GUI) apps which didn’t really work well in an event based architecture like Mach-II. I ended up rolling my own very lightweight architecture which is mostly pure OO and it’s very similar to Model-Glue (like using Config Beans for example).
Anyhow, I can see myself starting to move to it with the stuff I’m working on as Model-Glue is an open standard rather than my own concoction… nice work!
devnulled: A blog by Brandon Harper » Adding The Subversion Build Number To Your Application Using Ant
02|Aug|2005 3[...] grabs the build number from the builds directory where I’ve already deployed a build using a previous task I wrote. 2. The output of said task is pip [...]
Leave a reply