jberkel / android-plugin

An sbt plugin for Android development in Scala
https://groups.google.com/forum/#!forum/scala-on-android
Other
476 stars 113 forks source link

I've added a mixin for generating AndroidManifest version attributes #34

Closed geeksville closed 13 years ago

geeksville commented 13 years ago

Hi,

I've been using your excellent sbt plugin but I got tired of having to remember to bump up versions for my market releases. My solution to this was to make a mixin that automatically populates the versionCode and versionName attributes in AndroidManifest.xml. To use this, add the AndroidManifestgenerator mixin to your project - it will read from src/main/AndroidManifest.xml and generate src_managed/main/AndroidManifest.xml.

The versions used come from the sbt version property. To bump up the version use 'increment-version'.

What do you think of this idea? Can you review this diff somewhat carefully? I've never had cause to futz with sbt innards before so I might be doing something dumb.

Kevin

n8han commented 13 years ago

Looks great! I've also found it to be a an annoyance to increment the version number manually.

The only question I have is if the condition for triggering this file task is broad enough:

fileTask(androidManifestPath from androidManifestTemplatePath)

If the modification of other inputs results in changes to the output, it can be difficult for users to know when and how to force reapplication of the template. I don't know if that's an issue here, but it is for me usually when i write one of these tasks.

geeksville commented 13 years ago

Hi n8han,

Good point about the 'from' rule for generation from the template. I've updated the 'clean' rule so that it blows away any generated manfests, and 'increment-version' was already doing something similar. This seems to get almost all the way there.

The only thing I think that is missed by this approach is if someone hand edits build.properties (or it gets updated due to a source control pull). Do you know if there is any way in sbt to make something dependent on property file updates?

Alternatively, I could just make it generate the manfest file every time - it is a very cheap operation and the downstream apkbuilder doesn't seem to use dependencies anyways. Is there a way to have a fileTask that generates a file every time ?

n8han commented 13 years ago

Do you know if there is any way in sbt to make something dependent on property file updates?

You can build the file task from an Iterable of Path objects, so that should just be a matter of getting the path to build.properties and then passing both paths to from.

geeksville commented 13 years ago

Doh! Good point. I'll add something like that.

On Tue, May 3, 2011 at 3:53 AM, n8han reply@reply.github.com wrote:

Do you know if there is any way in sbt to make something dependent on property file updates?

You can build the file task from an Iterable of Path objects, so that should just be a matter of getting the path to build.properties and then passing both paths to from.

Reply to this email directly or view it on GitHub: https://github.com/jberkel/android-plugin/pull/34#issuecomment-1093049

n8han commented 13 years ago

I added evnBackingPath which to the task. For the adbTask method, it seems like a by-name parameter for action would have the same effect, so I changed it to that. (This is now in BaseAndroidProject.) Could you confirm that it still fixes the problem you observed?

geeksville commented 13 years ago

I'll pull it now and let you know.

geeksville commented 13 years ago

works fine.