我需要从一个依赖的jar文件到我的当前项目的输出目录的根目录的根目录复制的资源文件(menu.xml文件),在生成过程中被执行的测试之前.该文件必须可用于测试,但稍后也可用于主程序...getClassLoader().getResourceAsStream("menu.xml").
我正在尝试在这个问题中提出的解决方案,但它不起作用.
这是pom文件的样子:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>resource-dependencies</id>
<phase>process-test-resources</phase>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<type>jar</type>
<includeArtifactIds>pm1j-jar</includeArtifactIds>
<includes>menu.xml</includes>
<outputDirectory>${project.build.outputDirectory}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
当我执行时,mvn clean process-test-resources我看到以下输出:
[INFO] --- maven-resources-plugin:2.7:testResources (default-testResources) @ pm1-config ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 3 resources
[INFO]
[INFO] --- maven-dependency-plugin:2.8:unpack-dependencies (resource-dependencies) @ pm1-config ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.709 s
[INFO] Finished at: 2016-05-05T15:01:06-03:00
[INFO] Final Memory: 30M/458M
[INFO] ------------------------------------------------------------------------ …Run Code Online (Sandbox Code Playgroud)