On 10/29/06, Carlos A. Carnero Delgado <[EMAIL PROTECTED]> wrote:

Is there a way of modifying the web.xml at build time using Maven
profiles? Are profiles the solution?

I think that the ideal solution would involve maintaining a single
web.xml that could be modified at build time.

Sure.  I do this with profiles such as 'env-live' 'env-test' and
'env-local'.  That is, the auth filter is different in the live
environment, when running the integration tests, and when running
'local' on my workstation.

  <filter-mapping>
     <filter-name>${auth.filter.name}</filter-name>
     <url-pattern>*.do</url-pattern>
  </filter-mapping>

For example,

      <profile>
         <id>env-local</id>
         <activation>
            <property>
               <name>env</name>
               <value>local</value>
            </property>
         </activation>
         <properties>
            <auth.filter.name>localhostFilter</auth.filter.name>
         </properties>
      </profile>

Here's what the plugin config looks like.  I put web.xml in a separate
directory so I could filter it and nothing else.  This may not be
necessary anymore, I think I started doing it with an earlier verison
of the war plugin.  Adjust as necessary. :)

        <plugin>
            <artifactId>maven-war-plugin</artifactId>
            <configuration>
                <webResources>
                    <webResource>

<directory>${basedir}/src/main/webapp-filtered</directory>
                        <filtering>true</filtering>
                        <includes>
                            <include>**/*.xml</include>
                        </includes>
                    </webResource>
                </webResources>
            </configuration>
        </plugin>

I think I had problems trying to filter in the <!-- and --> for
comments, but then I realized that rather than trying to comment
various things in and out, I should just filter in the name of the
filter I wanted.

--
Wendy

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to