我可以使用简单的jar jdk工具命令将文件添加到预先存在的jar文件的根目录中:
jar uf target/my.jar -C target/classes plugin.xml
但是,当我尝试使用exec-maven-plugin并从与以前相同的位置运行mvn时,会这样做:
mvn exec:exec@add-dn-plugin-execution
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<id>add-dn-plugin-execution</id>
<phase>package</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>jar</executable>
<arguments>
<argument>uf target/my.jar -C target/classes plugin.xml</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
我在下面遇到错误。
>mvn exec:exec@add-dn-plugin-execution
[INFO] Scanning for projects...
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- exec-maven-plugin:1.6.0:exec (add-dn-plugin-execution) @
Usage: jar {ctxui}[vfmn0PMe] [jar-file] [manifest-file] [entry-point] [-C dir] files ...
[ERROR] Command execution failed.
org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
at org.apache.commons.exec.DefaultExecutor.executeInternal (DefaultExecutor.java:404)
at org.apache.commons.exec.DefaultExecutor.execute (DefaultExecutor.java:166)
at org.codehaus.mojo.exec.ExecMojo.executeCommandLine (ExecMojo.java:804)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.032 s
[INFO] Finished at: 2018-08-13T12:16:40-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:exec (add-dn-plugin-execution) on project bss:
Command execution failed.: Process exited with an error: 1 (Exit value: 1) -> [Help 1]
任何想法如何从exec-maven-plugin正确使用jar jdk工具? 还是我需要使用其他Maven插件来完成这项工作?