shell - 如何在 ant 脚本中运行 Maven 命令?
问题描述
我正在尝试创建一个 ant 任务来执行 maven 命令,但是在运行 ant 任务时出现错误
<target name="Junit">
<exec dir="./MServer/BuildServer/Workspc/CustMgmt" executable="cmd">
<arg value="/C"/>
<arg value="E:\EOM Setup\maven-3.3.9\bin\mvn.bat"/>
<arg value="test" />
</exec>
</target>
运行此程序时,出现错误:'E:\EOM' 不被识别为内部或外部命令、可运行程序或批处理文件(我在 Windows 7 上运行)
解决方案
您可以通过使用带有属性(而不是更常见的属性)的 Antproperty
任务来解决这个问题。这会将值存储为格式正确的路径。此外,您可以使用它来引用 mvn.bat,而不是每次都输入整个路径。location
value
<target name="Junit">
<property name="mvn.executable" location="E:\EOM Setup\maven-3.3.9\bin\mvn.bat" />
<exec dir="./MServer/BuildServer/Workspc/CustMgmt" executable="cmd">
<arg value="/C"/>
<arg value="${mvn.executable}"/>
<arg value="test" />
</exec>
</target>
推荐阅读
- git - 为什么每次更新更新日志时我的旧提交都会重新出现?
- javascript - JS:如何在 AlertifyJS 中覆盖 keyupHandler(event) 函数?
- jhipster - 为什么 jhipster 即使在登录后也考虑用户匿名
- python - 无法使用 pip install 安装软件包(在公司代理后面)
- python - Alpine 上的 Mozilla DeepSpeech
- reactjs - React 中的状态管理
- reactjs - React Router + React Pose 以“POP”或“PUSH”方向滑入/滑出
- angular - 来自cordova-camera-preview的离子调整图像大小?
- laravel - 如何在scss中获取环境变量
- xml - 将命名空间添加到 XML 中的标头