【发布时间】:2012-07-31 08:22:26
【问题描述】:
我正在尝试使用 exec:exec 目标使用 maven exec 插件运行 java 程序。
我需要在类路径中添加一个额外的 jar(sun 工具 jar)。
由于 includePluginDependencies 仅适用于 exec:java 目标,我想在参数部分手动添加它,但找不到将其连接到基类路径的方法。问题是由于 jar 被定义为系统范围,maven 不会将它添加到运行时类路径中,我需要手动添加它。
如果有人知道如何从命令行执行此操作,那就更好了。
在此先感谢,
阿夫纳
-
您可以在下面看到插件部分
<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.2.1</version> <dependencies> <dependency> <groupId>com.sun</groupId> <artifactId>tools</artifactId> <scope>system</scope> <systemPath>${JDK_HOME}/lib/tools.jar</systemPath> </dependency> <dependency> <groupId>${project.groupId}</groupId> <artifactId>myArtifact</artifactId> <version>1.0</version> </dependency> </dependencies> <configuration> <executable>java</executable> <arguments> <argument>-classpath</argument> <classpath/> <argument>com.mycompany.MyMainClass</argument> </arguments> </configuration> <executions> <execution> <goals> <goal>exec</goal> </goals> </execution> </executions> </plugin>
【问题讨论】:
-
我不得不解决几乎这个确切的问题,但我的配置看起来很像你的 (
<classpath/>)。我不清楚“将其连接到基类路径”是什么意思。你的意思是“引导”类路径?您能否提供构建输出的 sn-p 并描述您的最终目标? -
我的目标是使用 maven 计算的运行时类路径运行我的 java 程序,同时将 tools.jar 添加到其中。由于这些工具被定义为系统范围,因此它不会添加到 maven 计算的运行时类路径中。最终我决定使用 maven-antrun-plugin。
标签: maven maven-plugin