I am working in a Maven web project through Eclipse. In the web.xml
, I have a context-param which value should change according the profile I use when I run the Maven.
<context-param>
<param-name>producao</param-name>
<param-value>${ambiente.producao}</param-value>
</context-param>
In the pom file for project I have the following configuration:
<project>
<profiles>
<profile>
<id>prod</id>
<properties>
<ambiente.producao>true</ambiente.producao>
</properties>
</profile>
<profile>
<id>desenv</id>
<properties>
<ambiente.producao>false</ambiente.producao>
</properties>
</profile>
</profiles>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/main/webapp/WEB-INF/</directory>
<filtering>true</filtering>
<includes>
<include>**/web.xml</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.5</version>
<configuration>
<webResources>
<resource>
<filtering>true</filtering>
<directory>src/main/webapp</directory>
<includes>
<include>**/web.xml</include>
</includes>
</resource>
</webResources>
<warSourceDirectory>src/main/webapp</warSourceDirectory>
<webXml>src/main/webapp/WEB-INF/web.xml</webXml>
</configuration>
</plugin>
</plugins>
</build>
</project>
I am using both resources
tag as maven-war-plugin plugin according to the references I found on the internet. However, it did not work as expected. In the Eclipse I run the maven with the goals clean install and as "Profiles" either prod or desenv. After I run the Maven, I observed that in the web.xml
, the ${ambiente.producao}
property is not replaced.
Therefore, I would like to know what I did wrong. Should I use only Filtering resource or the maven-war-plugin?
Thanks,
Rafael Afonso