首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >不能使用Ant的preverify.exe任务运行“<exec>”

不能使用Ant的preverify.exe任务运行“<exec>”
EN

Stack Overflow用户
提问于 2012-05-21 14:09:24
回答 3查看 1.4K关注 0票数 1

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

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

代码语言:javascript
复制
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脚本中--尝试使用相同的参数:

代码语言:javascript
复制
<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>

这是不起作用的。I得到以下错误:

代码语言:javascript
复制
Illegal option 
-classpath C:\development\tools\bb-jde\jde5.0\components\lib\net_rim_api.jar

  • 这个类路径在命令行中是完全可以接受的(通常java命令接受JAR文件作为目录,因为它们基本上是ZIP文件)。

如何才能让Ant向这个命令发送正确的参数,就像在命令行版本中一样?,一定有关于exec的东西,我遗漏了什么?

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

代码语言:javascript
复制
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
EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2012-05-22 08:18:59

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

您必须将这一行(以及它下面的-d )拆分为2行。这样做是可行的:

代码语言:javascript
复制
    <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>
票数 0
EN

Stack Overflow用户

发布于 2012-05-21 18:23:56

这看起来不像是蚂蚁的问题。错误消息由预验证命令返回,证明ANT正在执行.

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

exec用法:预验证选项,类名,目录名.其中的选项包括: exec -classpath <目录,由';'> exec目录分隔,其中查找类

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

票数 1
EN

Stack Overflow用户

发布于 2013-09-05 05:18:36

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10686856

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档