adding additional resources to a maven pom

See build-helper-maven-plugin's usage page.


The behaviour you've described is expected.

Remember that your super POM is inheriting from Maven's default POM and pretty much any plugin that you define in your pom effectively overrides the setting in the default POM. As an example, to enable filtering on the default resource, you have to specify the path in your POM. You do this:

<resources>
  <resource>
    <directory>src/main/resources</directory>
    <filtering>true</filtering>
  </resource>
</resources>

Not this:

<resources>
  <resource>
    <filtering>true</filtering>
  </resource>
</resources>

The default directory does not bubble up for you, even if you've specified it there. There might be a special MOJO to do it for you, but I couldn't find one.


I know this question is pretty old by now but maybe someone will find this usefull:

You can easily do that using the maven resource plugin.

Basically, what it does by default (invoking the resources:resources goal) is moving the content of all directories listed in the build/resources section using the declared filter into the ${project.build.outputDirectory} If you now want to add some additional resources without influencing these sections, you can simply move the resources there yourself. An no, this does not mean drag and dropping it there.

The Maven Resources Pluginprovides a goal named resources:copy-resources that does exactly that for you: Coping files using filters from one place to another, or as the plugin doc states:

You can use the mojo copy-resources to copy resources which are not in the default maven layout or not declared in the build/resources element and attach it to a phase

The obvious advantage compared to the build-helper, that is suggested in other solutions, is that, while the build-helper is only able to take action during the generate-sources phase, the resources plugin works in any phase. (Though it would be wise to execute it before the packaging stage)

A full example on how to use this is provided here, as part of the plugins project page.

What this does is coping the content of the not listed resource directory "src/non-packaged-resources" into "${basedir}/target/extra-resources". But since the jar plugin (that creates the jar archive) basically creates a zip archive of the directory "${project.build.outputDirectory}", you may want to put it there.