We are aware on this. FYI the issue MNG-2848 is still open.

Cheers,

Vincent

2008/1/30, Tom Huybrechts <[EMAIL PROTECTED]>:
> While using a 2.0.9 snapshot, I noticed that my plugins no longer see -D...
> cli arguments as system properties.
> Probably because System.setProperty(...) was removed in this revision. Why
> was this necessary ?
>
> Tom
>
>
> On Jan 8, 2008 1:03 PM, <[EMAIL PROTECTED]> wrote:
>
> > Author: vsiveton
> > Date: Tue Jan  8 04:03:02 2008
> > New Revision: 609944
> >
> > URL: http://svn.apache.org/viewvc?rev=609944&view=rev
> > Log:
> > MNG-2848: Environment variables in profile activation not working
> > Submitted by: Richard van der Hoff
> > Reviewed by: Vincent Siveton
> >
> > o patch applied with a small fix for env.PATH in the test
> >
> > Modified:
> >    maven/components/branches/maven-2.0.x
> > /maven-core/src/main/java/org/apache/maven/cli/MavenCli.java
> >    maven/components/branches/maven-2.0.x
> > /maven-core/src/test/java/org/apache/maven/cli/MavenCliTest.java
> >
> > Modified: maven/components/branches/maven-2.0.x
> > /maven-core/src/main/java/org/apache/maven/cli/MavenCli.java
> > URL:
> > http://svn.apache.org/viewvc/maven/components/branches/maven-2.0.x/maven-core/src/main/java/org/apache/maven/cli/MavenCli.java?rev=609944&r1=609943&r2=609944&view=diff
> >
> > ==============================================================================
> > --- 
> > maven/components/branches/maven-2.0.x/maven-core/src/main/java/org/apache/maven/cli/MavenCli.java
> > (original)
> > +++ 
> > maven/components/branches/maven-2.0.x/maven-core/src/main/java/org/apache/maven/cli/MavenCli.java
> > Tue Jan  8 04:03:02 2008
> > @@ -23,9 +23,11 @@
> >  import java.io.IOException;
> >  import java.io.InputStream;
> >  import java.util.ArrayList;
> > +import java.util.Iterator;
> >  import java.util.List;
> >  import java.util.Properties;
> >  import java.util.StringTokenizer;
> > +import java.util.Map.Entry;
> >
> >  import org.apache.commons.cli.CommandLine;
> >  import org.apache.commons.cli.CommandLineParser;
> > @@ -63,6 +65,7 @@
> >  import org.codehaus.plexus.logging.Logger;
> >  import org.codehaus.plexus.logging.LoggerManager;
> >  import org.codehaus.plexus.util.Os;
> > +import org.codehaus.plexus.util.cli.CommandLineUtils;
> >  import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
> >
> >  /**
> > @@ -221,7 +224,7 @@
> >                 // TODO:Additionally, we can't change the mojo level
> > because the component key includes the version and it isn't known ahead of
> > time. This seems worth changing.
> >             }
> >
> > -            ProfileManager profileManager = new DefaultProfileManager(
> > embedder.getContainer(),System.getProperties() );
> > +            ProfileManager profileManager = new DefaultProfileManager(
> > embedder.getContainer(), executionProperties );
> >
> >             if ( commandLine.hasOption( CLIManager.ACTIVATE_PROFILES ) )
> >             {
> > @@ -561,10 +564,27 @@
> >     // System properties handling
> >     //
> > ----------------------------------------------------------------------
> >
> > -    private static Properties getExecutionProperties( CommandLine
> > commandLine )
> > +    static Properties getExecutionProperties( CommandLine commandLine )
> >     {
> >         Properties executionProperties = new Properties();
> >
> > +        // add the env vars to the property set, with the "env." prefix
> > +        // XXX support for env vars should probably be removed from the
> > ModelInterpolator
> > +        try
> > +        {
> > +            Properties envVars = CommandLineUtils.getSystemEnvVars();
> > +            Iterator i = envVars.entrySet().iterator();
> > +            while ( i.hasNext() )
> > +            {
> > +                Entry e = (Entry) i.next();
> > +                executionProperties.setProperty( "env." + 
> > e.getKey().toString(),
> > e.getValue().toString() );
> > +            }
> > +        }
> > +        catch ( IOException e )
> > +        {
> > +            System.err.println( "Error getting environment vars for
> > profile activation: " + e );
> > +        }
> > +
> >         //
> > ----------------------------------------------------------------------
> >         // Options that are set on the command line become system
> > properties
> >         // and therefore are set in the session properties. System
> > properties
> > @@ -611,13 +631,6 @@
> >         }
> >
> >         executionProperties.setProperty( name, value );
> > -
> > -        //
> > ----------------------------------------------------------------------
> > -        // I'm leaving the setting of system properties here as not to
> > break
> > -        // the SystemPropertyProfileActivator. This won't harm embedding.
> > jvz.
> > -        //
> > ----------------------------------------------------------------------
> > -
> > -        System.setProperty( name, value );
> >     }
> >
> >     //
> > ----------------------------------------------------------------------
> >
> > Modified: maven/components/branches/maven-2.0.x
> > /maven-core/src/test/java/org/apache/maven/cli/MavenCliTest.java
> > URL:
> > http://svn.apache.org/viewvc/maven/components/branches/maven-2.0.x/maven-core/src/test/java/org/apache/maven/cli/MavenCliTest.java?rev=609944&r1=609943&r2=609944&view=diff
> >
> > ==============================================================================
> > --- 
> > maven/components/branches/maven-2.0.x/maven-core/src/test/java/org/apache/maven/cli/MavenCliTest.java
> > (original)
> > +++ 
> > maven/components/branches/maven-2.0.x/maven-core/src/test/java/org/apache/maven/cli/MavenCliTest.java
> > Tue Jan  8 04:03:02 2008
> > @@ -21,6 +21,7 @@
> >
> >  import java.io.OutputStream;
> >  import java.io.PrintStream;
> > +import java.util.Properties;
> >
> >  import org.codehaus.classworlds.ClassWorld;
> >  import org.codehaus.plexus.util.StringOutputStream;
> > @@ -78,5 +79,29 @@
> >             System.setErr( oldErr );
> >             System.setOut( oldOut );
> >         }
> > +    }
> > +
> > +    public void testGetExecutionProperties()
> > +        throws Exception
> > +    {
> > +        System.setProperty( "test.property.1", "1.0" );
> > +        System.setProperty( "test.property.2", "2.0" );
> > +        Properties p = MavenCli.getExecutionProperties( ( new
> > MavenCli.CLIManager() ).parse( new String[] {
> > +            "-Dtest.property.2=2.1",
> > +            "-Dtest.property.3=3.0" } ) );
> > +
> > +        // assume that everybody has a PATH env var
> > +        String envPath = p.getProperty( "env.PATH" );
> > +        if ( envPath == null )
> > +        {
> > +            envPath = p.getProperty( "env.Path" );
> > +        }
> > +        assertNotNull( envPath );
> > +
> > +        assertEquals( "1.0", p.getProperty( "test.property.1" ) );
> > +        assertEquals( "3.0", p.getProperty( "test.property.3" ) );
> > +
> > +        // sys props should override cmdline props
> > +        assertEquals( "2.0", p.getProperty( "test.property.2" ) );
> >     }
> >  }
> >
> >
> >
>

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

Reply via email to