You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Martin Hoeller <ma...@xss.co.at> on 2013/10/18 09:40:24 UTC

Default value for properties depending on active profile

Hi!

Here is the short version of what I want: I've got a JEE6 webapp with a
web.xml file, where the context-parameter facelets.DEVELOPMENT should be
enabled in development mode but disabled for releases.

My idea to solve this problem is as follows:

1) Define the context parameter in web.xml like this

   <context-param>
      <param-name>facelets.DEVELOPMENT</param-name>
      <param-value>${devel.mode}</param-value>
   </context-param>

2) Configure the maven-resources-plugin to filter web.xml and replace
   ${devel.mode} with the actual value.

3) Make devel.mode a maven-property with it's value being 'true' for
   normal builds and 'false' for a release build.

My questions is, is this a recommended way or should I solve this task
differently?

If this is ok, how could I initialize devel.mode correctly? I was
thinking about a default initialization in the pom.xml and an alternative
initialization via the release-profile. My qualms about this approach
are, that profiles are considered evil for most use-cases.

Many thanks in advance,
- martin

Re: Default value for properties depending on active profile

Posted by Stephen Connolly <st...@gmail.com>.
https://issues.jboss.org/browse/AS7-4296


On 18 October 2013 11:10, Martin Hoeller <ma...@xss.co.at> wrote:

> On 18 Okt 2013, Adrien Rivard wrote:
>
> > Most server allow you to externally override context-param without
> > modifying the war
>
> I can't find anything for JBoss 7, which is the application-server i use.
> If this is not possible, your suggestion doesn't work for me :(
>
> > (which would be even worst than using profiles IMO)
>
> Fully ACK.
>
> - martin
>

Re: Default value for properties depending on active profile

Posted by Martin Hoeller <ma...@xss.co.at>.
On 18 Okt 2013, Adrien Rivard wrote:

> Most server allow you to externally override context-param without
> modifying the war

I can't find anything for JBoss 7, which is the application-server i use.
If this is not possible, your suggestion doesn't work for me :(

> (which would be even worst than using profiles IMO)

Fully ACK.

- martin

Re: Default value for properties depending on active profile

Posted by Adrien Rivard <ad...@gmail.com>.
Most server allow you to externally override context-param without
modifying the war (which would be even worst than using profiles IMO)
see
http://tomcat.apache.org/tomcat-6.0-doc/config/context.html#Context_Parameters
for
tomcat




On Fri, Oct 18, 2013 at 10:45 AM, Martin Hoeller <ma...@xss.co.at> wrote:

> On 18 Okt 2013, Adrien Rivard wrote:
> > You should just override the context-param when deploying on the real
> > production server.
>
> What do you mean by "override"?
>
> You don't want me to extract the released WAR artifact (which is actually
> included in an EAR), modify the web.xml and repackage it. Do you?
>
> - martin
>



-- 
Adrien Rivard

Re: Default value for properties depending on active profile

Posted by Martin Hoeller <ma...@xss.co.at>.
On 18 Okt 2013, Adrien Rivard wrote:
> You should just override the context-param when deploying on the real
> production server.

What do you mean by "override"?

You don't want me to extract the released WAR artifact (which is actually
included in an EAR), modify the web.xml and repackage it. Do you?

- martin

Re: Default value for properties depending on active profile

Posted by Adrien Rivard <ad...@gmail.com>.
Hi,

You should just override the context-param when deploying on the real
production server.




On Fri, Oct 18, 2013 at 9:40 AM, Martin Hoeller <ma...@xss.co.at> wrote:

> Hi!
>
> Here is the short version of what I want: I've got a JEE6 webapp with a
> web.xml file, where the context-parameter facelets.DEVELOPMENT should be
> enabled in development mode but disabled for releases.
>
> My idea to solve this problem is as follows:
>
> 1) Define the context parameter in web.xml like this
>
>    <context-param>
>       <param-name>facelets.DEVELOPMENT</param-name>
>       <param-value>${devel.mode}</param-value>
>    </context-param>
>
> 2) Configure the maven-resources-plugin to filter web.xml and replace
>    ${devel.mode} with the actual value.
>
> 3) Make devel.mode a maven-property with it's value being 'true' for
>    normal builds and 'false' for a release build.
>
> My questions is, is this a recommended way or should I solve this task
> differently?
>
> If this is ok, how could I initialize devel.mode correctly? I was
> thinking about a default initialization in the pom.xml and an alternative
> initialization via the release-profile. My qualms about this approach
> are, that profiles are considered evil for most use-cases.
>
> Many thanks in advance,
> - martin
>



-- 
Adrien Rivard