我正在使用带有以下命令的Exec Maven插件:
mvn exec:java
我没有设法用这种执行模式设置工作目录.我想使用mainClass(在特定的包中),我希望我的执行的根文件夹在$ {basedir}之外的另一个目录中.
谢谢您的帮助.
我的pom.xml目标<workingDirectory>对我不起作用:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.3.2</version>
<configuration>
<workingDirectory>${project.build.directory}\classes</workingDirectory>
<mainClass>com.package.MyMainClass</mainClass>
<includeProjectDependencies>true</includeProjectDependencies>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
使用-X选项的结果
[DEBUG] Configuring mojo org.codehaus.mojo:exec-maven-plugin:1.3.2:java from plugin realm ClassRealm[plugin>org.codehaus.mojo:exec-maven-plugin:1.3.2,parent: sun.misc.Launcher$AppClassLoader@11b86e7]
[DEBUG] Configuring mojo 'org.codehaus.mojo:exec-maven-plugin:1.3.2:java' with basic configurator -->
[DEBUG] (f) arguments = []
[DEBUG] (f) classpathScope = runtime
[DEBUG] (f) cleanupDaemonThreads = true
[DEBUG] (f) daemonThreadJoinTimeout = 15000
[DEBUG] (f) includePluginDependencies = false
[DEBUG] (f) includeProjectDependencies = true
[DEBUG] (f) keepAlive = false
[DEBUG] (f) killAfter = 1
[DEBUG] (f) localRepository = id: local url: file:///C:/Users/100728452/.m2/repository/ layout: none
[DEBUG] (f) mainClass = com.package.MyMainClass
[DEBUG] (f) pluginDependencies = [org.codehaus.mojo:exec-maven-plugin:maven-plugin:1.3.2:, org.codehaus.plexus:plexus...
[DEBUG] (f) skip = false
[DEBUG] (f) stopUnresponsiveDaemonThreads = false
[DEBUG] (s) key = sun.java2d.ddoffscreen
[DEBUG] (s) value = false
[DEBUG] (s) key = com.odi.OStoreLicenseFile
[DEBUG] (s) value = .\library\odi\etc\license.txt
[DEBUG] (f) systemProperties = [org.codehaus.mojo.exec.Property@194e776, org.codehaus.mojo.exec.Property@e80740]
[DEBUG] -- end configuration --
[WARNING] Warning: killAfter is now deprecated. Do you need it ? Please comment on MEXEC-6.
[DEBUG] Invoking : com.mypackage.MyMainClass.main()
[DEBUG] Plugin Dependencies will be excluded.
[DEBUG] Project Dependencies will be included.
[DEBUG] Collected project artifacts [javax.help:javahelp:jar:2.0.02:compile,
Run Code Online (Sandbox Code Playgroud)
use*_*947 23
我没有找到exec:java的解决方案.
所以,现在我使用exec:exec代替,因为我们可以设置workingDirectory并且它确定.
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.3.2</version>
<executions>
<execution>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>java</executable>
<arguments>
<argument>-classpath</argument>
<classpath />
<argument>com.package.MyMainClass</argument>
</arguments>
<workingDirectory>${project.build.outputDirectory}</workingDirectory>
</configuration>
Run Code Online (Sandbox Code Playgroud)
如果您想通过调用来设置它,mvn exec:java ...您需要像这样通过属性:
mvn exec:java -Dexec.workingdir=Folder ...
Run Code Online (Sandbox Code Playgroud)
这与您在 pom 中定义的内容无关,因为调用目标exec:java不是生命周期的一部分。
| 归档时间: |
|
| 查看次数: |
29295 次 |
| 最近记录: |