BlackBerry: create COD from JAR source file in Ant script

前端 未结 3 1184
栀梦
栀梦 2020-12-19 13:03

How do I use Ant (bb-ant-tools) to compile a JAR file into a COD? i.e. with no other source files


Reason

Ultimately, I need a script

3条回答
  •  隐瞒了意图╮
    2020-12-19 13:32

    To answer my own question with some details...

    One must not call rapc multiple times - it will create too many COD files. That is why I was getting that error.

    Following up from Michael's answer, the correct way to proceed is to build the final JAR file using the normal java tools (javac & jar) as well as RIM's preverify command.

    Only use rapc for the last step - converting that JAR file into a COD.

    A full ANT build framework to deal with this problem is too big to place here, but the steps needed to create it are listed below. Each of the steps can be easily researched on this site (or with some google). Each step is very simple, and can be debugged individually.

    Steps:

    1. javac the SDK to create CLASS files
    2. preverify the CLASS files
    3. jar the SDK
    4. Copy the SDK JAR file into the project
    5. javac the project - use the SDK JAR as the classpath
    6. preverify the project CLASS files (again, use the SDK JAR in the classpath)
    7. jar the project - add the SDK JAR as a zipfileset
    8. jarjar this project JAR to refactor package names as required
    9. Finally, run rapc on this JAR - it will find no duplicate COD files & should run fine.

    Note: Steps 1-3 can be combined by just using rapc on the SDK (which is needed if you need to run preprocessor tags on the SDK code).

    By breaking it down into simple steps like this, I learnt how the normal java tools link into RIM's toolchain (normally this is all hidden when you simply invoke rapc on a source folder).

    Of course, you still need to sign the COD with the sigtool.

    I do all of this in ANT. I use a different folder to store the output from each step as I go. This way I end up with 5 temp folders at the end, but it made it easy to debug the steps as I go.


    I finally understand now why so few people were able to offer conclusive answers to my various BB ANT build script questions. The process is laborious and very long, and hard to explain.

    A full ANT build framework to accomplish this can stretch over many different files (in my case I think I'm now using 8 including property files). And it requires a good working knowledge of ANT, normal java build tools, and RIM's rapc command.

    I think I have documented each step of the process quite well in my questions about this, and picked up some great answers along the line. For more details, have a look at those other questions & answers. Each one contains useful links, and some good insight from the other developers in this community

提交回复
热议问题