adding additional resources to a maven pom

前端 未结 4 1649
被撕碎了的回忆
被撕碎了的回忆 2021-01-01 17:00

I have a super pom defined in which I specify a \"resources\" directory for resources. In one of my projects, my pom extends that super pom, and I would like to add an addit

4条回答
  •  天命终不由人
    2021-01-01 17:37

    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.

提交回复
热议问题