I am trying to have some variable properties value and use Maven profile to get to the correct output. I've done this for my hibernate xml, log4j.properties and didnt have problem.
So it worked for me in project#1 where I have bunch of files under /src/main/resources. And I set up properties and resource filtering in maven as follow:
<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>
The above worked with no problem. However, in my Project#2 - I have some files that have variable properties, but they are under /src/main/webapp/WEB-INF - I do the same as above, except for the directory to point to the WEB-INF and it does not work. I tried on project #2 for the file to go under /src/main/resources and it worked.
So seems to me resource filtering have problem when the file is under /src/main/webapp/WEB-INF but I need the file to be there so it goes to the WEB-INF folder when the war is generated.
Does anyone have a pointer as to how to do this?
Here's the following snipet from the pom.xml that doesnt work (the 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>
I also had this problem; I suspect the main <resources>
section of the POM is ignored by the war plug-in, hence I've come up with configuring the plug-in 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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With