Maven2对pom类型打包下的文件应用过滤
我是 Maven 新手。我想在多模块项目中使用过滤。父pom的打包类型设置为pom。项目的结构如下:
pom.xml
|
|______MODULE1
| |
| pom.xml
| File1_needed_to_be_filtered
|
File2_needed_to_be_filtered
请注意,Module1 也是多模块项目。 所以请告诉我如何对 file1 和 file2 应用过滤。如果我对file1应用过滤,那么处理后的文件将存储在哪里(因为打包类型为pom的pom文件不会创建任何名为target的文件夹!) 请帮助我,因为这对我来说非常重要,而且这个问题在互联网上没有其他地方得到解决。
I am new to maven. I want to use filtering in a multimodule project. The packaging type of the parent pom is set to pom. The structure of the project is as follows:
pom.xml
|
|______MODULE1
| |
| pom.xml
| File1_needed_to_be_filtered
|
File2_needed_to_be_filtered
Please note that Module1 is also multimodule project.
So please tell me how can I apply filtering to file1 and file2. And if i apply filtering to file1, then where will the processed file be stored (Since pom file whose packaging type is pom do not create any folder named target!)
Please help me as this is very critical to me and this issue is addressed nowhere else on the internet.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 maven- assembly-plugin - 具有“dir”格式(尽管如果有多个文件,则将其作为某种存档可能是有意义的)。 描述符格式允许您进行过滤。这应该适用于您上面描述的 pom 和文件层次结构。
但是,我建议将它们放入兄弟模块而不是父模块中。这将逻辑排除在聚合器 pom 之外,并且(一旦开始这样做)您可能会决定使用程序集将它们与其他组件一起分发会更容易,无论如何您都需要一个模块。
You could use the maven-assembly-plugin - with a 'dir' format (although if there is ever more than one file, it might make sense to make it an archive of some kind). The descriptor format allows you to filter. This should work with the pom and file hierarchy you describe above.
However, I would recommend putting these in sibling modules instead of the parent. This keeps the logic out of your aggregator pom, and (once you start doing that) you might decide it's easier to use the assembly to distribute them along with your other components, which you'd want a module for anyway.
要让 Maven 在复制时过滤资源,请在 pom.xml 中将资源目录的过滤设置为
true
:但如果要过滤资源,请不要将它们放在具有打包类型的项目中
pom
,这没有意义(因为你给自己的原因)。实际上,我不明白你想要实现什么(因为你知道这不是事情的运作方式)。To have Maven filter resources when copying, set filtering to
true
for the resource directory in your pom.xml:But if you want to filter resources, don't put them in a project with a packaging of type
pom
, this doesn't make sense (for the reason you gave yourself). Actually, I don't understand what you're trying to achieve (since you know this is not how things work).