6

I am having a difficulty to understand the difference between the maven-resources-plugin and the project.build.resources tag, in maven.

Both seem to have the same purpose. The different goals of the maven-resources-plugin [resources, testResources and copy-resources] can also be achieved using the resources tag as:

<resources>
  <resource>  
    <directory>src/dir</directory>
    <targetPath>dest/dir</targetPath>
  </resource>  
</resources>

<testResources>
  <testResource>
  <directory>src/test/dir</directory>
  </testResource>

And using <resources> tag will effectively copy the specified files in source directory to destination directory, similar to copy-resources goal of maven-resources-plugin.

Then, is there any difference between them?
Will they differ in their functionality in any particular scenario?

Jean-Rémy Revy
  • 5,607
  • 3
  • 39
  • 65
r9891
  • 3,163
  • 1
  • 14
  • 12

1 Answers1

4

The maven-resources-plugin is the one which handles the resources area in your pom.xml file.

The definition of the resources plugin is done in the super pom of maven. You can check which version is used by using:

mvn help:effective-pom

Furthermore the resources goal of the maven-resources-plugin is related to the resources tag in you pom whereas testResources tag is related to testResources goal of the maven-resources-plugin.

The copy-resources goal can be used to separetely copying resources etc. to an output folder if needed.

khmarbaise
  • 92,914
  • 28
  • 189
  • 235
  • Thanks! So if I use `` tag to copy a file from a source directory to destination directory, it is similar to using `maven-resources-plugin` with copy-resources goal, right? Since the maven-resources plugin is responsible for handling resources area in pom.xml. – r9891 Aug 10 '12 at 07:06
  • 1
    It's not only similar it is exactly that you are using the maven-resources-plugin. But in the case resources tag you are using resources goal which is bound to the appropriate phases. See also the docs of the maven-resources-plugin and the resources goal in particular. – khmarbaise Aug 10 '12 at 07:41
  • So the difference could only be in the phase? We can specify different phases with maven-resources-plugin, but not with resources tag. I will search for what is the default phase `` tag work in. Thanks for the help! – r9891 Aug 10 '12 at 07:45
  • However, In a Project with maven and groovy I had to use plugin instead of tag to exclude a folder, otherwise it does not work. – Lucke Aug 14 '21 at 12:01