Tracking build information in distributed binaries

M

Matthew

I was wondering what methods people used to track build versions of
software once it's been distributed to the world. I'm basically
thinking about what happens when someone emails me with a bug, and I
want to know which specific version of my software they are using.

I tossed together a perl script that I was thinking of just putting
into my ant scripts, but before I put more time into this script, I
was wondering if there was a saner/more standard way to do this native
to ant or some other java based tool. If there isn't any better way
to do this, does anyone have any suggestions of other things to
include in the version string?

Here is the script I wrote, it creates a small java class that I was
thinking about having my code call to get the version string when the
user did a `java -jar foo.jar --version` or something of that manner.

#!/usr/bin/perl

my %svn_info;

open(my $fh_svn, "svn info|") or die "unable to open svn";

while (<$fh_svn>){
/(.+):\s+(.+)/;
$svn_info{$1} = $2;
}

close ($fh_svn);
my $date = localtime();

print <<EOS;
public class VersionInfo {
private String svnVer = "$svn_info{Revision}";
private String buildDate = "$date";

public String getSvnVer(){
return svnVer;
}

public String getBuildDate(){
return buildDate;
}

public String getVersionLine(){
return "SVN_Ver:" + svnVer + "|
Build_Date:" + buildDate;
}
}

EOS

#####################################################################################
it outputs java code similar to:
public class VersionInfo {
private String svnVer = "807";
private String buildDate = "Fri Oct 10 11:02:41 2008";

public String getSvnVer(){
return svnVer;
}

public String getBuildDate(){
return buildDate;
}

public String getVersionLine(){
return "SVN_Ver:" + svnVer + "|
Build_Date:" + buildDate;
}
}
 
A

Arne Vajhøj

Matthew said:
I was wondering what methods people used to track build versions of
software once it's been distributed to the world. I'm basically
thinking about what happens when someone emails me with a bug, and I
want to know which specific version of my software they are using.

I tossed together a perl script that I was thinking of just putting
into my ant scripts, but before I put more time into this script, I
was wondering if there was a saner/more standard way to do this native
to ant or some other java based tool. If there isn't any better way
to do this, does anyone have any suggestions of other things to
include in the version string?

There are a lot doing something similar to what you do.

But the official Java way would be to put the version in
the manifest of the jar file !

Arne
 
J

John B. Matthews

Matthew said:
I was wondering what methods people used to track build versions of
software once it's been distributed to the world. I'm basically
thinking about what happens when someone emails me with a bug, and I
want to know which specific version of my software they are using.

I tossed together a perl script that I was thinking of just putting
into my ant scripts, but before I put more time into this script, I
was wondering if there was a saner/more standard way to do this native
to ant or some other java based tool. If there isn't any better way
to do this, does anyone have any suggestions of other things to
include in the version string?
[...]

Alternatively, here's a way to get a version string from a file using
ant:

<http://mindprod.com/jgloss/ant.html#EXTRACTING>

You can also parse the output of `svn info`:

<http://www.nearinfinity.com/blogs/page/mwizeman?entry=svn_revision_numbe
rs_in_ant>

The author also suggests the Tigris <svn> task, using status command's
revisionProperty:

<http://subclipse.tigris.org/svnant.html>
 
J

John B. Matthews

Arne Vajhøj said:
There are a lot doing something similar to what you do.

But the official Java way would be to put the version in
the manifest of the jar file !

Good point. One may already be using the nested element <manifest> to
specify the Main-Class, so adding another atribute is easy:

<http://ant.apache.org/manual/CoreTasks/manifest.html>

And a filtered copy can be used to propagate version information. In
this fragment, Info.plist needs the current version in several places,
but only if the ant script itself is newer.

<touch file="build.xml">
<mapper type="glob" from="build.xml" to="Info.plist" />
</touch>
<filter token="version" value="${version}"/>
<copy todir="${proj}.app/Contents" filtering="true">
<fileset dir="${basedir}" includes="Info.plist"/>
</copy>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top