Maven 在多模块项目中复制资源
我的需求非常基本,但我找不到任何干净的答案:我只需要能够在多模块项目中分发资源。
让我们以 LICENSE 文件为例,我在此假设所有模块都相同。我不喜欢将其手动复制到每个模块中,因为文件可能会随着时间的推移而改变。我也不想静态链接到项目文件夹外部的资源(即使使用相对路径),因为模块化结构也可能会发生变化。
是否有任何插件可以用来可靠地保证每个模块都获得所需的文件?同样可以接受的是,通过利用父项目的 POM 来获取此类副本,或者由模块化层次结构中的超级项目直接执行。
My need is pretty basic but I could not find any clean answer to it: I simply need to be able to distribute a resource in a multi-module project.
Let us consider for example the LICENSE file, which I hereby assume to be the same for all modules. I prefer not to manually copy it into each and every module because the file could change over time. I also prefer not to statically link to resources (even if using relative paths) outside the project folder, because the modular structure can possibly change too.
Is there any plugin that can be used to robustly guarantee that each module is given the required file? It would be equally acceptable for such copy to be obtained by exploiting the POM of the parent project or directly performed by the super project in the modular hierarchy.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用程序集和依赖插件..您偶然发现了该链接吗?
http://www.sonatype.com/people/2008/04/how-to-share-resources-across-projects-in-maven/" sonatype.com/people/2008/04/how-to-share-resources-across-projects-in-maven/
它描述了该选项..它从 2008 年开始,但 Maven 是已经有一段时间了..所以我想它或多或少是最新的
编辑关于评论
另一个选项是maven-remote-resources-plugin。
有关更详细的示例,请参阅:
http://maven.apache.org/plugins /maven-remote-resources-plugin/examples/sharing-resources.html
由于他们的介绍本身就说明了一切,我引用(maven.apache.org)
you could use the assembly and the dependency plugins.. did you stumble over that link?
http://www.sonatype.com/people/2008/04/how-to-share-resources-across-projects-in-maven/
it describes that option ..its from 2008, but maven is around for quite some time.. so I guess its more or less up to date
edit regarding comment
Another option is the maven-remote-resources-plugin.
For a more detailed example see:
http://maven.apache.org/plugins/maven-remote-resources-plugin/examples/sharing-resources.html
Since their intro speaks actually for itself, I quote (maven.apache.org)