我需要从 maven 执行批处理文件,它将采用 2 个应该从 pom 文件传递的参数。我能够执行批处理文件但无法设置参数。 请告诉我如何设置批处理文件的参数
我正在写下面的代码:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<id>runbatchfile</id>
<phase>test</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>cmd</executable>
<workingDirectory></workingDirectory>
<arguments>
<argument>/C</argument>
<argument>D:\ITAS_TOI\toi20161207T072319Z\toi\ITAS.bat</argument>
</arguments>
</configuration>
</plugin>
编辑 :来自以下 OP 的评论:
我尝试了下面的代码,但它给了我以下错误:
The parameters 'executable' for goal org.codehaus.mojo:exec-maven-plugin:1.2:exec are missing or invalid
<configuration>
<tasks>
<exec dir="D:\ITAS_TOI\toi-20161207T072319Z\toi" executable="D:\ITAS_TOI\toi-20161207T072319Z\toi\ITAS.bat" failonerror="true">
<arg line="$testingDevice $executedon" />
</exec>
</tasks>
</configuration>
最佳答案
您可以在 pom.xml
中指定如下参数:
<properties>
<argument1></argument1>
<argument2></argument2>
</properties>
....
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<id>runbatchfile</id>
<phase>test</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>cmd</executable>
<workingDirectory></workingDirectory>
<arguments>
<argument>${argument1}</argument>
<argument>${argument2}</argument>
<!--you can rename accordinlgy-->
</arguments>
</configuration>
</plugin>
然后在命令行上执行如下:
mvn exec:java -Dargument1=/C -Dargument2=D:\ITAS_TOI\toi-20161207T072319Z\toi\ITAS.bat
关于java - 我需要从 maven 执行批处理文件,它将采用 2 个参数并且应该从 pom.xml 传递,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41044829/