我正在尝试使用maven-exec-plugin为我用EJB 2.1创建的旧项目启动ejbdeploy命令。
问题是,命令的一个参数是另一个命令(RMIC),它也有我需要使用的参数。
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>ejb-deploy</id>
<phase>package</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>ejbdeploy</executable>
<arguments>
<argument>${project.build.directory}\${project.build.finalName}.jar</argument>
<argument>${project.build.directory}\working</argument>
<argument>${project.build.directory}\${project.build.finalName}-deployed.jar</argument>
<argument>-rmic "-d C:\java\classes"</argument>
<argument>-cp</argument>
<classpath/>
</arguments>
</configuration>
</execution>
</executions>
</plugin>此代码段在我的mvn clean install期间生成一个错误:
[INFO] --- exec-maven-plugin:1.5.0:exec (ejb-deploy) @ SIMBOLight ---
Unrecognized option: -rmic -d.
Unrecognized option: C:\java\classes.
Error: Must specify the input JAR/EAR filename, the working directory, and output JAR/EAR filename.
0 Errors, 0 Warnings, 0 Informational Messages好像我把我的参数设置错了。有什么想法吗?
发布于 2016-09-12 09:24:14
在向exec-maven-plugin传递参数时,需要确保每个<argument>不包含未转义的空格字符。每个参数必须作为一个单独的<argument>给出。
在您的示例中,-rmic "-d C:\java\classes"实际上由2个参数组成:第一个参数是-rmic,第二个参数是"-d C:\java\classes" (包含转义空间),因此不能将它们传递给单个<argument>。
因此,您可以具有以下配置:
<arguments>
<argument>${project.build.directory}\${project.build.finalName}.jar</argument>
<argument>${project.build.directory}\working</argument>
<argument>${project.build.directory}\${project.build.finalName}-deployed.jar</argument>
<argument>-rmic</argument>
<argument>"-d C:\java\classes"</argument>
<argument>-cp</argument>
<classpath />
</arguments>当使用这些参数配置时,已启动的可执行文件的main方法将在参数数组中将-rmic作为第三个元素,而-d C:\java\classes将在参数数组中作为第四个元素。
https://stackoverflow.com/questions/39446742
复制相似问题