Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Contributor
kurtzettel
Posts: 6
Registered: ‎11-29-2011
My Device: 9810

Maven BlackBerry Plugin

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/repositories/releases/

 

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.

Please use plain text.
Developer
simon_hain
Posts: 16,190
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Maven BlackBerry Plugin

Welcome to the support forums Kurt, i appreciate your efforts, thank you for posting this here, and even more for contributing the plugin to the developer community.

I have downloaded the sources a few days ago and successfully compiled the plugin (with skipTests=true, as i did not have the proguard jar the tests want as it seems).

I did not succeed to build the hello world sample though. I saw that it referenced an older version of the plugin and changed that, but to no avail. Can you check if the hello world in your SVN builds well on your side?

I am really looking forward to see the plugin working, we have a few complicated projects that i did not succeed to build with bb-ant yet, and this would save me quite some hours on our release process.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
New Contributor
kurtzettel
Posts: 6
Registered: ‎11-29-2011
My Device: 9810

Re: Maven BlackBerry Plugin

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.

Please use plain text.
New Contributor
kurtzettel
Posts: 6
Registered: ‎11-29-2011
My Device: 9810

Re: Maven BlackBerry Plugin

I haven't looked at hello-world but I got the advanced fields example building.  Checkout svn://goodformobile.com/maven-plugin/trunk/blackberry-root and intstall the pom.  Then checkout svn://goodformobile.com/maven-plugin/trunk/test-advanced-fields.  If you use these settings in your settings.xml:

 

<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.2\\plugins\\net.rim.ejde.componentpack6.0.0_6.0.0.30\\components</jde.directory>
<preverify.path>C:\tools\j2me\WTK2.5.2\bin\preverify.exe</preverify.path>
<signature.path>C:\tools\rim\signatureTool</signature.path>
</properties>
</profile>

 

And run:

 

mvn clean install -P rim-6.0.0 -Drim.platform=rim-6.0.0

Please use plain text.
Developer
simon_hain
Posts: 16,190
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Maven BlackBerry Plugin

Hello Kurt,
after playing around a bit with my local maven guru we succeeded in building the project.

I have to admit that my maven knowledge is very basic, i did not know that i had to checkout the blackberry-root project and run maven install with rim-jar.version as a parameter.
We also had to put the rim api jar to the correct repository path manually as we had it somewhere else.

Signing was slow, and we suspected some error in the build, but after a while it completed successfully.

Now to the real task, get my main project to compile with it. No time for it right now, but i'll report if we succeed, it's fairly complicated with many dependencies and 4 different preprocessing levels.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Contributor
anwfr
Posts: 14
Registered: ‎11-22-2011
My Device: Bold 9790

Re: Maven BlackBerry Plugin

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

Please use plain text.
New Contributor
kurtzettel
Posts: 6
Registered: ‎11-29-2011
My Device: 9810

Re: Maven BlackBerry Plugin

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>	

 



Please use plain text.
Contributor
anwfr
Posts: 14
Registered: ‎11-22-2011
My Device: Bold 9790

Re: Maven BlackBerry Plugin

Hi,

 

Many thanks for your reply and fixing my mistakes :smileyhappy:

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

Please use plain text.
New Contributor
kurtzettel
Posts: 6
Registered: ‎11-29-2011
My Device: 9810

Re: Maven BlackBerry Plugin

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.

Please use plain text.
Contributor
anwfr
Posts: 14
Registered: ‎11-22-2011
My Device: Bold 9790

Re: Maven BlackBerry Plugin

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)

 

Please use plain text.