Continuing my prior question (Maven: how to fill a variable in web.xml file), I realized that the values written in web.xml are not passed to the deployed web.xml.
Let me show what is happening: I am running a web application in Tomcat through WTP Eclipse. In the web.xml, I have this context-param:
<context-param>
<param-name>producao</param-name>
<param-value>${ambiente.producao}</param-value>
</context-param>
The ambiente.producao is filled according to Maven profile chosen:
<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>
Also, I have a ServletContextListener implementation which will print the value of the producao param:
public void contextInitialized(ServletContextEvent event) {
logger.warn(event.getServletContext().getInitParameter("producao"));
}
Thanks to Fred Bricon tip, I was able make the Maven fill correctly the ambiente.producao variable in the web.xml copied to the target directory.
However, when I start the Tomcat and print the the producao init param, It is showed ${ambiente.producao}. Actually, when I open the web.xml present in the directory [WORKSPACE_DIR]/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/sinpo-web/WEB-INF, the producao is not filled as it should be. It was like Eclipse (or WTP or Maven) had chosen the original file instead of filled file.
Therefore, I ask if there is some missing configuration needed to make the Maven (or Eclipse) publish using the files in target directory instead the original file.
Thanks,
Rafael Afonso