I have inherited a project from another developer and there is a bit in the pom.xml
that I don't quite understand. It's as follows:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>filter</id>
<phase>generate-resources</phase>
<goals>
<goal>resources</goal>
</goals>
</execution>
</executions>
</plugin>
Can someone shed some light as to what it's trying to do? I think it's saying, "do filtering when running ANY generate-resources phase". Is this correct?
No, your interpretation is incorrect.
This is declaring an execution for the maven-resources-plugin
. This execution has an id of filter
but this is just a technical identifier and it has no involvement in the build itself. This execution is bound to the generate-resources
phase of the default life cycle and it invokes the resources
goal of that plugin.
Having said that, this is really strange and may be completely useless. By default, the resources
goal of the maven-resources-plugin
is already invoked in the default lifecycle in the process-resources
phase (which is right after the generate-resources
phase). What this goal does is to copy all of the resources of the project (i.e. what is under src/main/resources
by default) to the main output directory (i.e. the target
folder by default). Hence, this task will be performed twice: once in the generate-resources
phase (per the execution in your POM) and another time in the process-resources
phase by default.