SVN revision in version name?

395 views
Skip to first unread message

Jeremy Wadsack

unread,
Sep 28, 2010, 5:17:37 PM9/28/10
to npr-a...@googlegroups.com
One thing that would help with this kind of stuff is knowing what version of the code a bug-reporter is using. While the product version is requested in the template, that doesn't help us developers align with the svn revision code. In our projects, for many years, we have embed the source control revision into the version somewhere so that we can align the released code with the source control revisions. 

This is pretty easy to do on Android with a simple Ant task that can be added to the build process. If you are using Eclipse, you can add a build task to the start of the build process that runs the ant script. Attached are three files that can do this that I pulled from one of my other projects.

svn-revision.build.xml - The ant project file that updates AndroidManifest.xml to add or replace the third component of a three-component version name with the svn revision of the source being built. e.g. versionName="1.2" or versionName="1.2.3" would be changed to versionName="1.2.104" for svn revision 104. This file should be in the root of the project (same folder as AndroidManifest.xml)
AddSvnRevisionToVersion.launch - This is an Eclipse build/launch task that will run the ant project. This goes into a folder .externalToolBuilders (the default folder where Eclipse stores such things for a project).
dot-project.diff - The changes needed to the .project file to make Eclipse run the version update before anything else. The .project file is in the root of the project folder in your workspace.

If you'd like to do this (or something similar; it's easy enough to change the version numbering scheme) I can commit these changes to the trunk and version_1.x branches for future updates. Note that this assumes that your release process uses Eclipse — if not, then let's figure out how to get the ant task into the release process.

--
Jeremy Wadsack


On Mon, Sep 27, 2010 at 7:34 PM, <npr-and...@googlecode.com> wrote:

New issue 41 by GregBerns: App freezes when item on playlist finishes
http://code.google.com/p/npr-android-app/issues/detail?id=41

...

What version of the product are you using? On what operating system?
Running Samsung Epic by Sprint,
Firmware version:2.1-update1,
Kernel: 2.6.29,
build number SPH-d700 eclair.di07

svn-revision.build.xml
AddSvnRevisionToVersion.launch
dot-project.diff

Michael Frederick

unread,
Sep 28, 2010, 5:25:29 PM9/28/10
to npr-a...@googlegroups.com
We (actually, NPR in general, and Jeremy P. in particular) are using Eclipse to do the build, so this should be perfect!

There are a number of other tasks I would like to be involved in the official release process (e.g., checking to ensure that the correct jars are included, version number is incremented, etc.). Jeremy W., do you know if there are hooks in Eclipse to Export Android Application?

Jeremy Wadsack

unread,
Sep 28, 2010, 5:52:22 PM9/28/10
to npr-a...@googlegroups.com
I don't know how (or if it's possible) to hook into the Export Android Application wizard. I suppose a little digging could discern that but I haven't looked into it myself. When Eclipse builds the application for export, it runs your custom build tasks so this gets updated before packaging.

I suspect that the best way to insert tasks into the build process in by using an Ant build process. I tend to prefer this anyway because it's "one-click" release and reducing friction for the release process makes it easier to get updates out and puts less fear in the team about doing releases.

--
Jeremy Wadsack

Jeremy Pennycook

unread,
Sep 28, 2010, 9:10:36 PM9/28/10
to npr-a...@googlegroups.com
Anything to take more technical work out of my hands would be most appreciated!  Not only does it lead to more errors doing this kind of stuff by hand, by me at least, it also represents a knowledge problem where I'm the only one who knows how to do a release, etc.

Let me know what you come up with and I'm happy to change my workflow accordingly.

Jeremy Wadsack

unread,
Sep 28, 2010, 9:30:20 PM9/28/10
to Jeremy Pennycook, npr-a...@googlegroups.com

Jeremy - 

Do you have a list of what the revision number was (or the date) for released versions of the app?

If you're ok with the 1.2.3 number scheme I'll adjust this for the project and commit to both branches.

Note that the 1.2 part is set by hand in the AndroidManifest.xml file and can't really be automated because that's sort of a business decision (is this a major or minor release?).

Michael - what else do you want oversight or involvement in with the release process. Knowing that I can automate the rest.

Jeremy Wadsack

Jeremy Wadsack

unread,
Oct 6, 2010, 5:45:31 PM10/6/10
to Chris Moschini, npr-a...@googlegroups.com
Chris - 

I'm pushing this back to the mailing list so that anyone else can comment if they have problems as well.

This should work without any additional dependencies — that was the goal. I tested this on a clean build, clean system and it worked for me, so we need to figure out what's different about my Mac-based Eclipse and your system.

The .project loads an external configuration task into Eclipse (/Npr/.externalToolBuilders/org.npr.android.AddSvnRevisionToVersion.launch ). This is an ant build file. I assumed that the Ant Builder was a default plug-in for Eclipse or was required by Android, but may not be in your version. However, it looks like it's built into Eclipse (at least documented) since version 3.3. Can you look at Run > External Tools > External Tool Configuration and see if 'Ant Build' is one of the options?

--
Jeremy Wadsack


On Wed, Oct 6, 2010 at 12:46 PM, Chris Moschini <soop...@gmail.com> wrote:
This is preventing me from building - I get an error stating ant
couldn't find something it needed to perform the build.

Errors running builder 'Integrated External Tool Builder' on project
'Npr'.
Launch configuration type id
"org.eclipse.ant.AntBuilderLaunchConfigurationType" does not exist.
Possible causes:
       Missing specification of a launch type (missing plug-in)
       Incorrect launch configuration XML

If I comment out the portion of the .project file referencing this svn
build number task, the above error goes away. I'm guessing there are
thing(s) I need to install in order to build properly? I've installed
Subversive and a Connector - something more I need installed?

Chris Moschini

unread,
Oct 6, 2010, 5:56:35 PM10/6/10
to npr-android
Thanks Jeremy. Yes, it appears this is a common issue in projects that
have nothing to do with Android or NPR - googling the error message
got me a wide swath of seemingly unrelated Java projects.

My External Tools Configurations window is actually pretty funny -
it's just blank. On the left there's one type heading - Program - with
no configurations created underneath it. Looks like I don't have that
Ant tool.

I'm going to venture a quick guess that my version of Eclipse I
installed is odd though - I installed it for editing Web and JS and
projects a few months ago, so it's possible that build doesn't come
with this, or other things the default Java version comes with.

With that in mind, perhaps this is the pattern in the projects found
in a search with this issue - they tend to be Web projects, so people
installing this Web oriented version of Eclipse are left in the lurch.
Not having ant is very strange as even Javascript has builds to deal
with nowadays.

I'm going to just dump this install of Eclipse and pick up a default
build, see if that fixes it.

Jeremy Wadsack

unread,
Oct 6, 2010, 6:02:31 PM10/6/10
to npr-a...@googlegroups.com
I would probably start from scratch as well, but if you don't want to do that you could try Help > Check for Updates and see if the Ant Build Task is something you can add. I suspect, though, that if you don't have that there are other Android dependencies missing too.

--
Jeremy Wadsack

Chris Moschini

unread,
Oct 6, 2010, 7:24:11 PM10/6/10
to npr-android
That fixed it.

If anyone else run into this issue, FYI - all I did was just download
the "Eclipse Classic" and dump all the files right into my existing
Eclipse install, instead of uninstalling.

Jeremy

unread,
Oct 12, 2010, 10:57:49 AM10/12/10
to npr-android
Jeremy W - why don't you IM me later and we can chat about the
revision number issue. I need some more clarity on exactly what this
change means. I'll be free in the afternoon EST.
Reply all
Reply to author
Forward
0 new messages