views:

310

answers:

1

Hi all, 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.

A: 

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

Pascal Thivent
Hey pascal first of all thanks for your interest. Actually I need to use multi-module project that is why i am using pom packaging type. Also the file to be filtered is not present in src/main/resources folder, it is in the root of parent folder. I cant change the hierarchy of the files that is why i am going through all these problems.
Harmit
@Hamit The pom packaging is fine (and actually required) for aggregating modules of your multi-modules setup but I'm afraid you won't be able to filter resources in such modules. What I don't get is how these "filtered" resources are supposed to be used. What are you going to do with them since they are in a module of type pom?
Pascal Thivent
@Pascal: These resources are actually property files. These files(file1 and file2) will be copied to remote location along with the other files generated after filtering and compilation. These configuration files are also used by sub-modules. I need to set the values in these files manually, so i was thinking of using filtering. But I am afraid that there is any way to do so.
Harmit