1
votes

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

1

1 Answers

2
votes

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>