Maven: retrieve dependency resources before testing

I have a multi-module Maven project. One subproject stores XSL / XML resource files. Another project hosted Java code that should use these files in its unit tests.

In the dependency bar, the resources are in the folder xml-resources.

I found this example and tried to modify it for my needs:

<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>
        <classifier>xml-resources</classifier>
        <outputDirectory>${project.build.directory}/classes/xml-resources</outputDirectory>
      </configuration>
    </execution>
  </executions>
</plugin>

This does nothing when I run the process-test-resources step. We are sure that there are some errors - I don’t see where I can indicate the dependency from which the resources should be taken, but <classifier>it does not seem to indicate the source from which the resources should be copied.

I'm lost here, can someone tell me how to do it right?

+3
1

-

<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>my-artifact-id</includeArtifactIds>
        <includes>foobar.txt, loremipsum.xml</includes>
        <outputDirectory>${project.build.directory}/classes/xml-resources</outputDirectory>
      </configuration>
    </execution>
  </executions>
</plugin>

- .

+6

All Articles