This is a follow-up to: BlackBerry - use own JAR file in own project & BlackBerry - Ant build script for more complex apps. This problem has now been solved below.
Aim
I want to:
- use Ant (bb-ant-tools) to build my library into a JAR file
- include that JAR file in a project
- use Ant to build that project into a COD that will run on the device (without external COD files).
The important part is to use Ant to do the final stage of the build.
All posts I have found for this problem use Eclipse for that final build stage (details at BlackBerry - use own JAR file in own project).
Progress
- I can build the library project into a JAR using Ant.
- In Eclipse, I can add that JAR file to a project, and build it as desired (single COD, no external dependencies). It will run on the device.
- In Ant, I can also make a build that relies on an extra COD library to contain the runtime code - this is close to what I need.
Problem
I can build the final project with Ant. But the resulting COD file does not include any runtime code from my library.
Many posts I have read show how this can be done using extra COD files for the library. I would like to avoid this.
How can I include a JAR into my project without external dependencies, using Ant? I believe this is possible because I can do it using Eclipse.
Workaround
My current workaround is to include my SDK / library project as source code (as per esaj's answer below), rather than as a JAR file. This has some disadvantages over the JAR approach, but I have a build that runs on the device successfully.
(I hope its OK to cross-reference this question with the following long list of links?)
StackOverflow links:
- Continuous Integration server for blackberry development? (and certificate signing) (I haven't had time to go through this one, but I think it looks promising)
- Blackberry: Verificattion error when using Library project as External Jar
- https://stackoverflow.com/questions/6134940/how-to-use-external-library-jar-file-in-blackberry
- Blackberry 5.0 - Add reference to a Java Library Project
- How to add external jar or zip file in the Blackberry project
- Blackberry Apps - Importing a code-signed jar into an application project
- How to add library project with the current development project in blackberry
This one gives other links - quite useful:
These not so useful:
- In Blackberry, can we create common library that can be used by different applications?
- BlackBerry Facebook SDK jar file
- Adding and Testing Compatibility of External Jar to Blackberry Project
- How to attach Jar in Blackberry
- BlackBerry RIMAPPSA2 signing key required -- why?
- Is there a list of classes, methods and API which will trigger RIMAPPSA2 permission when signing Blackberry application?
RIM:
I had a similar problem last year, I had created a "framework" that was used as a base for multiple BB-applications, but run into problems with multiple CODs (I don't remember exactly what, something like the device refused to install multiple applications that had same external cods, if the external CODs weren't installed separately first, and then the applications). As the applications could be installed separately (one person might install only app A, another might install only app B, and yet another might install both A and B), the whole framework needed to be included in all the apps using it. I cooked up this Ant-script using bb-ant-tools (hopefully I didn't break anything removing some stuff specific to our apps and obfuscating package names etc):
What this does, is copy all the java-files and resources from your current project and then from the framework-project to a temporary directory, replacing package names on the way for the frame-work files (as they're put into a separately named directory), this has to do with the fact that the devices also refused to install multiple applications that had same classes under same packages (namely, the framework classes, for your case this might not be necessary). After the copying and replacing is done, the application is built to target build-directory using rapc. There are separate tasks for signing, cleaning and loading the app to a simulator. Hope this helps.
Have you tried pointing to the library in the src section under rapc?
E.g.: