You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by "Carlos A. Carnero Delgado" <ca...@gmail.com> on 2006/10/30 05:05:56 UTC
Modifying a web application's web.xml at build time
Hello,
using Maven the last couple of weeks with the Jetty plugin has
provided our team with a huge productivity boost. We use the
UrlRewrite servlet[1] in order to generate "pretty" URLs (from a
Spring-backed application.) Currently, during development, this
UrlRewrite servlet (which is loaded using a <filter> tag in web.xml)
is disabled using comments.
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.
Best regards,
Carlos.
--
<nick> grah windows just crashed again, unstable crap.
<yukito> Windows isn't unstable, it's just spontaneous.
[1] http://tuckey.org/urlrewrite/
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Modifying a web application's web.xml at build time
Posted by 向秦贤 <fy...@gmail.com>.
Hi,
There has a good example, jboss-messaging, which use replace stratedgy.
If you wanna check it out, after downloaded a new version, try to see that
file:
${jboss-messaging}/util/release-admin.xml.
Regards,
xy
2006/10/30, Carlos A. Carnero Delgado <ca...@gmail.com>:
>
> Hello,
>
> using Maven the last couple of weeks with the Jetty plugin has
> provided our team with a huge productivity boost. We use the
> UrlRewrite servlet[1] in order to generate "pretty" URLs (from a
> Spring-backed application.) Currently, during development, this
> UrlRewrite servlet (which is loaded using a <filter> tag in web.xml)
> is disabled using comments.
>
> 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.
>
> Best regards,
> Carlos.
> --
> <nick> grah windows just crashed again, unstable crap.
> <yukito> Windows isn't unstable, it's just spontaneous.
>
> [1] http://tuckey.org/urlrewrite/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
--
向秦贤
Re: Modifying a web application's web.xml at build time
Posted by "Carlos A. Carnero Delgado" <ca...@gmail.com>.
On 10/29/06, Wendy Smoak <ws...@gmail.com> wrote:
> ... That is, the auth filter is different in the live environment,
> when running the integration tests, and when running
> 'local' on my workstation.
That's nice, but I think it will not help me. Your method, using
properties, can change which servlet to use. I'd like to turn it on or
off.
Thanks a lot,
Carlos.
--
<nick> grah windows just crashed again, unstable crap.
<yukito> Windows isn't unstable, it's just spontaneous.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Modifying a web application's web.xml at build time
Posted by 向秦贤 <fy...@gmail.com>.
Hi,
Maybe doing conditional subtasks in your case is good idea.
And refering to this segment mentioned before has no bad effect.:)
which use replaceregexp, with in ant, should available in m2.
there are two codes as follows, one in firefox. and one in text.
Regards,
Qinxian
<!-- slim down jboss-service.xml -->
−
<replaceregexp file="${jboss.home}/server/${config.name}/conf/jboss-
service.xml" flags="s">
<regexp pattern="(\x3cmbean
code=\x22org.jboss.management.j2ee.LocalJBossServerDomain\x22.*jboss:service=CorbaORB\x3c/attribute\x3e[
\t\n\r]*\x3c/mbean\x3e)"/>
<substitution expression=""/>
</replaceregexp>
−
<replaceregexp file="${jboss.home}/server/${config.name}/conf/jboss-
service.xml" flags="s">
<regexp pattern="(\x3cmbean
code=\x22org.jboss.util.property.jmx.SystemPropertyClassValue\x22.*
org.jboss.system.JBossRMIClassLoader\x3c/attribute\x3e[
\t\n\r]*\x3c/mbean\x3e)"/>
<substitution expression=""/>
</replaceregexp>
−
<replaceregexp file="${jboss.home}/server/${config.name}/conf/jboss-
service.xml" flags="s">
<regexp pattern="(\x3cmbean
code=\x22org.jboss.web.WebService\x22.*\x3cdepends
optional-attribute-name=\x22ThreadPool\x22[
\t\n\r]*proxy-type=\x22attribute\x22\x3ejboss.system:service=ThreadPool\x3c/depends\x3e[
\t\n\r]*\x3c/mbean\x3e)"/>
<substitution expression=""/>
</replaceregexp>
−
<replaceregexp file="${jboss.home}/server/${config.name}/conf/jboss-
service.xml" flags="s">
<regexp pattern="(\x3cmbean
code=\x22org.jboss.tm.usertx.server.ClientUserTransactionService\x22.*\x3cdepends\x3ejboss:service=invoker,type=jrmp\x3c/depends\x3e[
\t\n\r]*\x3c/mbean\x3e[ \t\n\r]*\x3c/depends\x3e[ \t\n\r]*\x3c/mbean\x3e)"/>
<substitution expression=""/>
</replaceregexp>
−
<replaceregexp file="${jboss.home}/server/${config.name}/conf/jboss-
service.xml" flags="s">
<regexp pattern="(\x3cmbean
code=\x22org.jboss.invocation.pooled.server.PooledInvoker\x22.*\x3cdepends
optional-attribute-name=\x22TransactionManagerService\x22\x3ejboss:service=TransactionManager\x3c/depends\x3e[
\t\n\r]*\x3c/mbean\x3e)"/>
<substitution expression=""/>
</replaceregexp>
−
<replaceregexp file="${jboss.home}/server/${config.name}/conf/jboss-
service.xml" flags="s">
<regexp pattern="(\x3cmbean
code=\x22org.jboss.ejb.plugins.cmp.jdbc.metadata.MetaDataLibrary\x22.*name=\x22jboss.jdbc:service=metadata\x22/\x3e)"/>
<substitution expression=""/>
</replaceregexp>
<!-- customize login-config.xml -->
−
<replaceregexp file="${jboss.home}/server/${config.name}/conf/login-
config.xml" flags="s">
<regexp pattern="(\x3cpolicy\x3e)"/>
<substitution expression="\1 <application-policy name =
"messaging"> <authentication><login-module code = "
org.jboss.security.auth.spi.UsersRolesLoginModule" flag =
"required" > <module-option name =
"unauthenticatedIdentity">guest</module-option> <module-option name
= "usersProperties">messaging-users.properties</module-option>
<module-option name =
"rolesProperties">messaging-roles.properties</module-option>
</login-module></authentication></application-policy>"/>
</replaceregexp>
−
<replaceregexp file="${jboss.home}/server/${config.name}/conf/login-
config.xml" flags="s">
<regexp pattern="(\x3cpolicy\x3e)"/>
<substitution expression="\1 <application-policy name =
"messaging"> <authentication><login-module code = "
org.jboss.security.auth.spi.UsersRolesLoginModule" flag =
"required" > <module-option name =
"unauthenticatedIdentity">guest</module-option> <module-option name
= "usersProperties">messaging-users.properties</module-option>
<module-option name =
"rolesProperties">messaging-roles.properties</module-option>
</login-module></authentication></application-policy>"/>
</replaceregexp>
−
<replaceregexp file="${jboss.home}/server/${config.name}/conf/login-
config.xml" flags="s">
<regexp pattern="(\x3capplication-policy name = \x22jbossmq\x22\x3e.*FROM
JMS_ROLES WHERE USERID=.\x3c/module-option\x3e[
\t\n\r]*\x3c/login-module\x3e[ \t\n\r]*\x3c/authentication\x3e[
\t\n\r]*\x3c/application-policy\x3e)"/>
<substitution expression=""/>
in text:
<target name="create-standalone-server-config" depends="validate-jboss,
validate-messaging-artifact"
description="Creates a standalone Messaging server configuration
based on a default JBoss instance">
<echo message="Creating Standalone Messaging configuration '${
config.name}' for ${jboss.home} based on ${messaging.artifact.name}"/>
<mkdir dir="${jboss.home}/server/${config.name}/conf"/>
<mkdir dir="${jboss.home}/server/${config.name}/lib"/>
<mkdir dir="${jboss.home}/server/${config.name}/deploy"/>
<copy todir="${jboss.home}/server/${config.name}/conf">
<fileset dir="${jboss.home}/server/default/conf">
<include name="jboss-service.xml"/>
<include name="jndi.properties"/>
<include name="log4j.xml"/>
<include name="login-config.xml"/>
<include name="props/**"/>
<include name="xmdesc/**"/>
</fileset>
</copy>
<copy todir="${jboss.home}/server/${config.name}/deploy">
<fileset dir="${jboss.home}/server/default/deploy">
<include name="hsqldb-ds.xml"/>
<include name="jboss-local-jdbc.rar"/>
<include name="jbossjca-service.xml"/>
<include name="jbossweb-tomcat6.sar/**"/>
<include name="jmx-console.war/**"/>
<include name="jmx-invoker-service.xml"/>
<include name="management/**"/>
<include name="properties-service.xml"/>
</fileset>
</copy>
<copy todir="${jboss.home}/server/${config.name}/lib">
<fileset dir="${jboss.home}/server/default/lib">
<include name="commons*.jar"/>
<include name="hsqldb*.jar"/>
<include name="javax.servlet*.jar"/>
<include name="jboss-common-jdbc-wrapper.jar"/>
<include name="jboss-j2ee.jar"/>
<include name="jboss-jca.jar"/>
<include name="jboss-management.jar"/>
<include name="jboss-monitoring.jar"/>
<include name="jboss-transaction.jar"/>
<include name="jboss.jar"/>
<include name="jbosssx.jar"/>
<include name="jmx-adaptor-plugin.jar"/>
<include name="jnpserver.jar"/>
<include name="log4j.jar"/>
<include name="properties-plugin.jar"/>
</fileset>
</copy>
<!-- slim down jboss-service.xml -->
<replaceregexp file="${jboss.home}/server/${config.name}/conf/jboss-
service.xml" flags="s">
<regexp pattern="(\x3cmbean
code=\x22org.jboss.management.j2ee.LocalJBossServerDomain\x22.*jboss:service=CorbaORB\x3c/attribute\x3e[
\t\n\r]*\x3c/mbean\x3e)"/>
<substitution expression=""/>
</replaceregexp>
<replaceregexp file="${jboss.home}/server/${config.name}/conf/jboss-
service.xml" flags="s">
<regexp pattern="(\x3cmbean
code=\x22org.jboss.util.property.jmx.SystemPropertyClassValue\x22.*
org.jboss.system.JBossRMIClassLoader\x3c/attribute\x3e[
\t\n\r]*\x3c/mbean\x3e)"/>
<substitution expression=""/>
</replaceregexp>
<replaceregexp file="${jboss.home}/server/${config.name}/conf/jboss-
service.xml" flags="s">
<regexp pattern="(\x3cmbean
code=\x22org.jboss.web.WebService\x22.*\x3cdepends
optional-attribute-name=\x22ThreadPool\x22[
\t\n\r]*proxy-type=\x22attribute\x22\x3ejboss.system:service=ThreadPool\x3c/depends\x3e[
\t\n\r]*\x3c/mbean\x3e)"/>
<substitution expression=""/>
</replaceregexp>
<replaceregexp file="${jboss.home}/server/${config.name}/conf/jboss-
service.xml" flags="s">
<regexp pattern="(\x3cmbean
code=\x22org.jboss.tm.usertx.server.ClientUserTransactionService\x22.*\x3cdepends\x3ejboss:service=invoker,type=jrmp\x3c/depends\x3e[
\t\n\r]*\x3c/mbean\x3e[ \t\n\r]*\x3c/depends\x3e[ \t\n\r]*\x3c/mbean\x3e)"/>
<substitution expression=""/>
</replaceregexp>
<replaceregexp file="${jboss.home}/server/${config.name}/conf/jboss-
service.xml" flags="s">
<regexp pattern="(\x3cmbean
code=\x22org.jboss.invocation.pooled.server.PooledInvoker\x22.*\x3cdepends
optional-attribute-name=\x22TransactionManagerService\x22\x3ejboss:service=TransactionManager\x3c/depends\x3e[
\t\n\r]*\x3c/mbean\x3e)"/>
<substitution expression=""/>
</replaceregexp>
<replaceregexp file="${jboss.home}/server/${config.name}/conf/jboss-
service.xml" flags="s">
<regexp pattern="(\x3cmbean
code=\x22org.jboss.ejb.plugins.cmp.jdbc.metadata.MetaDataLibrary\x22.*name=\x22jboss.jdbc:service=metadata\x22/\x3e)"/>
<substitution expression=""/>
</replaceregexp>
<!-- customize login-config.xml -->
<replaceregexp file="${jboss.home}/server/${config.name}/conf/login-
config.xml" flags="s">
<regexp pattern="(\x3cpolicy\x3e)"/>
<substitution expression="\1 <application-policy name =
"messaging">
<authentication><login-module code =
"org.jboss.security.auth.spi.UsersRolesLoginModule"
flag = "required" >
<module-option name =
"unauthenticatedIdentity">guest</module-option>
<module-option name = "usersProperties">messaging-
users.properties</module-option>
<module-option name = "rolesProperties">messaging-
roles.properties</module-option>
</login-module></authentication></application-policy>"/>
</replaceregexp>
<replaceregexp file="${jboss.home}/server/${config.name}/conf/login-
config.xml" flags="s">
<regexp pattern="(\x3cpolicy\x3e)"/>
<substitution expression="\1 <application-policy name =
"messaging">
<authentication><login-module code =
"org.jboss.security.auth.spi.UsersRolesLoginModule"
flag = "required" >
<module-option name =
"unauthenticatedIdentity">guest</module-option>
<module-option name = "usersProperties">messaging-
users.properties</module-option>
<module-option name = "rolesProperties">messaging-
roles.properties</module-option>
</login-module></authentication></application-policy>"/>
</replaceregexp>
>
--
向秦贤
Re: Modifying a web application's web.xml at build time
Posted by Wendy Smoak <ws...@gmail.com>.
On 10/29/06, Carlos A. Carnero Delgado <ca...@gmail.com> 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: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org