简体   繁体   中英

Maven with Ant : exec Command line

I want to retrieve the serial number of my computer by running ant task in pom.xml .

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

[WARNING] Parameter tasks is deprecated, use target instead
[INFO] Executing tasks

main:

[INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------ [INFO] Total time: 1:48.264s
[INFO] Finished at: Wed May 27 10:17:57 GMT+01:00 2015
[INFO] Final Memory: 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
[ERROR] around Ant part ...... @ 4:100 in 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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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