One of the nicest features of Git is that it’s possible to use it locally against a Subversion server. For many this is a crucial selling point as it allows individual developers to take advantage of Git while not requiring that the entire project switches version control from Subversion. On your local Git repository you’re then free to do as many branches as you like, or otherwise take advantage of the many nice features in Git.
However, if your project is set up to use the Maven automatic build versioning as provided by the buildnumber-maven-plugin you will run into problems if it is set to get the build numbers from the Subversion revision number. Since your local checkout is against Git, and not Subversion, the build will fail since the Subversion commands won’t work.
One solution for this could be to alter the plugin configuration to get the build number from the date or something similar, but that’s not always possible. You might have a build server setup that depends on the build number matching the revision number, and imposing such a change might break other functionality or processes.
Instead you can add an additional profile to the Maven POM which will only be triggered in the absence of a .svn directory (i.e. when not using Subversion). In this profile you can override the default configuration for the build number generator to instead use the date for build numbers. This means that your builds will have different build numbers from the integration builds, but at least it will compile on your git checkout.
The profile will look like this:
This profile is here for triggering when another scm than svn is
used (for example git). Instead of getting the version build number
from svn we will use the build date and the user name.
This way Subversion and Git users can live happily together in the same project.