GMaven for Blackberry development on a Mac?


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

I’ve gone clear outta my mind. I’m thinking let’s build a blackberry native app on the Mac. Sure! Why not? I mean there’s only the long-standing platform incompatibilities between J2ME and OS X, the windows-oriented nature of Blackberry tools, the mismatch of typical J2ME project structure and Maven project structure and looming deadlines to worry about. And while I’m at it, throw Groovy into the mix, because everybody knows that Groovy has everything to do with writing embedded apps right?

This week I’ve bounced between a Gant build, a legacy Ant build, our multi-module maven JEE project, and brand new GMaven plugin projects. Let’s just say I’m becoming very familiar with the build process in general. Project structure is important. The build system is critical. It is at the root of every successful and failed project in history. Many problems, and resolutions to problems stem from the build/deployment system in place on a given project. It makes sense that as a developer you pay close attention to what’s involved in the building and deployment of your software. Yet soooo many people fail to understand the variables involved in the build tool chain. Many a problem can be tracked to system incompatibilities resulting from version mis-match and/or conflicts. Something as simple as a micro point release difference in your web container or JDK can cause an app to behave wildly different. (Today I tracked a bug down to Tomcat 5.0.28 on a dev box where version 5.5.25 is running in production.) The version numbers of your build tool chain is often the last place developers look when researching a problem. It is the first thing I look for when trying to isolate an issue. I digress.

With all the build tools ranging from Ant to GAnt to Maven to Gradle… (BuildR anybody?) it’s easy to get overwhelmed. I had a buddy remind me how important it is to refrain from going overboard in leading edge-multi-faceted-combined technologies. Stick with proven products yet always look for the next thing. That’s how I feel about Maven. There are alternatives some have better features. However Maven is mature and ubiquitous. I don’t have to pull in yet another runtime to build my project. I don’t need to learn yet another platform. It does its job and does it well. So well that I try to use it for all of my Java work, bringing me to my point. J2ME Blackberry development can be done with Maven. It can be done on a Mac. And at the end of my ordeal it should be painless to do on a Mac.

So why Maven? Why not Ant? The app I’m working on includes several JEE complimentary pieces and I’m sorry but I would rather not touch Ant on a web app project. No way, no how. Furthermore with JEE making up over half of the codebase Maven is the perfect solution for managing the project. We currently have it in use and we have a wrappering pom around the Ant build we use for our J2ME client. That wrapper has been a source of utter pain. So I’ve been looking to figure this out for the longest.

What does Groovy have to do with it? Well I have the Pyx4ME J2ME plugin for Maven working pretty well but there are some obvious holes. First off is a decent deployment mechanism. I need to tie deployment into the modified Antenna OTA servlet we have. Secondly there is no support for Blackberry in the plugin so somebody needs to add it. I started to write a plugin and I just knew I wouldn’t want to be bothered writing it in Java. A couple of minutes after I finished bouncing between 20 different reference articles, APIs, and PDFs and I had the beginnings of the RIM plugin for Maven complete with OS X compatibility. It’s not totally finished yet. I still have issues running the jar signing tool on the Mac. (It should run fine on Windows, and possibly Linux.) But it runs the compiler. I’ve generated a .cod file in the target folder of a prototype project. Interesting stuff indeed.

If that’s not enough, I’ve also managed to launch GAnt from within Maven! Why would anybody want to do this? Maven is become widespread like Ant. If you or your team already use Maven but you want to toy with Something else like Gant you would have immediate access. You don’t need to open your browser, don’t launch Safari, just run Gant:

mvn gant:run

That’s it! And that’s perfect for my current situation where I’m trying to spread Gant across my team. The same applies for Groovy. Don’t go to the codehaus site, just run it!

mvn groovy:console

There’s something to be said about the convenience of a one stop shop. That’s my thing for now. Stop back because I’m gonna continue to post updates on not only Groovy, but Blackberry, GAnt, Maven, maybe even Gradle if I get that far. Holla!

I got it!


I just ran the Blackberry compiler from Maven… on my Mac. Two cans of Pabst Ice and one Mike’s hard cranberry lemonade into my dev cycle and I finally see a “.cod” file show from a pyx4Me project! It’s in the wrong folder, project root vs. projectroot/target but I can live with that for now. Anyone know a groovy way to set the working directory from a command string run by the overloaded String.execute() method? I don’t wanna call out to Runtime.exec and I don’t wanna write a bunch of platform checks in my plugin. Right now I’m one too many drinks swallowed to know whether or not String.execute() implies platform. In other words I don’t know if I need to code a prefixing “cmd /c ” on my string and check for Windows before calling String.execute(). I’m not happy with the impl because there were a few things I wanted to do better. Right now I’m spawning a java process because the GMaven plugin doesn’t set the rootLoader, which means I can’t dynamically append to my classpath. I’ll either have to set the rapc.jar as a dependency or figure something else out. I’m just glad I got this far! More updates later…

Pyx4ME Hack


It’s late tonight but I gotta get this posted. I’m still trying to get a good dev cycle with the Maven Pyx4ME maven plug in and IntelliJ Idea. I’m running on Parallels on my Mac. Here’s an extra tag I added to the project generated from the pyx4ME archetype:

<plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
              <id>run</id>
            <phase>install</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <tasks>
                  <property environment="env"/>
                  <echo message="Running WTK out of ${env.WTK_HOME}"/>
                  <taskdef resource="antenna.properties"/>
                  <wtkrun jadfile="target/${project.artifactId}-${project.version}-me.jad"/>
              </tasks>
            </configuration>
          </execution>
          <execution>
              <id>site</id>
            <phase>site</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <tasks>
                <copy overwrite="true" file="${project.build.directory}/${project.build.finalName}-me.jar" tofile="${project.build.directory}/site/mymidlet.jar" />
                <copy overwrite="true" file="${project.build.directory}/${project.build.finalName}-me.jad" tofile="${project.build.directory}/site/mymidlet.jad" />
                <replace value="mymidlet.jar" token="${project.build.finalName}-me.jar" dir="${project.build.directory}/site">
                  <include name="mymidlet.jad"></include>
                </replace>
              </tasks>
            </configuration>
          </execution>
        </executions>
          <dependencies>
              <dependency>
                  <groupId>net.sf.antenna</groupId>
                  <artifactId>antenna</artifactId>
                  <version>0.9.14</version>
              </dependency>
          </dependencies>
      </plugin>

This lets me run my project using WTK assuming WTK_HOME is been set as a system env var. More stuff later.

Candy


Where did these projects creep out from? I’ve been doing some mulling about Maven2 because I’m gearing up forsome servlet development on the job and somehow I ended up on the q4e site which pointed me to Candy. Candy appears to be an Eclipse developer front end to AppFuse which itself is a nice project. I’m not gonna speak much, but I am keeping my eye on these projects.

I Need –help!


I’ve bragged that Maven2 is the best technology to emerge since Compact Discs replaced cassette tapes but in all honesty it suffers from a little thing I like to call… umm… block-head user-interface design! I hope none of the M2 developers frequent my site and take offense, believe me I am deeply thrilled with your product if you are reading but check it out. I should not have to waste hours googling the net, posting stoopid forum help requests, or getting side tracked on unrelated but interesting links from your wiki to figure out what the how to set the compiler to JDK5 level during a build. The plain fact is that Maven2’s interface is just a little, how should I put it? …A little less than user friendly. To start it’s a command line. OK, I’m blugened with command line work every minute being a Linux user so that doesn’t hurt me as much. (I can’t say the same for poor Windows users.) But then the command line is hard to use. You got plugins for everything, a separate syntax for plugin options versus the syntax for core maven options, the hard to manage requirement of qualifying a plugin by using a package name/groupid so now I have to “-DarchetypeName=myCustomArchetype -DarchetypeGroupId=com.pkg.something -DarchetypeVersion=1.0 -DarchetypeNextOfKin=cousinMarchetypePlugin -DarchetypeNextOfKinName=… -DarchetypeNextOfKinGroupId=… -DarchetypeNextOfKinBloodType=…”

Here’s the story, true story. I began this morning on a quest to understand Maven deeper since we’re using it a lot more at my job and all. I thought it’d be a good idea if I learned exactly how to manage the versioning and intermitten releases of a given project. I picked up the latest copy of “Better Builds With Maven” because frankly I’m interested in having a better build of our project. I started reading and following allong the example daytrader EJB application. I even downloaded the source and started running the commands. Somewhere in the example there was a mention of running “mvn -N install” in the root directory of the project. I was curious. “-N” was an option that I don’t use and I wanted to know what it meant. I did what would come natural to any Java developer on a linux box. I ran “man mvn”. Realizing there were no man pages for the mvn command I progressed my documentation search to the next level. I ran mvn with no args then when that didn’t work I ran “mvn help”. That activated the help plugin which naturally wanted to look for a project. I was totally confused so I went on the Maven web site and browsed the online documentation. I couldn’t find an explanation to either the “-N” param or any documentation on the mvn command line available options. After furiously Goolging for an answer I stumbled across a page that pointed me to “mvn –help”. I thought, “Oh, now why didn’t I think of that earlier?” I’ll tell you why. Because I thought of “mvn help” first and because that invoked the help plugin I thought that would be the most natural place to put help documentation. To be honest I’ve gotten so used to “cmd help” syntax of Bazaar and svn (I’ve been using both of them a lot more recently) that it never occured to me that some commands expect “–help” as a parameter instead. Infact there are some commands that look for “help” some that look for “-help” and some that expect “–help”. It’s all too confusing. by default mvn should at least indicate the need the use the –help flag when you run it without arguments and it throws an error. I’m just too frustrated and if you feel my pain holler back…

With respect for Kathy


Go Kathy!Kathy Seirra, one of the top three bloggers that I know of has been under attack. The short story is some people thought it would be comical, daring, or cool to slander the woman over the internet for whatever reason. The entire situation is foolish but you can’t easily stop something as powerful as the internet once it turns against you. I only have a small set of readers that frequent my pages, and I’m thankful for each one of you. I’m going to follow Scoble’s lead and refrain from posting or commenting at all during the following week in respect for Kathy. (I do realize that I may loose most of my loyal readers since I’m not as powerful or as cool as Joel or Rory but it’s something that I feel is necessary. It’s all good though because I got John Blaze stuff here, y’all just ain’t reckognizin’!!!) That’ll give me more time to actually work on GSpec as well as some other things. You can continue to post comments, hollaback, and drop it like it’s hot (unless of course it is really not all that hot and rather easy and comfortable to hold onto), I’ll respond to everyone and everything in a week. Support Kathy!If ya’ got a blog and ya’ wit’ me then take a moment of silence in support. If you don’t have a blog but yer’ still with me then join in the moment of silence by meditating on my man Cuba Gooding. (Show your further support for Kathy and Cuba by checking out one of his DLLs.) In parting I’d like to remind everyone that reads me, be careful of what you post on the net because once it’s out there, it’s impossible to take it back.

Idea Selena Bug with Maven2 generated iml’s


Idea Selena can’t read Maven2 generated iml files! I’ve been stumbling over the problem for a while and if it hit you recently I’m gonna help you out. The trick is to generate the file with Selena and overwrite it with Maven2. I’ll be specific.

What I used to do:

  • Run “mvn archetype:create -DgroupId=blah -DartifactId=wha …” and generate a Java or web project in the current directory.
  • Run “mvn idea:module” to generate the module descriptor for Idea
  • “Import existing module” in Idea, find the generated iml file using that spiffy file dialog.
  • Let stand for 10-30 seconds, enjoy

What I started doing:

  • Run “createMyJavaProj com.cliff.myproj myproj” (a linux script I wrote the combines the above two steps and removes the ugly system property setting syntax.)
  • “Import existing module” in Idea, find the generated iml file using that spiffy file dialog.
  • Let stand for 10-30 seconds, enjoy

What I now do:

  • Run “mvn archetype:create -DgroupId=blah -DartifactId=wha …” and generate a Java or web project in the current directory.
  • “Create new module” in Idea, find the generated project folder using that same spiffy file dialog.
  • Let stand for 10-30 seconds
  • Run “mvn idea:module” (via an Idea external tool setting mapped to my F10 key so really I just hit F10) to rewrite the module descriptor for Idea
  • Let stand for 30 seconds, enjoy

Better M2 support in Selena would be a big plus here but for now that’s what it takes. If you hit a similar issue and want to vent about it fill in the box below. Your name and contact info will be kept confidential, entrusted to the webservers and kind folks at WordPress. (Although that Matt character looks a little shady, I dunno.)

Groovy, Maven, Idea and more


I’ve been fighting to make some progress on my GSpec project and I’m at a standstill. The big problem is that I migrated all of my work off of my windows partition onto my Mepis install. On top of that I’ve upgraded to the latest Idea Selena (7.0 EAPO build) and GroovyJ is no longer on the install list. I think I’m just making my life much harder than it has to be but I refuse to give up and use older or lesser capable tools. For example, right after writing the last two sentences I realized that my current efforts to checkout the latest build of GroovyJ with subversion, build, realize the project has no JDK set, set the JDK, realize that half of the dependencies are missing, add the only dependency I have time to add, remake, realize that I never downloaded the plugin developer toolkit, cuss, download the plugin developer toolkit, yeah all of those efforts, would all be simpler if I just copied the groovyJ install from my earlier Idea install sitting on my Windows partition. How about that for wasted effort? Well I have the source to it now and I think the plugin toolkit just finished downloading so maybe one day I’ll look at the source and see if I can help development along. (Like I’ll have any time for that!)

With GroovyJ now pleasantly installed I have also managed to get a working copy of the latest groovy-maven plugin from the Codehaus subversion repo using most of the same long winded steps above. My pom now builds, and sees all of my production and test resources. (Yaay!) I just ran both the M2 test goal and the individual failing test under Idea and everything is working. (Everything except for the failing test! But that’s cool because that’s where I left off anywayz.) As an aside I noticed that my JUnitGSpecSuiteBuilderTest wouldn’t get picked up when I right clicked the tests folder in Idea and selected “Run all tests”. I also noticed that running it directly doesn’t work. I get an error:

Caught: groovy.lang.GroovyRuntimeException: This script or class could not be run. 
It should either: 
- have a main method, 
- be a class extending GroovyTestCase, 
- or implement the Runnable interface.

My class is a .groovy file that extends and is written Java classic style but has no test methods, only a static suite() method. I believe it’s an issue with Groovy and not Idea or the plugin. Anyway, life is good and I finally get to make progress as soon as I stop blabbing on my blog about all the work I should be doing. I apologize to those of my reads who have been loyal because my last flurry of articles has been anything but informative or funny. I assure you all that as soon as I get over some rough edges I’ll bring the edge back to my writing and begin filling my site with useful content once again. For now, I’m out like a scout on a new route without a doubt. Peace…

Groovin’ with Maven


Last night I made several desparate attempts to set my environment up for Groovy development on Mepis-6.0. This was after cooking dinner, feeding my two daughters, scrubbing the floors, cleaning the bathroom, and reading a page or two out of my JSF book. (Why the heck am I reading about JSF? You don’t even want to know!) I knew I would get nowhere but I had to try. It was about 10:30 at the time and I was up until about 11:45 working on it. I decided that to do an svn checkout of the latest from the Groovy Maven plugin stuff. That’s when I noticed that there was something screwy going on at the Codehaus Mojo site. I saw what looked like a new Groovy Maven plugin. It had docs and everything! I was all like, “Jeah! That’s what I’m talkin’ ’bout!” (‘Jeah’ is ‘Yeah’ in west coast Japanese slang, kinda, sorta.)

Well I followed the docs on how to use it, copied the appropriate tags into my aged Maven groovy project pom and also added the codehaus mojo site as an alternate profile in my settings.xml. When I ran the build Maven started bugging. It said stuff like, “say man, I can’t find ya’ groovy-maven junk…” I replied with the usual, “What’chu mean fool? It’s right where I told you about it! On the Codehaus Mojo repo, ya’ doh-doh!” Then Maven hollered back like, “Listen cuz, I told you I can’t find your stuff! Stop asking me to build ya’ stoopid project!” That’s when I knew I had a problem. I looked on the repo myself (copying the URL from the repo I defined in settings.xml into Firefox and leaning on the enter key) then lo and behold! No Mojo! I felt like Austin Powers in his second movie. I looked around a little bit browsing other subfolders and eventually the sandbox. I did find an alpha build of what looked like the Groovy-Maven plugin but I couldn’t tell. My wife had entered the room at the time (she works late nights and had just got home) and needed to use the computer. Realizing how late it was and understanding that I needed to find the strength to come in to work the next day I gave up. If any of you out there no anything about the new Groovy Maven stuff gimme a shout. I’m swamped with all kinds of other stuff and I really have limited time to play with things. Until later, drop it like it’s hot even if you know it’s not…