Markus Heberling Coding == Relaxing

31Aug/081

Using Maven2 to build Cydia Packages for the iPhone

I am using Maven2 for most Java projects. So I wanted to use it for Phone-Java development, too. This is a little tutorial on how it can be done.

iPhone Cydia Packages are Debian .deb files really and luckily there is the mvn-pkg-plugin that supports creating .deb files with Maven2. Unfortunatly the current version has a bug, so that it won't work out of the box for creating iPhone packages. So you have to grab the latest svn-snapshot and apply the following patch.

 


 

After applying the atch and doing a "mvn install", we can start with the real work. Download the tutorial files from here. I will explain the contents of the archive later. For now unzip it and do a "mvn package" in its directory. It will compain about some missing dependencies, so grab the missing jars from your iPhone and install them in your Maven reposiory as directed in the error message. After you have done that another "mvn package" shoud produce a .deb file in the target subdirectory. You can upload this to your iphone and install it with dpkg. After a restart of the SpringBoard a new icon HelloMaven should be on your screen, that should start the demo program.

Now some explanation of how it works. The main part is done in the pom.xml. Here is the relavant excerpt form this file:


The first important part is the defaultDistro tag. Here we tell the plugin, that we want to build a package for the iPhone. Unfortunatly there are no default iPhone mappings contained in the plugin. That is why we have the auxPackageMapURL tag, that tells the plugin where to look for the Maven-to-Cydia-Package-Mapping. Most other things should be pretty self explaining.

The files in the dataFiles Section have to reside in src/main/auxfiles icon.png and Info.plist should be pretty clear. The Starter entry needs some explanation though. The plugin automatically generates a start script in /usr/bin. This is good enough for console applications, but if you want to start a GUI-App some more work is needed. The Starter script sets the Java executable path to /Applications/Appname.app/Java and calls the generated script after that. For this to work the starter Script has to get executable permissions and jamvm has to be linked to /Applications/Appname.app/Java. This is done in the postInst.sh script. For more info about those scripts and what you can do there refer to the Debian documentation.

This should be enough to get you started, if cou have questions, please feel free to post them in the comments.

Comments (1) Trackbacks (0)
  1. Great, should be in a wiki for iPhone Java devs…


Leave a comment

No trackbacks yet.