使用Ant,如何从一个src目录创建单独的jar文件?

时间:2011-07-01 21:03:08

标签: java blackberry ant

我有一个源目录,我正在尝试创建单独的cod文件,因为我的资源(PNG文件)超出了RAPC编译器的限制。

我正在尝试创建:

  1. .cod(s)for source
  2. .cod(s)for res res。资源
  3. .cod(s)for hi res。资源
  4. 我成功创建了以下内容:

    AppMeasurement_BlackBerry.cod

    com_mch_coffeehouse-1.cod

    com_mch_coffeehouse.cod

    com_mch_coffeehouse.jad

    com_mch_coffeehouse_resources_hires-1.cod

    com_mch_coffeehouse_resources_hires-2.cod

    com_mch_coffeehouse_resources_hires-3.cod

    com_mch_coffeehouse_resources_hires-4.cod

    com_mch_coffeehouse_resources_hires-5.cod

    com_mch_coffeehouse_resources_hires-6.cod

    com_mch_coffeehouse_resources_hires-7.cod

    com_mch_coffeehouse_resources_hires.cod

    com_mch_coffeehouse_resources_lowres-1.cod

    com_mch_coffeehouse_resources_lowres-2.cod

    com_mch_coffeehouse_resources_lowres-3.cod

    com_mch_coffeehouse_resources_lowres-4.cod

    com_mch_coffeehouse_resources_lowres.cod

    共1.cod

    common.cod

    但是,应用程序无法启动,并且从设备上的事件日志中,我得到了很好的加密消息:

    RIM无线手持Java加载程序 版权所有2001-2009 Research In Motion Limited 连接的 guid:0x97C9F5F641D25E5F时间:Wed Dec 31 19:00:00 1969严重程度:0类型:2 app:系统数据:JVM:INFOp = 23575346,a ='5.0.0.979',o ='5.1.0.177',h = 4001507 guid:0x9C3CD62E3320B498时间:2011年7月1日星期五16:59:26严重程度:1类型:3 app:Java异常数据:         错误         没有详细消息         com_mch_coffeehouse(4E0E2E1F)          CoffeeHouseClient                    0x3764         com_mch_coffeehouse(4E0E2E1F)          CoffeeHouseClient          主要          0x30BD guid:0x0 time:Fri Jul 01 16:59:26 2011严重程度:2类型:3 app:数据:         回溯:

    guid:0x97C9F5F641D25E5F时间:2011年7月1日星期五16:59:31严重程度:0类型:2 app:系统数据:JVM:INFOp = 23575346,a ='5.0.0.979',o ='5.1.0.177', H = 4001507

    无论如何,在成为关键阻截者之前,我们非常感谢任何帮助或建议 - yippee!

    我的蚂蚁脚本:

    <?xml version="1.0" encoding="UTF-8"?>
    

        

    <property name="package.label" value="com_mch_coffeehouse" />
    
    <property name="lowres.label" value="com_mch_coffeehouse_resources_lowres" />
    
    <property name="hires.label" value="com_mch_coffeehouse_resources_hires" />
    
    <property name="jde.home" value="C:\Eclipse3.6\plugins\net.rim.ejde.componentpack5.0.0_5.0.0.25\components" />
    
    <property name="workspace" value="C:\Users\jtp\Documents\mch" />
    
    <property name="appmeasure" value="${workspace}\AppMeasurement_BlackBerry\deliverables\Standard\5.0.0" />
    
    <property name="common" value="${workspace}\Common-BlackBerry\deliverables\Standard\5.0.0" />
    
    <property name="simulator" value="${jde.home}\simulator" />
    
    <property name="bin" value="${jde.home}\bin" />
    
    <property name="src" value="src" />
    
    <property name="respackage" value="${src}\com\mch\coffee_house\res" />
    
    <property name="hi" value="${respackage}\hi" />
    
    <property name="low" value="${respackage}\low" />
    
    <property name="dest" value="deliverables" />
    
    <property name="ota.dir" value="${dest}\ota" />
    
    <target name="debug" depends="ota" description="Build, deploy project and Launches Remote Debug Server">
        <exec executable="cmd.exe" dir="${bin}" spawn="true">
            <arg value="/c" />
            <arg value="jdwp.bat" />
        </exec>
    </target>
    
    <target name="simulate" depends="ota" description="Build, deploy project and Launches Simulator">
        <exec executable="cmd.exe" dir="${simulator}" spawn="true">
            <arg value="/c" />
            <arg value="${simulator}\9700.bat" />
        </exec>
    </target>
    
    <target name="ota" depends="build" description="Build OTA project.">
        <mkdir dir="${ota.dir}" />
        <jadtool input="${dest}\${package.label}.jad" destdir="${ota.dir}">
            <fileset dir="${appmeasure}" includes="*.cod" />
            <fileset dir="${common}" includes="*.cod" />
            <fileset dir="${dest}" includes="*.cod" />
        </jadtool>
    </target>
    
    <target name="deploy" depends="build" description="Build and deploy project.">
        <copy todir="${simulator}" overwrite="true">
            <fileset dir="${appmeasure}">
                <include name="*.cod" />
                <include name="*.debug" />
                <include name="*.csl" />
                <include name="*.cso" />
            </fileset>
        </copy>
        <copy todir="${simulator}" overwrite="true">
            <fileset dir="${common}">
                <include name="*.cod" />
                <include name="*.debug" />
                <include name="*.csl" />
                <include name="*.cso" />
            </fileset>
        </copy>
        <copy todir="${simulator}" overwrite="true">
            <fileset dir="${dest}">
                <include name="*.cod" />
                <include name="*.debug" />
                <include name="*.csl" />
                <include name="*.cso" />
            </fileset>
        </copy>
    </target>
    
    <target name="build" depends="buildhiresources" description="Builds project.">
        <!-- Copy the resource package to be compiled with preserved folder hierarchy -->
        <!--<copy todir="${dest}">
            <fileset dir="${src}">
                <include name="com/mch/coffee_house/res/low/*.png" />
                <include name="com/mch/coffee_house/res/hi/*.png" />
                <exclude name="**/*.java" />
                <exclude name="com/mch/coffee_house/res/torch/*.png" />
            </fileset>
        </copy>-->
        <!--
        ${appmeasure}\AppMeasurement_BlackBerry.jar:${common}\danicacommon.jar:${dest}\com_mch_coffeehouse_resources_hires.jar:${dest}\com_mch_coffeehouse_resources_lowres.jar
        -->
        <rapc jdehome="${jde.home}" jdkhome="${java.home}" import="${appmeasure}\AppMeasurement_BlackBerry.jar:${common}\danicacommon.jar:${dest}\com_mch_coffeehouse_resources_hires.jar:${dest}\com_mch_coffeehouse_resources_lowres.jar" destdir="${dest}" noconvert="false" output="${package.label}" quiet="true" verbose="false" generatesourcelist="false" nopreverify="true">
            <jdp type="cldc" title="mch coffeehouse" vendor="MCH Inc" version="1.0.0" description="Find a coffee house from your BlackBerry device." arguments="" systemmodule="false" runonstartup="false" startuptier="7" ribbonposition="0" nameresourcebundle="com.mch.coffeehouse" nameresourceid="0" icon="../src/com/mch/coffee_house/res/hi/icon.png">
            </jdp>
            <src>
                <fileset dir=".">
                    <exclude name="src/com/mch/coffee_house/res/hi/*.java*" />
                    <exclude name="src/com/mch/coffee_house/res/low/*.java*" />
                    <include name="src/**/*.java*" />
                    <include name="src/**/*.rrc*" />
                    <include name="src/**/*.rrh*" />
                    <include name="src/**/*.cod*" />
                    <include name="src/**/*.cso*" />
                    <include name="src/**/*.MF*" />
                    <!-- Add the preserved folder hierachy to be compiled as is -->
                    <!--<include name="${dest}/com/**/*.*" />-->
                </fileset>
            </src>
        </rapc>
        <sigtool jdehome="${jde.home}" password="########" close="false">
            <fileset dir="${dest}" includes="*.cod" />
        </sigtool>
    </target>
    <!-- Hi Res. Resources -->
    <target name="buildhiresources" depends="buildlowresources" description="Builds low resolution resources project.">
        <!-- Copy the resource package to be compiled with preserved folder hierarchy -->
        <copy todir="${dest}">
            <fileset dir="${src}">
                <include name="com/mch/coffee_house/res/hi/*.png" />
                <exclude name="com/mch/coffee_house/res/low/*.png" />
                <exclude name="**/*.java" />
                <exclude name="com/mch/coffee_house/res/torch/*.png" />
            </fileset>
        </copy>
        <rapc jdehome="${jde.home}" jdkhome="${java.home}" destdir="${dest}" noconvert="false" output="${hires.label}" quiet="true" verbose="false" generatesourcelist="false" nopreverify="true">
            <jdp type="library" title="MCH Library" vendor="MCH Inc" version="1.0.0" description="coffeehouse hi-res resources library.">
            </jdp>
            <src>
                <fileset dir=".">
                    <!-- Add the preserved folder hierachy to be compiled as is -->
                    <include name="src/com/mch/coffee_house/res/hi/*.java*" />
                    <include name="${dest}/com/**/*.*" />
                    <exclude name="${dest}/com/mch/coffee_house/res/low/*.png" />
                </fileset>
            </src>
        </rapc>
        <sigtool jdehome="${jde.home}" password="########" close="false">
            <fileset dir="${dest}" includes="*.cod" />
        </sigtool>
    </target>
    <!-- Low Res. Resources -->
    <target name="buildlowresources" description="Builds low resolution resources project.">
        <!-- Copy the resource package to be compiled with preserved folder hierarchy -->
        <copy todir="${dest}">
            <fileset dir="${src}">
                <exclude name="com/mch/coffee_house/res/hi/*.png" />
                <include name="com/mch/coffee_house/res/low/*.png" />
                <exclude name="**/*.java" />
                <exclude name="com/mch/coffee_house/res/torch/*.png" />
            </fileset>
        </copy>
        <rapc jdehome="${jde.home}" jdkhome="${java.home}" destdir="${dest}" noconvert="false" output="${lowres.label}" quiet="true" verbose="false" generatesourcelist="false" nopreverify="true">
            <jdp type="library" title="MCH Library" vendor="MCH Inc" version="1.0.0" description="coffeehouse low-res resources library.">
            </jdp>
            <src>
                <fileset dir=".">
                    <!-- Add the preserved folder hierachy to be compiled as is -->
                    <include name="src/com/mch/coffee_house/res/low/*.java*" />
                    <include name="${dest}/com/**/*.*" />
                </fileset>
            </src>
        </rapc>
        <sigtool jdehome="${jde.home}" password="########" close="false">
            <fileset dir="${dest}" includes="*.cod" />
        </sigtool>
    </target>
    
    <target name="clean" description="Clean the destination directory.">
        <delete dir="${ota.dir}" failonerror="no" />
        <delete dir="${dest}" failonerror="no" />
        <mkdir dir="${dest}" />
    </target>
    

1 个答案:

答案 0 :(得分:1)

使用BlackBerry Ant ToolsPreprocessor生成包含源文件和资源的单独文件夹,并使用compile them分隔应用程序文件。