How to ignore missing filter file error on pom.xml in Eclipse when using resource filtering?

I have a multi-module project similar to this:

parent | +-- childA | +-- src/main/resources/application.properties | +-- childB +-- src/main/resources/application.properties +-- src/main/filters/filter.properties 

I am filtering application.properties both childA and childB using filter.properties in childB.

I followed this strategy to attach the filter file to the childB artifact, and then unzip it to the childA target:

 childA/target/filters/filter.properties 

childA has resource filtering as follows:

 <build> <filters> <filter>target/filters/filter.properties</filter> </filters> </build> 

Eclipse puts the error in childA/pom.xml :

Error loading properties file 'Parent \ childΓ’ \ target \ filters \ filter.properties' (Org.apache.maven.plugins: Maven-resources-plugin: 3.0.2: copy-resources: default resources: process-resources)

The filter file is available when I create the application, so it does not concern me here.

How can I update pom.xml childA to permanently ignore this error?

+7
java eclipse maven maven-3 maven-resources-plugin
source share
2 answers

The problem disappeared after upgrading from Eclipse Luna to Neon.

+1
source share

You took this filter.properties file from the target folder. This is the wrong way. You should think about this src/main/filters/filter.properties .

 <filters> <filter>${basedir}/src/main/filters/filter.properties</filter> </filters> 

For more information, you can go through this tutorial: Error loading Maven properties file

UPDATE # 2:

For my part, you can save the properties file in your parent. Then give a link to both ChildA and childB using the following filter. Hope this works.

 <filters> <filter>${basedir}/src/main/filters/filter.properties</filter> </filters> 

UPDATE # 3:

Stephen Conolly said in a post as shown below:

Think about what happens when your project is listed as a dependency. If you specified your dependencies using mojo to pull these from the .properties file on disk, Maven is not able to replicate this when your dependency has been pulled from the Maven repository. So Maven cannot determine the dependencies. That way, he could never work.

What you can do is use an external system (e.g. ANT) to generate pom.xml from the template with the replaced versions in this file. And then use the instantiated template.

Resource Link: fooobar.com/questions/485779 / ...

A similar question is asked here: Maven2 property indicating the parent directory

Dennis Lundbarg said this problem as an anti-pattern in this post :

Linking to files in another module using relative paths is an anti-model. One of the reasons for this is that it will break your assembly if you use an assembly server such as Jenkins. The build server will check each module in a separate folder, which is not in the same folder structure as your project.

The best way to share resources, such as configuration files, is to store them in an archive that is deployed to your repository. when this is done, you can use it as a dependency, which makes the resources available on the way to the class, or use the dependency: unzip the target to extract the files to where you want.

0
source share

All Articles