How to keep Free/Paid version of the app separate in subversion

androidsvnversion control

I have a paid application on the android marketplace, however, I want to release a free ad-supported version.

The easiest way I thought to do this was to set up a branch on my subversion repository that has the additional code to add the ads. However, when I went to submit this to the android marketplace, they require unique package names. This solution no longer works for me because I'd have to change the package of every class file, which would make merging the trunk and branch very painful.

What is the best way I can keep these two projects together, sharing patches, but with a different package?

Best Answer

Have you considered compiler directives?

Example:

#define FREE
// ...
#if FREE
Console.WriteLine("Free version");
#else
Console.WriteLine("Paid version");
#endif

You can keep the exact same code base and target the two builds using two separate build scripts or a parametrable one.

msbuild /p:DefineConstants=FREE

To do it with Java, read this and this. And maybe this.

Related Topic