Archive

Archive for April, 2008

I am Linked In

April 9th, 2008 clickonchris No comments

I have created a linkedin profile. At first I thought linkedin was going to be a facebook or myspace ripoff, but I see now that it’s really a great tool for professional networking. In fact, given that I’m studying business administration and that I have a passion for web applications, I think that linkedin is pretty awesome.
View Christopher Johnson's profile on LinkedIn
www.linkedin.com/in/johnsonchristopherg

Categories: Uncategorized Tags:

Java Project Versioning with perforce+ant

April 8th, 2008 clickonchris No comments

I recently developed a useful ANT task to automatically increment a version number on your Java project when using perforce as your source control application. This task is intended to be run as part of an automated build (via cruisecontrol). It checks out version.properties and checks it back in after incrementing.
Notes:

  1. The task will look for the following files in the same directory as your build.xml. You should be able to figure out what parameters belong in each file by looking at the task. files: version.properties, buildnumber.properties, p4.properties
  2. In the lines where I print the full version number I have broken it up into two lines for display purposes. In practice you will want to keep it on one line. 

<target name="create-label" depends="compile-src">

		<copy todir="${ant.library.dir}"
			file="medremote_dev/tools/jakarta-oro-2.0.8.jar"
			overwrite="false"/>
		<property name="p4.properties"
		            value="p4.local.properties" />
		<property file="${p4.properties}" />

		<property name="p4.port" value="${p4.port}"/>
		<property name="p4.client" value="${p4.client}"/>
		<property name="p4.user" value="${p4.user}"/>
		<!-- must supply password in globalopts when the perforce server uses sessions -->
		<property name="p4.globalopts" value="-P ${p4.password}"/>
		<property name="p4.path" value="{p4.path}"/>

		<echo>p4.path is ${p4.path}</echo>

		<!-- sync buildnumber.properties and version.properties for edit -->
		<p4sync view="${p4.path}/source/buildnumber.properties"
			force="true"
			globalopts="${p4.globalopts}"/>
		<p4sync view="${p4.path}/source/version.properties"
			force="true"
			globalopts="${p4.globalopts}"/>

		<!-- increment buildnumber.properties -->
		<chmod file="buildnumber.properties" perm="ugo+w"/>
		<attrib file="buildnumber.properties" readonly="false"/>
		<buildnumber file="buildnumber.properties"/>
		<tstamp/>
		<!-- Updates the version.properties file -->
	    <property prefix="label" file="version.properties"/>
	    <property name="new.version.major" value="${label.version.major}"/>
	    <property name="new.version.minor" value="${label.version.minor}"/>
		<property name="new.version.iteration" value="${label.version.iteration}"/>
	    <property name="new.version.build" value="${build.number}"/>
	 	<property name="new.version.drop" value="${label.version.drop}"/>
		<!-- update version.properties -->
		<chmod file="version.properties" perm="ugo+w"/>
		<attrib file="version.properties" readonly="false"/>

	    <propertyfile file="version.properties">
	        <entry key="version.major" value="${new.version.major}"/>
	        <entry key="version.minor" value="${new.version.minor}"/>
	    	<entry key="version.iteration" value="${new.version.iteration}"/>
	    	<entry key="version.drop" value="${new.version.drop}"/>
	        <entry key="version.build" value="${new.version.build}"/>
	        <entry key="version.date" value="${DSTAMP}${TSTAMP}"/>
	    </propertyfile>

		<echo>Creating Label: ${new.version.major}.${new.version.minor}.
${new.version.iteration}.${new.version.build}"</echo>
		<p4change description="Increment build number via automatic build"
			globalopts="${p4.globalopts}"/>

		<!-- open buildnumber.properties and version.properties for edit
                (even though we already incremented it)-->
				<p4edit view="${p4.path}/source/buildnumber.properties"
						change="${p4.change}"
						globalopts="${p4.globalopts}"/>
				<p4edit view="${p4.path}/source/version.properties"
						change="${p4.change}"
						globalopts="${p4.globalopts}"/>

		<!-- submit properties files to source control after incrementing build -->
		<p4submit change="${p4.change}"
			globalopts="${p4.globalopts}"/>

		<!-- label the project -->
		<p4label
			name="FX${new.version.major}.${new.version.minor}.
      ${new.version.iteration}.${new.version.build}"
			desc="label created during automatic project build"
			view="${p4.path}/..."
			globalopts="${p4.globalopts}"/>
	</target>
Categories: Uncategorized Tags: