Maven2 And Mobile Java

Ok, it’s been a while but I finally posted the code for GMaven-Blackberry in another blog post.

Leave it to me and I’ll figure out how to run the dishwasher from the Maven2 build system. Today I did it! I got a working J2ME build using only Maven! It’s still really early and premature and I’m definitely going to either need to change some plugins, write a plugin, or nest some oogly logic for Blackberry. Still you can’t beat the feeling of having true Maven/ME integration. Right now I struggle daily with an Ant build.xml wrapped with a Maven2 chocolate covering. It’s yuky, it’s messy, it’s dumb! Of course there’s a story here isn’t there? Anytime I talk tech I always have some long winded over dramatized story of what I went through to figure out the latest thing. See below:

Once upon a time there was a young villager named Cliff who sought out the mysteries of the amulet of Maven2. Young Cliffy frequently sought assistance from the Elders, keepers of the amulet of M2. Over the months our young hero practiced his art of project organization, separation of concerns, and deployment both local and remote until one morning he felt confident enough to take on the greatest challenge of all, J2ME! J2ME is not your momma’s Java. (My momma always put two lumps of sugar in her Java and three lumps on my backside when I tried to sneak a cup of Java. This Java comes sans sugar, sans lumps, minus the buttock sting.) J2ME comes with a unique set of bootclasspath jar files, a mandatory preverification step, optional but necessary obfuscation, manifest signing tools, and unique tool chains for certain platforms (eg. Blackberry RIM compilers). These additional tools and steps are not included in typical Java, thus no provisions are made with modern Java build systems. What does this mean for our young adventurer? Write your own or die trying!

Our hero began the morning blocked on a performance test. He diverted and traveled into an early traveled land of Pyx4ME. He’d been down this road before, gung-ho trying to get a Maven build that not only understood JME but could run directly on the Macbook Pro. The earlier venture ended in destruction and turmoil as he struggle with the bash terminal trying to wrapper the deadly JME preverify command. Today, lo, this morning our adventurer had a much different experience. He began his tussle with Pyx4ME running under parallels. with a stroke of the Maven wand and a copy paste from the online tutorial a Maven build was off and running. Errors returned sending our journeyman off to the mailing lists and help forums. Little did he know the (J)VM running on top of his VM (Parallels) was not the correct VM! It was the middle of hos about-to-be post for help when he awakened and decided to double check the error messages and all paths. After executing the jar command echoed in an error output log the “no file or program found” messages all made sense. You see our superstar thought they referred to the generated jar file which he could physincaly see sitting on his hard drive. Instead the mesages referred to the absence of the jar command used to update the file with pre-verified binaries! Configuring a JDK instead of the JRE he was using before allowed the build to complete. Our escapade ends with our main character raising his staff to the heavens and calling lightning down from the powers of Maven2 while the staff is transformed into a broad sword and his laptop super charged into a wild-cat upon which he rides off into the sunset.

Ok, yet another dumb bunch of rambling to say the following:
If you get a “no file or program found” error when running a Pxy4ME build then you probably are running under a JRE instead of a JDK.

For the technically inept that sometimes frequent my site, “what’s the difference between a JRE and a JDK?”
A JRE runs your Java program while a JDK builds your Java program. Maven is a build system and needs Java build tools to do it’s building.

2 thoughts on “Maven2 And Mobile Java

  1. congrats.

    I’m thinking of using maven as well…I presently use it for my web applications. But the Sun WTK emulator/build tool does a pretty good job of organizing/compiling/obfuscating/running the code.

    What was your motivation to get your J2ME builds on Maven?

  2. Well I’ll tell you. There are a whole bunch of reasons primarily tied to production build. In experience I found that you can’t/shouldn’t use IDE wizards unless your project is simple and your dev team consists of 1. Why? Well, what do you do when you publish your product? With a team greater than one and a product slightly more sophisticated than client only logic you’d face some integration issues. (I’m using Eclipse 3.3 and he’s on Eclipse 3.2 I run Ant-1.6.5 and he uses Ant-1.7.0). If there’s a server component then you’d also have additional deployment concerns. The wizards fall apart here. Plus add in a CI server to help with developer change integration of course and now you have the need for a build system. Maven brings uniformity to the entire development process which eliminates that bugs that come from point release differences in a component or tool involved in the build or used by the application. We took the approach of wrapping Maven around an Ant build and while it works it has it’s issues. While most would shake the finger at Maven, a seasoned developer would immediately see the root cause as a build tool integration issue. (The re-invented build life cycle doesn’t match the Maven build life cycle.)

    The short answer is because we’re an agile shop we need all of the Agile features available from the Maven build system which are currently mis-understood or mis-implemented in the Ant component of our client build.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s