无法使用 Ant 的任务运行"preverify.exe" <exec>



我在让我的 Ant 脚本(用于 BlackBerry 构建(运行 preverify.exe 命令并向其传递正确的参数时遇到问题。


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

preverify -verbose -classpath C:developmenttoolsbb-jdejde5.0componentslibnet_rim_api.jar -d buildclassespreverified buildclassespreverified buildclassesunverified

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

<target name="preverify">
    <mkdir dir="${dest.dir}/classes/preverified" />
    <exec executable="${jde.home}/bin/preverify">
        <arg value="-verbose" />
        <arg value="-classpath C:developmenttoolsbb-jdejde5.0componentslibnet_rim_api.jar" />
        <arg value="-d buildclassespreverified" />
        <arg value="buildclassesunverified" />
    </exec>
</target>

这行不通。我收到以下错误:

Illegal option 
-classpath C:developmenttoolsbb-jdejde5.0componentslibnet_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:developmentanttest_using_javac_jar_preverify_then_rapcCobibuild.xml
Detected Java version: 1.6 in: C:Javajdk1.6.0_24jre
Detected OS: Windows 7
parsing buildfile C:developmentanttest_using_javac_jar_preverify_then_rapcCobibuild.xml with URI = file:/C:/development/ant/test_using_javac_jar_preverify_then_rapc/Cobi/build.xml
Project base dir set to: C:developmentanttest_using_javac_jar_preverify_then_rapcCobi
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:developmentantcommonconstants.xml from C:developmentanttest_using_javac_jar_preverify_then_rapcCobibuild.xml
Overriding previous definition of reference to ant.projectHelper
parsing buildfile C:developmentantcommonconstants.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:developmentanttest_using_javac_jar_preverify_then_rapcCobiproject.properties
 [property] Loading C:developmentantcommonjde5.0.properties
 [property] Loading C:developmentantcommoncommon.properties
[pathconvert] Set property net_rim_api.jar.dos = C:developmenttoolsbb-jdejde5.0componentslibnet_rim_api.jar
Build sequence for target(s) `preverify' is [preverify]
Complete build sequence is [preverify, javac, build, sign, clean, ]
preverify:
    [mkdir] Skipping C:developmentanttest_using_javac_jar_preverify_then_rapcCobibuildclassespreverified because it already exists.
     [exec] Current OS is Windows 7
     [exec] Executing 'C:developmenttoolsbb-jdejde5.0componentsbinpreverify' with arguments:
     [exec] '-verbose'
     [exec] '-classpath C:developmenttoolsbb-jdejde5.0componentslibnet_rim_api.jar'
     [exec] '-d buildclassespreverified'
     [exec] 'buildclassesunverified'
     [exec]
     [exec] The ' characters around the executable and arguments are
     [exec] not part of the command.
     [exec] preverify: Illegal option -classpath C:developmenttoolsbb-jdejde5.0componentslibnet_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

这看起来不像是 ANT 问题。预验证命令返回错误消息,证明 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 文件?

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

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

    <exec executable="${jde.home}/bin/preverify">
        <arg value="-verbose" />
        <!-- classpath to the RIM api -->
        <arg value="-classpath" />
        <arg value="C:developmenttoolsbb-jdejde5.0componentslibnet_rim_api.jar" />
        <!-- destination folder -->
        <arg value="-d" />
        <arg value="buildclassespreverified" />
        <!-- source folder -->
        <arg value="buildclassesunverified" />
    </exec>

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

相关内容

  • 没有找到相关文章

最新更新