werken      2002/07/04 06:31:52

  Modified:    src/java/org/apache/maven/app Maven.java
  Log:
  Added another round of property interp.
  maven.repo.local=${user.home}/maven.repo should now work Just Fine.
  
  Revision  Changes    Path
  1.41      +72 -49    jakarta-turbine-maven/src/java/org/apache/maven/app/Maven.java
  
  Index: Maven.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/app/Maven.java,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -r1.40 -r1.41
  --- Maven.java        4 Jul 2002 02:46:50 -0000       1.40
  +++ Maven.java        4 Jul 2002 13:31:52 -0000       1.41
  @@ -466,7 +466,19 @@
        */
       public String getProperty(String name)
       {
  -        return this.properties.getProperty(name);
  +        Object val = getJellyContext().getVariable( name );
  +
  +        if ( val == null )
  +        {
  +            return null;
  +        }
  +
  +        if ( val instanceof CompositeExpression )
  +        {
  +            val = ((CompositeExpression)val).evaluate( getJellyContext() );
  +        }
  +
  +        return val.toString();
       }
   
       /** Produce a string representation, suitable for debugging.
  @@ -506,11 +518,12 @@
   
           parseCommandLine(args);
   
  +        initializeJelly();
  +
           loadProperties();
   
           initializeProjectDescriptor();
   
  -        initializeJelly();
           initializeAnt();
           initializeIO();
           initializeTagLibs();
  @@ -735,52 +748,7 @@
       {
           Properties props = getPluginProperties(name);
   
  -        if (props == null)
  -        {
  -            return;
  -        }
  -
  -        JellyContext context = getJellyContext();
  -
  -        Enumeration propNames = props.propertyNames();
  -
  -        String eachName = null;
  -        String propText = null;
  -        Object propVal  = null;
  -
  -        JexlExpressionFactory factory = new JexlExpressionFactory();
  -
  -        while (propNames.hasMoreElements())
  -        {
  -            eachName = (String) propNames.nextElement();
  -
  -            if (context.getVariable(eachName) == null)
  -            {
  -                propText = props.getProperty(eachName);
  -
  -                try
  -                {
  -                    Expression expr = CompositeExpression.parse(propText,
  -                                                                 factory);
  -
  -                    if (expr != null)
  -                    {
  -                        propVal = expr;
  -                    }
  -                    else
  -                    {
  -                        propVal = propText;
  -                    }
  -
  -                    context.setVariable(eachName,
  -                                        propVal);
  -                }
  -                catch (Exception e)
  -                {
  -                    e.printStackTrace();
  -                }
  -            }
  -        }
  +        integrateProps( props );
       }
   
       /** Run maven.
  @@ -1112,7 +1080,12 @@
           try
           {
               in = new FileInputStream(propsFile);
  -            this.properties.load(in);
  +
  +            Properties props = new Properties();
  +
  +            props.load( in );
  +
  +            integrateProps( props );
           }
           catch (IOException e)
           {
  @@ -1130,6 +1103,56 @@
               catch (IOException e)
               {
                   // ignore
  +            }
  +        }
  +    }
  +
  +    private void integrateProps(Properties props) 
  +    {
  +        if (props == null)
  +        {
  +            return;
  +        }
  +        
  +        JellyContext context = getJellyContext();
  +
  +        Enumeration propNames = props.propertyNames();
  +
  +        String eachName = null;
  +        String propText = null;
  +        Object propVal  = null;
  +
  +        JexlExpressionFactory factory = new JexlExpressionFactory();
  +
  +        while (propNames.hasMoreElements())
  +        {
  +            eachName = (String) propNames.nextElement();
  +
  +            if (context.getVariable(eachName) == null)
  +            {
  +                propText = props.getProperty(eachName);
  +
  +                try
  +                {
  +                    Expression expr = CompositeExpression.parse(propText,
  +                                                                 factory);
  +
  +                    if (expr != null)
  +                    {
  +                        propVal = expr;
  +                    }
  +                    else
  +                    {
  +                        propVal = propText;
  +                    }
  +                    
  +                    context.setVariable(eachName,
  +                                        propVal);
  +                }
  +                catch (Exception e)
  +                {
  +                    e.printStackTrace();
  +                }
               }
           }
       }
  
  
  

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

Reply via email to