我有两个神器:
<plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>2.2</version> <executions> <execution> <goals> <goal>test-jar</goal> </goals> </execution> </executions> </plugin> </plugins>
<dependency> <groupId>com.xxxx.yyy</groupId> <artifactId>artifact-A</artifactId> <version>3.0-SNAPSHOT</version> <type>test-jar</type> <scope>test</scope> </dependency>
问题是资源永远不会在项目工件-B中提取。 我怎么能这样做?
答案 0 :(得分:1)
如果您定义了这样的依赖项,则永远不会提取使用过的jar,因为它将在编译期间放在类路径上。这意味着从工件A访问资源 - 您需要通过类路径访问它们。
答案 1 :(得分:1)
在artifact-B中,我使用maven-dependency-plugin从test-jar中提取资源
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>2.4</version> <executions> <execution> <id>resource-dependencies</id> <phase>process-test-resources</phase> <goals> <goal>unpack-dependencies</goal> </goals> <configuration> <includeArtifactIds>artifact-A</includeArtifactIds> <includes>**/db-test/*</includes> <outputDirectory>${project.build.testOutputDirectory}</outputDirectory> </configuration> </execution> </executions> </plugin>