开发者

Maven2 applying filtering to the file under pom type packaging

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
开发者_JS百科

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.


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.


To have Maven filter resources when copying, set filtering to true for the resource directory in your pom.xml:

<project>
  ...
  <build>
    <resources>
      <resource>
        <directory>src/main/resources</directory>
        <filtering>true</filterineg>
      </resource>
    </resources>
  </build>
</project>

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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜