简体   繁体   English

使用Ant进行Maven:exec命令行

[英]Maven with Ant : exec Command line

I want to retrieve the serial number of my computer by running ant task in pom.xml . 我想通过运行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>

I execute maven at compile phase and here is the result: 我在编译阶段执行maven,结果如下:

[WARNING] Parameter tasks is deprecated, use target instead [警告]不建议使用参数任务,请改用target
[INFO] Executing tasks [INFO]执行任务

main: 主要:

[INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ----------------------------------------------- ------------------------- [INFO]内置失败
[INFO] ------------------------------------------------------------------------ [INFO] Total time: 1:48.264s [INFO] ----------------------------------------------- ------------------------- [INFO]总时间:1:48.264s
[INFO] Finished at: Wed May 27 10:17:57 GMT+01:00 2015 [INFO]结束于:2015年5月27日星期三10:17:57 GMT + 01:00
[INFO] Final Memory: 11M/121M [INFO]最终内存:11M / 121M
[INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.7:run (default) on project runner: An Ant BuildException has occured: Execute failed: java.io.IOExcept ion: Cannot run program "wmic bios get serialnumber": CreateProcess error=2, Le fichier spÚcifiÚ est introuvable [INFO] ----------------------------------------------- ------------------------- [错误]无法执行目标org.apache.maven.plugins:maven-antrun-plugin:1.7:run(默认值):在项目运行器上:发生了Ant BuildException:执行失败:java.io.IOException:无法运行程序“ wmic bios获取序列号”:CreateProcess错误= 2,可解释
[ERROR] around Ant part ...... @ 4:100 in C:\\xxx\\yyy\\target\\antrun\\build-main.xml [错误]蚂蚁部分...... @ 4:100在C:\\ xxx \\ yyy \\ target \\ antrun \\ build-main.xml中

Could you try the arguments using the following syntax please? 您可以使用以下语法尝试参数吗?

<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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM