11-30-2011 10:04 PM
Hello BlackBerry Developers,
I have recently created a Maven Plugin for building BlackBerry Java apps. It is open sourced and licensed with the Apache License. Here is the Maven plugin page:
http://dev.goodformobile.com/maven-mobile-plugin/
Look at the usage page before you ask any questions. The latest SNAPSHOT is built here:
http://dev.goodformobile.com/bamboo/browse/MMP-SI
and the plugin itself can be downloaded from the Nexus repo:
http://dev.goodformobile.com/nexus/content/reposit
and the source is in SVN.
If you want to add anything or have questions you can submit a patch or send me a message. So far I have only used it with 4.5 through 7.1 but it should work on older stuff. Nothing is Eclipse specific so it should also work with the JDE. I have only used it for a few libraries and apps in the RIM Eclipse Plugin.
Most importantly: It runs in Windows or Linux. I haven't tested it on a Mac but I don't know of any reason it wouldn't work.
12-01-2011 03:58 AM
12-01-2011 09:11 PM
I made the Hello World a few months back so it likely doesn't work. You may want to look at some of the projects under the src/test/resources/projects directory. This weekend I'll take a pass at getting some better examples out there.
12-01-2011 11:30 PM
I haven't looked at hello-world but I got the advanced fields example building. Checkout svn://goodformobile.com/maven-plugin/tru
<profile>
<id>rim-6.0.0</id>
<properties>
<rim.platform>rim-6.0.0</rim.platform>
<rim.jar.version>6.0.0.30</rim.jar.version>
<jde.directory>C:\\tools\\eclipse\\eclipse-rim-3.0
<preverify.path>C:\tools\j2me\WTK2.5.2\bin\preveri
<signature.path>C:\tools\rim\signatureTool</signat
</properties>
</profile>
And run:
mvn clean install -P rim-6.0.0 -Drim.platform=rim-6.0.0
12-02-2011 04:25 AM
06-05-2012 11:32 AM
Hi,
A big big thanks to Kurtzettel who did an amazing work for maven integration, awesome I couldn't expect better! :-)
I successfully got my project mavenized and start it in Simulator.
Now I'm trying something more advanced:
In My workspace I have:
blackberry-parent
\- [Main application] (Blackberry Application)
\- [Jar#1 library] (Blackberry Library)
-- [Jar#2 library] (Java Jar project)
[Main application] -> depends on [Jar#1 library] -> depends on [Jar#2 library]
[Main application] and [Jar#1] have blackberry-parent as pom parent.
First problem : cross module class invocation
This works fine on simulator.
But once deployed on a device, application won't start. It looks like [Jar#2] is unable to see classes from [Jar#1] or [Main application].
This means that [Jar#2] throws a ClassNotFoundException when invoking Class.forName("SomeClassFromMainApplication").
Second problem : closing projects dependencies
This works fine on simulator, as long as projects [Jar#1] and [Jar#2] are opened in Eclipse workspace.
When I close [Jar#2] (which is then found from my local repository), it's correctly deployed to simulator but application won't start, instead a popup message : "Module [Jar#2].jar not found"
I tried checking "Maven dependencies" in in the build path>Order and Export, with no success.
Third problem : compiling a Blackberry dependency with preprocessor directives
I'm unable to "mvn install" [Jar#1] by itself, getting compilation errors where I have preprocessor directives ("not a statement"). I think that preprocessor from the maven-mobile-plugin is not invoked.
The plugin is declared in the blackberry-parent, but I guess something is missing for mapping the goal "preprocess" to the compile goal?
Many thanks
06-06-2012 11:08 PM
Okay: I reviewed the project and there are a few things going on that were weird:
1. The BlackBerry library project pom.xml was missing the packaging type. This is what causes the plugin to deploy a jar with cod files instead of just a jar. I added: "<packaging>bblib</packaging>" and it built a jar with cod files.
2. The BlackBerry application project pom.xml was missing the packaging type. I added "<packaging>bbapp</packaging>" and then in built a jad and cod.
Once I did the above it still didn't work on the device. jar2 was never specified to be compiled with RAPC so it isn't setup as a dependency. This is something that the Eclipse plugin does automatically. I added a story for this in Jira and I'll eventually add it:
http://dev.goodformobile.com/jira/browse/MMP-26
3. The Java Jar project (titled Jar#2) had a pom which specifies nothing so it uses a lot of defaults. Since the Maven default is Java 5 or 6 this jar won't work with BB. I changed the compiler plugin to a source of 1.3 and a target of 1.1 and it built into something usable.
4. In order to package it all into a single cod file you can do two things that will make it work:
1. Set bundleDependenciesInAppCod to true in the maven-mobile-plugin config. This will tell the plugin to skip including the library cods.
2. Configure the maven-dependency-plugin to move all of the dependent classes into the target directory. This causes the app to have one named cod file. There are pros and cons to this but since RIM doesn't handle dependency cod files that elegantly, I just bundle them all into one.
Here is an example of that plugin config:
<!-- Rather than including each library, just extract them and combine
them with the final cod. -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>unpack-dependencies</id>
<phase>prepare-package</phase>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<excludes>*.cod,META-INF</excludes>
<outputDirectory>${project.build.outputDirectory}< /outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
<includeScope>compile</includeScope>
</configuration>
</execution>
</executions>
</plugin>
06-25-2012 10:43 AM
Hi,
Many thanks for your reply and fixing my mistakes ![]()
Now maven build is working fine, great!
But it seems that the RIM plugin doesn't use maven process (when using right click > debug as > device / simulator). Is there a way to get debug working with a multimodule app? Or to get the RIM plugin using the maven build?
Thanks
06-25-2012 01:24 PM
Right now I have been using the approach of developing in Eclipse but building and releasing using Maven. The Eclipse Plugin's output may have cod files named differently and will output the application and library projects as separate cod files. They don't play nicely with each other at this time.
My recommendation is to use Eclipse to develop and debug your app. It creates a pretty clean way of coding and launching. Let it build your multiple modules and put them on the simualtor and develop using RIM's tools. The Maven tool was really built for that quick debug cycle. If you already have a Maven built instance on that simulator you should remove it.
When you want to do a release: use Maven as it will create a consistent, repeatable build. It can also automate the signing and build for multiple platforms.
If you need to install the app on a device which has the Eclipse built version you will likely have to manually remove the Eclipse built version.
06-26-2012 04:21 AM
Ok, I understand. I like the idea of using eclipse build for development, and maven build for releases.
The only problem with eclipse build is I couldn't get my sample code working:
- when dependencies are closed
- when an unsigned dependency (from a non-blackberry project like jar#2) tries to use classes from signed dependency (jar#1 or app)