Не удается запустить "preverify.exe" с помощью задачи Ant <exec>
У меня проблемы с получением моего скрипта 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
3 ответа
То, как вы передаете параметры, неверно. Пространство между -classpath
тег, а имя JAR не допускается.
Вы должны разорвать эту линию (и -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>
Это не похоже на проблему 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
Вы не указали список каталогов в качестве параметра "classpath".... Вы указали файл jar. Может ли команда поддерживать файлы JAR?
Я решил эту проблему, включив путь к каталогу jdk\bin в переменную окружения PATH.