[英]Maven with Ant : exec Command line
我想通过运行pom.xml
ant任务来检索计算机的序列号。
<profile>
<id>generate-license</id>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>compile</phase>
<configuration>
<tasks>
<exec executable="wmic bios get serialnumber"
resultproperty="serialNumber"
failonerror="false" />
<echo message="Serial number: ${serialNumber}" />
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
我在编译阶段执行maven,结果如下:
[警告]不建议使用参数任务,请改用target
[INFO]执行任务
主要:
[INFO] ----------------------------------------------- ------------------------- [INFO]内置失败
[INFO] ----------------------------------------------- ------------------------- [INFO]总时间:1:48.264s
[INFO]结束于:2015年5月27日星期三10:17:57 GMT + 01:00
[INFO]最终内存:11M / 121M
[INFO] ----------------------------------------------- ------------------------- [错误]无法执行目标org.apache.maven.plugins:maven-antrun-plugin:1.7:run(默认值):在项目运行器上:发生了Ant BuildException:执行失败:java.io.IOException:无法运行程序“ wmic bios获取序列号”:CreateProcess错误= 2,可解释
[错误]蚂蚁部分...... @ 4:100在C:\\ xxx \\ yyy \\ target \\ antrun \\ build-main.xml中
您可以使用以下语法尝试参数吗?
<exec executable="wmic" resultproperty="serialNumber" failonerror="false">
<arg value="bios" />
<arg value="get" />
<arg value="serialnumber" />
</exec>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.