You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Jeff <pr...@gmail.com> on 2011/01/20 07:52:22 UTC

Help referencing profile properties/attributes...

I'm new to Maven and am building a POM with profiles.  I want to be able to
set a system property that contains the value of the current profile(s).

Currently I have multiple profiles that each relate to different web app
servers (dev, test, staging, etc.) in our dev/test environment.  I want the
profile (via the surefire plugin) to set a system property called "config"
that can be read during the "test" goal to change which web app server to
use (via property file).

Currently the value of the "config" system property is equivalent to the
value of the profile id.  Is there a syntax in the POM for referencing the
id of the profile that is in the parent chain of the property being set?

For example, in the profile below, can I reference the profile id in order
to retrieve the value "staging"?  I've tried ${profile.id}, ${id}, but they
don't work.

<profiles>
    <profile>
      *<id>staging</id>
*    ...
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.7.1</version>
            <configuration>
              <skip>false</skip>
              <systemPropertyVariables>
                *<config>${profile.id}</config>
*        ...

   </profile>
</profiles>

Thanks!!

-- 
Jeff Vincent
predatorvi@gmail.com
See my LinkedIn profile at:
http://www.linkedin.com/in/rjeffreyvincent

Re: Help referencing profile properties/attributes...

Posted by Ron Wheeler <rw...@artifact-software.com>.
We have had long discussions about why profiles are not the right way to 
deal with environment/deployment issues.

Ron

On 20/01/2011 3:05 AM, Anders Hammar wrote:
> Not that I know of, no.
>
> In your example, why don't you just specify the value ('staging') in the
> confgiuration of the surefire plugin?
>
> /Anders
>
> On Thu, Jan 20, 2011 at 07:52, Jeff<pr...@gmail.com>  wrote:
>
>> I'm new to Maven and am building a POM with profiles.  I want to be able to
>> set a system property that contains the value of the current profile(s).
>>
>> Currently I have multiple profiles that each relate to different web app
>> servers (dev, test, staging, etc.) in our dev/test environment.  I want the
>> profile (via the surefire plugin) to set a system property called "config"
>> that can be read during the "test" goal to change which web app server to
>> use (via property file).
>>
>> Currently the value of the "config" system property is equivalent to the
>> value of the profile id.  Is there a syntax in the POM for referencing the
>> id of the profile that is in the parent chain of the property being set?
>>
>> For example, in the profile below, can I reference the profile id in order
>> to retrieve the value "staging"?  I've tried ${profile.id}, ${id}, but
>> they
>> don't work.
>>
>> <profiles>
>>     <profile>
>>       *<id>staging</id>
>> *    ...
>>       <build>
>>         <plugins>
>>           <plugin>
>>             <groupId>org.apache.maven.plugins</groupId>
>>             <artifactId>maven-surefire-plugin</artifactId>
>>             <version>2.7.1</version>
>>             <configuration>
>>               <skip>false</skip>
>>               <systemPropertyVariables>
>>                 *<config>${profile.id}</config>
>> *        ...
>>
>>    </profile>
>> </profiles>
>>
>> Thanks!!
>>
>> --
>> Jeff Vincent
>> predatorvi@gmail.com
>> See my LinkedIn profile at:
>> http://www.linkedin.com/in/rjeffreyvincent
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Help referencing profile properties/attributes...

Posted by Anders Hammar <an...@hammar.net>.
Not that I know of, no.

In your example, why don't you just specify the value ('staging') in the
confgiuration of the surefire plugin?

/Anders

On Thu, Jan 20, 2011 at 07:52, Jeff <pr...@gmail.com> wrote:

> I'm new to Maven and am building a POM with profiles.  I want to be able to
> set a system property that contains the value of the current profile(s).
>
> Currently I have multiple profiles that each relate to different web app
> servers (dev, test, staging, etc.) in our dev/test environment.  I want the
> profile (via the surefire plugin) to set a system property called "config"
> that can be read during the "test" goal to change which web app server to
> use (via property file).
>
> Currently the value of the "config" system property is equivalent to the
> value of the profile id.  Is there a syntax in the POM for referencing the
> id of the profile that is in the parent chain of the property being set?
>
> For example, in the profile below, can I reference the profile id in order
> to retrieve the value "staging"?  I've tried ${profile.id}, ${id}, but
> they
> don't work.
>
> <profiles>
>    <profile>
>      *<id>staging</id>
> *    ...
>      <build>
>        <plugins>
>          <plugin>
>            <groupId>org.apache.maven.plugins</groupId>
>            <artifactId>maven-surefire-plugin</artifactId>
>            <version>2.7.1</version>
>            <configuration>
>              <skip>false</skip>
>              <systemPropertyVariables>
>                *<config>${profile.id}</config>
> *        ...
>
>   </profile>
> </profiles>
>
> Thanks!!
>
> --
> Jeff Vincent
> predatorvi@gmail.com
> See my LinkedIn profile at:
> http://www.linkedin.com/in/rjeffreyvincent
>

Re: Help referencing profile properties/attributes...

Posted by Wayne Fay <wa...@gmail.com>.
> I'm new to Maven and am building a POM with profiles.  I want to be able to

Then you are most likely doing things "wrong." Is there no other way
to build/test your app without using profiles?

> Currently the value of the "config" system property is equivalent to the
> value of the profile id.  Is there a syntax in the POM for referencing the
> id of the profile that is in the parent chain of the property being set?

Not that I'm aware of. The simplest fix is to just put the word
"staging" in that plugin configuration, since your plugin is inside
the profile anyway. The next simplest "fix" is to have another
property, say profile-name, that you copy your profile id to and then
reference that property where you need to use the name.

Wayne

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org