0

2 days ago i asked about building android apps from cli, someone recomended Gradle for building it and it worked.

Now i was trying to do same thing in Blackberry, Is there a tool as Gradle in BlackBerry? where i could build,change package name and sign the files with a predifined build without using the common java gui for signing etc...

Im trying to compile same java files with different resources files everytime making an app customizable by them.

I tryed:

  • compiled an app for blackberry using the codes that eclipse show on console with rpc, this worked but i cant change package name before building.
  • tryed to signing applications using :

Java -jar SignatureTool.jar [ [-a [-p password] ] [-c] [-C] [-s] [-f [-d] inputFile ][-r directory ][-help] codFile codfile... | csiFile

But no lucks this didnt work for me, and i dont really want to use the Java UI for signing apps, i want to acomplish everything executing it from command line so i can make a script that do this for me later.

Is there a way of using Ant or Maven to do this?

Thank you for reading !

EDIT (Added the code)

Im using bb-ant-tools , i used different ways to import the third party jar files but no luck. Also de the signing isn't working.

build.xml

<?xml version="1.0" encoding="UTF-8"?>
    <project name="smspremiumtemplateBB" default="build">
    <property name="jde.home" location="C:\Users\Amir\Desktop\eclipse\plugins\net.rim.ejde.componentpack5.0.0_5.0.0.36\components"/>
    <property name="bb-ant-tools.home" location="C:\Users\Amir\Desktop/eclipse/plugins/org.apache.ant_1.8.4.v201303080030\lib" />
    <taskdef resource="bb-ant-defs.xml" classpath="${bb-ant-tools.home}/bb-ant-tools.jar" />
    <property file="common.properties" />
    <property prefix="project" file="project.properties" />

    <property name="dest.dir" location="build" />

    <path id="import.jars">
        <fileset dir="../MySDK/build" includes="*.jar" />
        <fileset dir="../regex/build" includes="*.jar" />
    </path>

    <path id="src.files">
       <fileset dir="src" includes="**/*" />
       <fileset dir="res" includes="**/*" />
    </path>

<target name="build" depends="">
        <mkdir dir="${dest.dir}" />


        <copy file="${basedir}/res/img/icon.png" tofile="${dest.dir}/icon.png" />


        <rapc 
                jdehome="${jde.home}"
                output="${project.output}" 
                destdir="${dest.dir}" >

            <import refid="import.jars" />
            <src refid="src.files" />
            <jdp file="${basedir}/project.properties" />
            <import location="C:/Users/Amir/Desktop/eclipse/plugins/net.rim.ejde.componentpack5.0.0_5.0.0.36/components/bin/output/regex2.jar" />
            <import>
            <fileset dir="C:/Users/Amir/Desktop/eclipse/plugins/net.rim.ejde.componentpack5.0.0_5.0.0.36/components/bin/output/" includes="*.jar" />
            </import>

        </rapc>
    </target>

    <target name="sign" depends="build">
        <sigtool
                codfile="${dest.dir}/${project.output}.cod" 
                jdehome="${sigtool.jde}" 
                password="${sigtool.password}" />
    </target>

    <target name="clean">
        <delete dir="${dest.dir}" />
    </target>
</project>

common.properties file

jde.home=C:/Users/Amir/Desktop/eclipse/plugins/net.rim.ejde.componentpack5.0.0_5.0.0.36/
sigtool.jde = C:/Users/Amir/Desktop/eclipse/plugins/net.rim.ejde.componentpack5.0.0_5.0.0.36/components
sigtool.password = ********

project.properties file

    output=MySDK 
type=midlet
output=regex
type=midlet
output=MyApp
title=App
type=cldc
vendor=Richard
version=1.0.7
description=A nice app
icon=img/icon.png

EDIT (Solved the signing issue)

Signing is now working just including the .jar files left. My problem was that my SignatureTool.jar was from rimBB_5.0 and i just changed it for the 7.1 one.

EDIT(added output and rapc task for 3rd party libraries)

<rapc 
            jdehome="${jde.home}"
            output="${project.output}_library" 
            destdir="${dest.dir}" 

      >
      <src>
            <fileset dir="./lib/" includes="*.jar"/>
        </src>

      <jdp type= "midlet" title="${app.name}_library" vendor="my vendor" version="@{buildversion}" runonstartup="true" startuptier="6"/>

    </rapc>

output

C:\Users\Amir\Desktop\cliTest\antBB>ant build
Buildfile: C:\Users\Amir\Desktop\cliTest\antBB\build.xml

build:
     [rapc] Compiling 30 source files to MyApp.cod
     [rapc] C:\Users\Amir\Desktop\cliTest\antBB\src\mypackage\ValidationManager.
java:20: error: package me.regexp does not exist
     [rapc] import me.regexp.RE;
     [rapc]                 ^
     [rapc] C:\Users\Amir\Desktop\cliTest\antBB\src\mypackage\ValidationManager.
java:39: error: cannot find symbol
     [rapc]             RE regular_expresion = new RE("^"+pattern+"$");
     [rapc]             ^
     [rapc]   symbol:   class RE
     [rapc]   location: class ValidationManager
     [rapc] C:\Users\Amir\Desktop\cliTest\antBB\src\mypackage\ValidationManager.
java:39: error: cannot find symbol
     [rapc]             RE regular_expresion = new RE("^"+pattern+"$");
     [rapc]                                        ^
     [rapc]   symbol:   class RE
     [rapc]   location: class ValidationManager
     [rapc] 3 errors
     [rapc] Error!: Error: java compiler failed: javac -source 1.3 -target 1.3 -
g -O -d C:\Users\Amir\AppData\Local\Temp\rapc_63ff2f31.dir -bootclas ...

BUILD FAILED
C:\Users\Amir\Desktop\cliTest\antBB\build.xml:35: Java returned: 97

Total time: 2 seconds
Community
  • 1
  • 1
AmirG
  • 615
  • 8
  • 18

1 Answers1

1

Consider BlackBerry Ant Tools

there are four ant tasks:

rapc - that runs the compiler

sigtool - that signs the code

alx - creates a directory structure of cod files and an .alx file. Alx file is using to install the blackberry application via usb-cable. So called "standard install"

jadtool - takes an input .jad file and rewrites it with one or more new cod files. Jad-file is using for install over the air. So called "OTA install".

UPDATE

Let say we have the following jar libraries and need to include them to our project:

  • lib1.jar
  • lib2.jar
  • lib3.jar

Upon compilation all these jar files will be compiled to cod files. And you will get:

  • lib1.cod
  • lib2.cod
  • lib3.cod

If your application cod file name is myapp.cod, then you will need to sign and install the following files:

  • lib1.cod
  • lib2.cod
  • lib3.cod
  • myapp.cod

It is important, myapp.cod will not include those jar files inside, myapp.cod will have only references to corresponding cod files (modules). And you need to sign and install all of these cod files to the device.

Please note that you do not need to sign and install net_rim_api.jar

It is a system library and should not be installed to the device, because it is already supported by the device operating system.

Community
  • 1
  • 1
  • there aren't any third party libraries .cod files in my build directory, i must be doing something wrong.@RafaelOsipov – AmirG Jul 09 '14 at 12:30
  • @AmirG In this case specify your jar files in rapc task directly. Don't use reference for jars, but specify jar files directly. Check it and post here the result. –  Jul 09 '14 at 13:13
  • if you meant for "specify jar files directly" that i should put the path directly for the .jar without using any ${variable} im doing that, even so the build completes without error but the emulation keeps saying that the module doesn't exist when i run the .cod and there isn't any .cod files for that third party library. @RafaelOsipov – AmirG Jul 09 '14 at 14:47
  • Maybe this hint could help : in one of my builds files an error of duplicate definitions of class in the third party library package appear, since this error appear i avoided using that way of importing libraries.@RafaelOsipov – AmirG Jul 09 '14 at 14:53
  • @AmirG there should not be same classes among your jars. I mean fully canonical names. Otherwise you will get a conflict upon compilation. All classes among all libraries must have unique canonical names. –  Jul 09 '14 at 15:23
  • @AmirG you should get a cod file for every jar file after compilation process. Try to compile your jar files to cod modules via rapc task. Specify jar as a source file. –  Jul 09 '14 at 15:28
  • I get same error if i put the .class files from the 3rd party library into src @RafaelOsipov – AmirG Jul 09 '14 at 20:08
  • @AmirG if your jar libraries do not change, then [compile them to cod files](http://stackoverflow.com/questions/10632262/blackberry-create-cod-from-jar-source-file-in-ant-script) sign and just copy these cod files to the build location, along with your application cod file. If you have source code of these jars, I recommend to add the source code to your project and exclude those jars from it. –  Jul 10 '14 at 02:08
  • Sorry if im not getting it right, but that error in my last edit appear when im trying to make the cod files from the 3rd party library jar. – AmirG Jul 10 '14 at 12:56
  • @AmirG upon compilation of your jar file to cod do you import other jar files to resolve dependencies? Seems that there's an unresolved dependency in your jar file, which you are trying to compile to cod module. –  Jul 10 '14 at 13:17
  • when i built this on eclipse i only made reference to the preverified jar and the default net.rim.api.jar. Which jars should i import to satisfy this dependencies on my rapc task?. Btw im using the recomended library for regex in blackberry: [regexp-me](https://code.google.com/p/regexp-me/) – AmirG Jul 10 '14 at 14:13
  • @AmirG as you can see from the error log rapc was unable to resolve regexp-me classes upon compilation of your jar file. –  Jul 10 '14 at 15:16
  • i couldn't get the jar to work, i ended pasting the source code of the third party library on my src.Thank you a lot for your patience. – AmirG Jul 10 '14 at 21:26
  • @AmirG If you have source code, it is far more better to use it, instead of a jar file. –  Jul 11 '14 at 02:07
  • Not every library give you the source code to use it, so i just wanted to learn about importing jar files libraries to my project. But your help worked for me to understand better the process, thank you. @RafaelOsipov – AmirG Jul 11 '14 at 19:35