You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Dhruva Reddy <dr...@sapient.com> on 2008/01/04 14:26:34 UTC

Filtering with Maven 2

I am working with a Java web application and trying to filter resources for inclusion in the WAR file.  This application runs in Tomcat.

There is one file in particular, context.xml, which resides in src/main/webapp/META-INF/context.xml.  I have the following in pom.xml:

<build>
  ...
  <filters>
    <filter>${user.home}/.m2/container.properties</filter>
  </filters>
  <resources>
    <resource>
      <directory>src/main/webapp</directory>
      <filtering>true</filtering>
    </resource>
  </resources>
  ...

Without the above, the WAR contains META-INF/context.xml, as is necessary.  However, when I have filtering turned on as above, I find the following in the WAR:

META-INF/context.xml (this copy is not filtered)
WEB-INF/classes/META-INF/context.xml (this copy is filtered as expected, but of course the file is in the wrong place)

I am using Maven 2.0.8.  Is it possible to filter this way, or is there something else I need to do for WAR files (like look at the WAR plugin)?

Thanks,
Dhruva

Re: Filtering with Maven 2

Posted by Stephen Connolly <st...@gmail.com>.
look at <webResources> in the maven-war-plugin configuration section

On Jan 4, 2008 1:26 PM, Dhruva Reddy <dr...@sapient.com> wrote:

> I am working with a Java web application and trying to filter resources
> for inclusion in the WAR file.  This application runs in Tomcat.
>
> There is one file in particular, context.xml, which resides in
> src/main/webapp/META-INF/context.xml.  I have the following in pom.xml:
>
> <build>
>  ...
>  <filters>
>    <filter>${user.home}/.m2/container.properties</filter>
>  </filters>
>  <resources>
>    <resource>
>      <directory>src/main/webapp</directory>
>      <filtering>true</filtering>
>    </resource>
>  </resources>
>  ...
>
> Without the above, the WAR contains META-INF/context.xml, as is necessary.
>  However, when I have filtering turned on as above, I find the following in
> the WAR:
>
> META-INF/context.xml (this copy is not filtered)
> WEB-INF/classes/META-INF/context.xml (this copy is filtered as expected,
> but of course the file is in the wrong place)
>
> I am using Maven 2.0.8.  Is it possible to filter this way, or is there
> something else I need to do for WAR files (like look at the WAR plugin)?
>
> Thanks,
> Dhruva
>