Filtering maven variable properties

I am trying to get some values โ€‹โ€‹of property variables and use the Maven profile to get the correct output. I did this for my hibernate xml, log4j.properties and did not have a problem.

So, this worked for me in project # 1, where I have a bunch of files in / src / main / resources. And I configured the properties and resource filtering in maven as follows:

<properties> <log.level>DEBUG</log.level> </properties> <profiles> <profile> <id>production</id> <properties> <log.level>INFO</log.level> </properties> </profile> </profiles> <build> <resources> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> </resource> </resources> </build> 

Above worked without problems. However, in my project # 2 - I have files with variable properties, but they are under / src / main / webapp / WEB -INF - I do the same as above, except that the directory points to WEB-INF and it will not work. I tried project # 2 so that the file is under / src / main / resources and it works.

It seems to me that resource filtering has problems when the file is under / src / main / webapp / WEB -INF, but I need the file to be there, so it gets into the WEB-INF folder when creating a war.

Does anyone have a pointer on how to do this?

Here is the following snipet from pom.xml which does not work (resource filtering is completely ignored)

 <properties> <wsdl.url>http://stage/wsdl-url</wsdl.url> </properties> <profiles> <profile> <id>production</id> <properties> <wsdl.url>http://prod/wsdl-url</wsdl.url> </properties> </profile> </profiles> <build> <resources> <resource> <directory>src/main/webapp/WEB-INF</directory> <filtering>true</filtering> </resource> </resources> </build> 
+6
source share
1 answer

I also had this problem; I suspect that the main <resources> POM section is ignored by the military plug-in, so I decided to configure the plugin directly:

 <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <configuration> <filters> <filter>filter.properties</filter> </filters> <webResources> <resource> <directory>WebContent/WEB-INF</directory> <filtering>true</filtering> <targetPath>WEB-INF</targetPath> </resource> </webResources> </configuration> </plugin> 
+5
source

Source: https://habr.com/ru/post/903114/


All Articles