1

我无法让我的 Ant 脚本(用于 BlackBerry 构建)运行preverify.exe命令并将正确的参数传递给它。


在命令提示符 (Windows 7) 中,这 100% 有效 - 给定的参数正常工作:

preverify -verbose -classpath C:\development\tools\bb-jde\jde5.0\components\lib\net_rim_api.jar -d build\classes\preverified build\classes\preverified build\classes\unverified

我尝试使用以下目标将其放入我的 Ant 脚本中 - 尝试使用相同的参数:

<target name="preverify">
    <mkdir dir="${dest.dir}/classes/preverified" />
    <exec executable="${jde.home}/bin/preverify">
        <arg value="-verbose" />
        <arg value="-classpath C:\development\tools\bb-jde\jde5.0\components\lib\net_rim_api.jar" />
        <arg value="-d build\classes\preverified" />
        <arg value="build\classes\unverified" />
    </exec>
</target>

这不起作用。我收到以下错误:

Illegal option 
-classpath C:\development\tools\bb-jde\jde5.0\components\lib\net_rim_api.jar
  • 这个类路径在命令行中是完全可以接受的(通常 java 命令接受 JAR 文件作为目录,因为它们基本上是 ZIP 文件)。

如何让 Ant 向该命令发送正确的参数,就像在命令行版本中一样?一定有什么exec我想念的吗?


以下是在详细模式下运行此目标的完整 Ant 输出,如果有帮助的话:

Apache Ant(TM) version 1.8.2 compiled on December 20 2010
Trying the default build file: build.xml
Buildfile: C:\development\ant\test_using_javac_jar_preverify_then_rapc\Cobi\build.xml
Detected Java version: 1.6 in: C:\Java\jdk1.6.0_24\jre
Detected OS: Windows 7
parsing buildfile C:\development\ant\test_using_javac_jar_preverify_then_rapc\Cobi\build.xml with URI = file:/C:/development/ant/test_using_javac_jar_preverify_then_rapc/Cobi/build.xml
Project base dir set to: C:\development\ant\test_using_javac_jar_preverify_then_rapc\Cobi
parsing buildfile jar:file:/C:/development/tools/apache-ant/lib/ant.jar!/org/apache/tools/ant/antlib.xml with URI = jar:file:/C:/development/tools/apache-ant/lib/ant.jar!/org/apache/tools/ant/antlib.xml from a zip file
Importing file C:\development\ant\common\constants.xml from C:\development\ant\test_using_javac_jar_preverify_then_rapc\Cobi\build.xml
Overriding previous definition of reference to ant.projectHelper
parsing buildfile C:\development\ant\common\constants.xml with URI = file:/C:/development/ant/common/constants.xml
parsing buildfile jar:file:/C:/development/tools/bb-ant-tools/bb-ant-tools.jar!/bb-ant-defs.xml with URI = jar:file:/C:/development/tools/bb-ant-tools/bb-ant-tools.jar!/bb-ant-defs.xml from a zip file
Overriding previous definition of reference to ant.projectHelper
 [property] Loading C:\development\ant\test_using_javac_jar_preverify_then_rapc\Cobi\project.properties
 [property] Loading C:\development\ant\common\jde5.0.properties
 [property] Loading C:\development\ant\common\common.properties
[pathconvert] Set property net_rim_api.jar.dos = C:\development\tools\bb-jde\jde5.0\components\lib\net_rim_api.jar
Build sequence for target(s) `preverify' is [preverify]
Complete build sequence is [preverify, javac, build, sign, clean, ]

preverify:
    [mkdir] Skipping C:\development\ant\test_using_javac_jar_preverify_then_rapc\Cobi\build\classes\preverified because it already exists.
     [exec] Current OS is Windows 7
     [exec] Executing 'C:\development\tools\bb-jde\jde5.0\components\bin\preverify' with arguments:
     [exec] '-verbose'
     [exec] '-classpath C:\development\tools\bb-jde\jde5.0\components\lib\net_rim_api.jar'
     [exec] '-d build\classes\preverified'
     [exec] 'build\classes\unverified'
     [exec]
     [exec] The ' characters around the executable and arguments are
     [exec] not part of the command.
     [exec] preverify: Illegal option -classpath C:\development\tools\bb-jde\jde5.0\components\lib\net_rim_api.jar
     [exec]
     [exec] Usage: preverify [options] classnames|dirnames ...
     [exec]
     [exec] where options include:
     [exec]    -classpath     <directories separated by ';'>
     [exec]                   Directories in which to look for classes
     [exec]    -d <directory> Directory in which output is written (default is ./output/)
     [exec]    -cldc1.0       Checks for existence of language features prohibited
     [exec]                   by CLDC 1.0 (native methods, floating point and finalizers)
     [exec]    -nofinalize    No finalizers allowed
     [exec]    -nonative      No native methods allowed
     [exec]    -nofp          No floating point operations allowed
     [exec]    @<filename>    Read command line arguments from a text file
     [exec]                   Command line arguments must all be on a single line
     [exec]                   Directory names must be enclosed in double quotes (")
     [exec]
     [exec] Result: 1

BUILD SUCCESSFUL
Total time: 1 second
4

3 回答 3

1

这看起来不像是 ANT 问题。preverify命令正在返回错误消息,证明 ANT 正在执行它...

我不明白这个命令应该做什么,但是使用消息给出了根本原因的提示:

[exec] Usage: preverify [options] classnames|dirnames ...
[exec]
[exec] where options include:
[exec]    -classpath     <directories separated by ';'>
[exec]                   Directories in which to look for classes

您还没有将目录列表指定为“类路径”参数......您提供了一个 jar 文件。该命令是否支持 jar 文件?

于 2012-05-21T18:23:56.580 回答
0

您传递参数的方式不正确。标记和 JAR 名称之间不允许有空格-classpath

您必须将该行(及其-d下方)分成 2 行。这有效:

    <exec executable="${jde.home}/bin/preverify">
        <arg value="-verbose" />
        <!-- classpath to the RIM api -->
        <arg value="-classpath" />
        <arg value="C:\development\tools\bb-jde\jde5.0\components\lib\net_rim_api.jar" />
        <!-- destination folder -->
        <arg value="-d" />
        <arg value="build\classes\preverified" />
        <!-- source folder -->
        <arg value="build\classes\unverified" />
    </exec>
于 2012-05-22T08:18:59.253 回答
0

我通过在环境变量 PATH 中包含 jdk\bin 目录路径解决了这个问题。

于 2013-09-05T05:18:36.763 回答