We continued our work on getting Groovy working on Android over the past two weeks.
Erik has made quite a good progress with the tests suite for Discobot. What he has achieived by now now is a slightly modified original Groovy test suite running against the compiled but not packaged (jared) code of our patched version of Groovy on his laptop. And of course it’s all green! As we removed some unnecessary classes and had to patch other, because the Dalvik VM doesn’t provide all the classes that regular Java does, Erik also had to remove and change some of the tests but we are trying our best to keep the needed patching to a minimum. It all looks promising and the next step for Erik is to run the tests against a jar and then create an Android app that will run all the tests on the emulator/device. We need that to learn if the differences between Dalvik and regular Java will break any tests and we can do that only by running the tests on a real Dalvik VM. This will give us some confidence that when people start using Discobot for something more complex than a ‘Hello World’ app things won’t start to break big time.
One of the concerns when Hjalmar Ekengren started his first efforts to run Groovy on Android as his GSoC project was the performance. I recall him telling me that it took up to 20s to start even a really simple app back in 2009 in the emulator. Apparently the things have improved quite a lot and our simple ‘Hello world’ example loads in the emulator in less than 5 seconds. It’s still quite long in my opinion. But last week when I uploaded our test application to my HTC Desire running Android 2.2 I was really surprised how quick it loaded the app – I think it’s less than a second! So we don’t have to worry about the performance, at least at this stage of the project.
For the past two weeks I worked hard on modifying the Android Gradle plugin and creating the Discobot Gradle plugin. Thanks to the extensive documentation that the Gradle project has and a terrific example in the original Android Gradle plugin it wasn’t hard to understand Gradle concepts. And when you get the main principles of Gradle it’s a real pleasure to work on a Gradle plugin.
I’m basically done with all the changes that had to be made to the Android Gradle plugin so that the Discobot Gradle plugin could extend it and use it for its own needs. The last thing I need to work on is the documentation – the changes I’ve made are breaking for the Android Gradle plugin and I think that if I update the docs the developers of that plugin will be happier to accept my pull request. I tried to contact the github repository owner of the Android Gradle plugin (Jason Voegele) before I started the work on it to learn what is his view on the changes I planned to make but unfortunatelly I didn’t get a response to my email. Hopefully when I create the pull request someone will get it processed…
Also the Discobot Gradle plugin is almost ready. Currently it builds the Android projects that use Groovy without a problem. I still want to add one task to it that will create the project structure and default files (AndroidManifest.xml and the main activity class among others) so that it will be easier to start the project from complete scratch with only a build.gradle file in your project. The task, updating Gradle Android plugin’s documentation and creating a pull request on my changes are my goals for the next week.