Issue Details (XML | Word | Printable)

Key: MNG-2848
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: John Casey
Reporter: Muhammad Alsebaey
Votes: 10
Watchers: 9
Operations

If you were logged in you would be able to see more operations.
Maven 2

Environment variables in profile activation not working

Created: 24/Feb/07 05:02 PM   Updated: 12/Mar/08 12:39 PM
Component/s: Profiles
Affects Version/s: 2.0.4, 2.0.5
Fix Version/s: 2.0.9

Time Tracking:
Not Specified

File Attachments: 1. Text File MNG-2848.patch (5 kB)

Environment: Windows XP Professional, JDK 1.5
Issue Links:
Related
 

Complexity: Intermediate


 Description  « Hide
When using an environment variable as a profile activation variable, it doesnt work, using either env.X or ${env.X} doesnt work.
I found the same issue on the forums unresolved.

http://www.nabble.com/profile-activation-based-on-environment-variables-tf2585492s177.html#a7208580

Basically, the following doesnt work, where FOO is a windows environment variable (like PATH for example) :

<profile>
  <id>haroon-workstation</id>
  <activation>
    <property>
      <name>env.FOO</name>
      <value>foo</value>
    </property>
   </activation>
    .......

 </profile>


 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
k added a comment - 31/Aug/07 09:07 AM - edited
Has there been any resolution to this issue? I am currently also trying to access environment variables from within <profile> (be it within profiles.xml and pom.xml) with no success. Outside of <profile>, I can access environment variables just fine, but within <profile>, using the environment variable as an activation property, does not seem to work.

I've been unsuccessful trying to access the variable using the following methods within <profile>:
env.FOO
FOO
${env.FOO}
${FOO}

Any information reguarding this issue would be greatly appreciated... especially since this has been an issue for well over a year now (referring to http://jira.codehaus.org/browse/MNG-2276 ).

Defining the variable via the commandline interface does work however, as stated in the link above.

Btw, my version of maven is 2.0.7


Richard van der Hoff added a comment - 04/Jan/08 12:03 PM
Here's a patch, against maven-core 2.0.8, which makes profile activation via environment variables work.

Vincent Siveton added a comment - 08/Jan/08 06:11 AM
Patch applied in r609944. Thanks!

Richard van der Hoff added a comment - 11/Jan/08 05:28 PM
Oops, this seems to have broken property passing in mvn exec:java - see MEXEC-41

Vincent Siveton added a comment - 14/Jan/08 10:37 PM
To reinvestigate due to Richard's comment

Brian Fox added a comment - 03/Mar/08 11:14 AM
vincent: any way to get this for 2.0.9 this week?

John Casey added a comment - 11/Mar/08 03:24 PM
Looks like the system-property-setting has been reinstated, and the execution properties are still setup and used internally as specified in the patch. This is probably the best we can expect for now, unless/until we find a way to control the way plugins use (and more importantly, pass on to their delegates) the system properties.

I'm closing this issue. We can open a new one later if we need to fine-tune this behavior further.


Richard van der Hoff added a comment - 12/Mar/08 12:39 PM
Yes, agreed that this seems the most sensible approach for now.

Thanks for sorting this, guys.