dion        2003/08/18 21:28:16

  Modified:    src/java/org/apache/maven/jelly JellyUtils.java
                        JellyPropsHandler.java JellyBuildListener.java
                        MavenJellyContext.java
  Added:       src/java/org/apache/maven/jelly MavenExpressionFactory.java
  Log:
  Switch stable branch back to HEAD
  
  Revision  Changes    Path
  1.16      +38 -1     maven/src/java/org/apache/maven/jelly/JellyUtils.java
  
  Index: JellyUtils.java
  ===================================================================
  RCS file: /home/cvs/maven/src/java/org/apache/maven/jelly/JellyUtils.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- JellyUtils.java   1 Aug 2003 07:38:02 -0000       1.15
  +++ JellyUtils.java   19 Aug 2003 04:28:15 -0000      1.16
  @@ -67,6 +67,9 @@
   import org.apache.commons.jelly.JellyContext;
   import org.apache.commons.jelly.Script;
   import org.apache.commons.jelly.XMLOutput;
  +import org.apache.commons.jelly.expression.CompositeExpression;
  +import org.apache.commons.jelly.expression.Expression;
  +import org.apache.commons.jelly.expression.ExpressionFactory;
   import org.apache.commons.jelly.parser.XMLParser;
   import org.xml.sax.XMLReader;
   
  @@ -209,5 +212,39 @@
           script = script.compile();
   
           return script;
  +    }
  +    
  +    /**
  +     * Recursively evaluate a string representation of a jelly expression.
  +     *
  +     * @param text String representation of the a Jelly expression.
  +     * @param factory Expression factory used for evaluating the expression.
  +     * @param context The Jelly context to compute the expression against.
  +     *
  +     * @return The recursively evaluated Jelly expression.
  +     */
  +    public static Expression decomposeExpression( String text,
  +                                                  ExpressionFactory factory,
  +                                                  JellyContext context )
  +    {
  +        Expression expression = null;
  +
  +        try
  +        {
  +            expression = CompositeExpression.parse( text, factory );
  +
  +            String expressionText = expression.evaluateAsString( context );
  +
  +            if ( CompositeExpression.parse( expressionText, factory ) instanceof 
CompositeExpression )
  +            {
  +                expression = decomposeExpression( expressionText, factory, context 
);
  +            }
  +        }
  +        catch ( Exception e )
  +        {
  +            // do nothing.
  +        }
  +
  +        return expression;
       }
   }
  
  
  
  1.7       +0 -1      maven/src/java/org/apache/maven/jelly/JellyPropsHandler.java
  
  Index: JellyPropsHandler.java
  ===================================================================
  RCS file: /home/cvs/maven/src/java/org/apache/maven/jelly/JellyPropsHandler.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- JellyPropsHandler.java    27 Jul 2003 23:33:57 -0000      1.6
  +++ JellyPropsHandler.java    19 Aug 2003 04:28:15 -0000      1.7
  @@ -138,7 +138,6 @@
                   h.put( name, value.toString() );
               }
           }
  -
           return h;
       }
   
  
  
  
  1.4       +1 -2      maven/src/java/org/apache/maven/jelly/JellyBuildListener.java
  
  Index: JellyBuildListener.java
  ===================================================================
  RCS file: /home/cvs/maven/src/java/org/apache/maven/jelly/JellyBuildListener.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- JellyBuildListener.java   27 Jul 2003 23:33:57 -0000      1.3
  +++ JellyBuildListener.java   19 Aug 2003 04:28:15 -0000      1.4
  @@ -55,8 +55,7 @@
   import org.apache.tools.ant.Project;
   import org.xml.sax.SAXException;
   
  -public class JellyBuildListener
  -    implements BuildListener
  +public class JellyBuildListener implements BuildListener
   {
       private XMLOutput out;
   
  
  
  
  1.33      +393 -29   maven/src/java/org/apache/maven/jelly/MavenJellyContext.java
  
  Index: MavenJellyContext.java
  ===================================================================
  RCS file: /home/cvs/maven/src/java/org/apache/maven/jelly/MavenJellyContext.java,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- MavenJellyContext.java    27 Jul 2003 23:33:57 -0000      1.32
  +++ MavenJellyContext.java    19 Aug 2003 04:28:15 -0000      1.33
  @@ -60,13 +60,19 @@
   import org.apache.commons.grant.GrantProject;
   import org.apache.commons.jelly.JellyContext;
   import org.apache.commons.jelly.TagLibrary;
  -import org.apache.maven.Maven;
  +import org.apache.commons.jelly.XMLOutput;
  +import org.apache.commons.jelly.expression.Expression;
  +import org.apache.commons.lang.StringUtils;
   import org.apache.maven.MavenConstants;
  +import org.apache.maven.MavenSession;
   import org.apache.maven.jelly.tags.jeez.MavenJeezTagLibrary;
   import org.apache.maven.jelly.tags.maven.MavenTagLibrary;
   import org.apache.maven.project.Project;
   
   import java.net.URL;
  +import java.util.ArrayList;
  +import java.util.Iterator;
  +import java.util.List;
   
   /** Specialized version of a <code>JellyContext</code>.
    *
  @@ -86,7 +92,9 @@
   public class MavenJellyContext
       extends JellyContext
   {
  -    private ClassLoader classLoader;
  +    // ----------------------------------------------------------------------
  +    // C O N S T R U C T O R S
  +    // ----------------------------------------------------------------------
   
       /** Construct.
        */
  @@ -116,23 +124,9 @@
           initializeContext();
       }
   
  -    // ----------------------------------------------------------------------
  -    // Accessors
  -    // ----------------------------------------------------------------------
  -
  -    public ClassLoader getClassLoader()
  +    protected JellyContext createChildContext()
       {
  -        if ( classLoader != null )
  -        {
  -            return classLoader;
  -        }
  -
  -        return Thread.currentThread().getContextClassLoader();
  -    }
  -
  -    public void setClassLoader( ClassLoader classLoader )
  -    {
  -        this.classLoader = classLoader;
  +        return new MavenJellyContext(this);
       }
   
       // ----------------------------------------------------------------------
  @@ -214,22 +208,52 @@
        */
       public Object getVariable( String name )
       {
  -        Object value;
  -
  -        value = super.getVariable( name );
  +        Object value = super.getVariable( name );
   
  -        if ( value == null
  -             &&
  -             getProject() != null )
  +        if ( value instanceof Expression )
           {
  -            value = getProject().getProjectProperty( name );
  +            value = ( (Expression) value ).evaluate( this );
           }
   
           return value;
       }
   
  +    /**
  +     * Convert a <code>String</code> property to a
  +     * <code>Boolean</code> based on its contents.  It would be nice
  +     * if Jelly would deal with this automatically.
  +     *
  +     *  @param key The property key to lookup and convert.
  +     *
  +     *  @return The boolean value of the property if convertiable,
  +     *          otherwise <code>Boolean.FALSE</code>.
  +     */
  +    public Boolean getBoolean( String key )
  +    {
  +        // After changing the processing everything is now a Boolean already
  +        // but I want to keep the type check for the time being.
  +
  +        Object value = getVariable( key );
  +
  +        if ( value instanceof Boolean )
  +        {
  +            return (Boolean) value;
  +        }
  +
  +        String stringValue = (String) value;
  +
  +        if (    "true".equalsIgnoreCase( stringValue )
  +             || "on".equalsIgnoreCase( stringValue )
  +             || "1".equals( value ) )
  +        {
  +            return Boolean.TRUE;
  +        }
  +
  +        return Boolean.FALSE;
  +    }
  +
       // ----------------------------------------------------------------------
  -    // Accessors
  +    // A C C E S S O R S
       // ----------------------------------------------------------------------
   
       /**
  @@ -237,7 +261,7 @@
        *
        * @param mavenSession
        */
  -    public void setMavenSession( Maven mavenSession )
  +    public void setMavenSession( MavenSession mavenSession )
       {
           setVariable( MavenConstants.SESSION, mavenSession );
       }
  @@ -247,11 +271,120 @@
        *
        * @return The
        */
  -    public Maven getMavenSession()
  +    public MavenSession getMavenSession()
       {
  -        return (Maven) getVariable( MavenConstants.SESSION );
  +        return (MavenSession) getVariable( MavenConstants.SESSION );
       }
   
  +    /**
  +     * Add a remote repository to the list of remote repositories.
  +     *
  +     * @param mavenRemoteRepo Remote repository to add.
  +     */
  +    public void addMavenRemoteRepo( String mavenRemoteRepo )
  +    {
  +        ( (List) getVariable( MavenConstants.REPO_REMOTE ) ).add( mavenRemoteRepo );
  +    }
  +
  +    /**
  +     * Set the mavenRepoRemote attribute.
  +     *
  +     * @param mavenRepoRemote List of remove repositories.
  +     */
  +    public void setMavenRepoRemotes( List mavenRepoRemote )
  +    {
  +        setVariable( MavenConstants.REPO_REMOTE, mavenRepoRemote );
  +    }
  +
  +    /**
  +     * Get the mavenRepoRemote attribute.
  +     *
  +     * @return The list of remote repositories.
  +     */
  +    public List getMavenRepoRemote()
  +    {
  +        // We might have CSV list of remote repositories.
  +        return convertCsvStringToList( (String) getVariable( 
MavenConstants.REPO_REMOTE ) );
  +    }
  +
  +    /**
  +     * Convert a CSV list of values into a List
  +     *
  +     * @param csvString CVS list of values.
  +     * @return The List of value.
  +     */
  +    private List convertCsvStringToList( String csvString )
  +    {
  +        ArrayList list = new ArrayList();
  +        String[] s = StringUtils.split( csvString, "," );
  +
  +        for ( int i = 0; i < s.length; i++ )
  +        {
  +            list.add( s[i] );
  +        }
  +
  +        return list;
  +    }
  +
  +    /**
  +     * Set the location of the local maven repository.
  +     *
  +     * @param mavenRepoLocal The local repository.
  +     */
  +    public void setMavenRepoLocal( String mavenRepoLocal )
  +    {
  +        setVariable( MavenConstants.REPO_LOCAL, mavenRepoLocal );
  +    }
  +
  +    /**
  +     * Get the location of the local maven repository.
  +     *
  +     * @return The local repository.
  +     */
  +    public String getMavenRepoLocal()
  +    {
  +        return (String) getVariable( MavenConstants.REPO_LOCAL );
  +    }
  +
  +    /**
  +     * Set the jelly output sink.
  +     *
  +     * @param xmlOutput The jelly output sink.
  +     */
  +    public void setXMLOutput( XMLOutput xmlOutput )
  +    {
  +        setVariable( MavenConstants.XML_OUTPUT, xmlOutput );
  +    }
  +
  +    /**
  +     * Get the jelly output sink.
  +     *
  +     * @return The jelly output sink.
  +     */
  +    public XMLOutput getXMLOutput()
  +    {
  +        return (XMLOutput) getVariable( MavenConstants.XML_OUTPUT );
  +    }
  +
  +    /**
  +     * Set the online flag.
  +     *
  +     * @param online The online flag.
  +     */
  +    public void setOnline( Boolean online )
  +    {
  +        setVariable( MavenConstants.ONLINE, online );
  +    }
  +
  +    /**
  +     * Get the online flag.
  +     *
  +     * @return The online flag.
  +     */
  +    public Boolean getOnline()
  +    {
  +        return getBoolean( MavenConstants.ONLINE );
  +    }
   
       /**
        * Set the maven project.
  @@ -274,6 +407,203 @@
       }
   
       /**
  +     * Set the proxy host.
  +     *
  +     * @param proxyHost The proxy host.
  +     */
  +    public void setProxyHost( String proxyHost )
  +    {
  +        setVariable( MavenConstants.PROXY_HOST, proxyHost );
  +    }
  +
  +    /**
  +     * Get the proxy host.
  +     *
  +     * @return The proxy host.
  +     */
  +    public String getProxyHost()
  +    {
  +        return (String) getVariable( MavenConstants.PROXY_HOST );
  +    }
  +
  +    /**
  +     * Set the proxy port.
  +     *
  +     * @param proxyPort The proxy port.
  +     */
  +    public void setProxyPort( String proxyPort )
  +    {
  +        setVariable( MavenConstants.PROXY_PORT, proxyPort );
  +    }
  +
  +    /**
  +     * Get the proxy port.
  +     *
  +     * @return The proxy port.
  +     */
  +    public String getProxyPort()
  +    {
  +        return (String) getVariable( MavenConstants.PROXY_PORT );
  +    }
  +
  +    /**
  +     *  Set the proxy user name.
  +     *
  +     * @param proxyUserName The user name setting for the proxy.
  +     */
  +    public void setProxyUserName( String proxyUserName )
  +    {
  +        setVariable( MavenConstants.PROXY_USERNAME, proxyUserName );
  +    }
  +
  +    /**
  +     * Get the proxy user name.
  +     *
  +     * @return The proxy user name.
  +     */
  +    public String getProxyUserName()
  +    {
  +        return (String) getVariable( MavenConstants.PROXY_USERNAME );
  +    }
  +
  +    /**
  +     * Set the proxy password.
  +     *
  +     * @param proxyPassword The proxy password.
  +     */
  +    public void setProxyPassword( String proxyPassword )
  +    {
  +        setVariable( MavenConstants.PROXY_PASSWORD, proxyPassword );
  +    }
  +
  +    /**
  +     * Get the proxy password.
  +     *
  +     * @return The ant project.
  +     */
  +    public String getProxyPassword()
  +    {
  +        return (String) getVariable( MavenConstants.PROXY_PASSWORD );
  +    }
  +
  +    //!! Align these these two sets of methods to use getBoolean
  +
  +    /**
  +     * Set the debug flag.
  +     *
  +     * @param debug The debug flag.
  +     */
  +    public void setDebugOn( Boolean debug )
  +    {
  +        setVariable( MavenConstants.DEBUG_ON, debug );
  +    }
  +
  +    /**
  +     * Get the debug flag.
  +     *
  +     * @return The debug flag.
  +     */
  +    public Boolean getDebugOn()
  +    {
  +        Boolean b = (Boolean) getVariable( MavenConstants.DEBUG_ON );
  +
  +        if ( b == null )
  +        {
  +            return Boolean.FALSE;
  +        }
  +
  +        return b;
  +    }
  +
  +    /**
  +     * Set the emacs mode flag.
  +     *
  +     * @param emacsModeOn The emacs mode flag.
  +     */
  +    public void setEmacsModeOn( Boolean emacsModeOn )
  +    {
  +        setVariable( MavenConstants.EMACS_MODE_ON, emacsModeOn );
  +    }
  +
  +    /**
  +     * Get the emacs mode flag.
  +     *
  +     * @return The emacs mode flag.
  +     */
  +    public Boolean getEmacsModeOn()
  +    {
  +        Boolean b = (Boolean) getVariable( MavenConstants.EMACS_MODE_ON );
  +
  +        if ( b == null )
  +        {
  +            return Boolean.FALSE;
  +        }
  +
  +        return b;
  +    }
  +
  +    /**
  +     * Set flag indicating if the remote repository is enabled for use.
  +     *
  +     * @param remoteRepositoryEnabled Remote repository usage flag.
  +     */
  +    public void setRemoteRepositoryEnabled( Boolean remoteRepositoryEnabled )
  +    {
  +        setVariable( MavenConstants.REPO_REMOTE_ENABLED, remoteRepositoryEnabled );
  +    }
  +
  +   /**
  +     * Set flag indicating if the remote repository is enabled for use.
  +     *
  +     * @return Remote repository usage flag.
  +     */
  +    public Boolean getRemoteRepositoryEnabled()
  +    {
  +        return getBoolean( MavenConstants.REPO_REMOTE_ENABLED );
  +    }
  +
  +   /**
  +     * Set the flag indicating the use of the JAR overriding facility.
  +     *
  +     * @param mavenJarOverride MavenSession jar override flag.
  +     */
  +    public void setMavenJarOverride( Boolean mavenJarOverride )
  +    {
  +        setVariable( MavenConstants.JAR_OVERRIDE, mavenJarOverride );
  +    }
  +
  +    /**
  +     * Get the flag indicating the use of the JAR overriding facility.
  +     *
  +     * @return MavenSession jar override flag.
  +     */
  +    public Boolean getMavenJarOverride()
  +    {
  +        return getBoolean( MavenConstants.JAR_OVERRIDE );
  +    }
  +
  +    /**
  +     * Get the maven jar override value for a particular dependency.
  +     *
  +     * @param id Id of the project to override.
  +     * @return MavenSession jar override value for a particular dependency.
  +     */
  +    public String getMavenJarOverride( String id )
  +    {
  +        return (String) getVariable( MavenConstants.JAR_OVERRIDE_PROPERTY + id );
  +    }
  +
  +    /**
  +     * Get MavenSession home.
  +     *
  +     * @return MavenSession home.
  +     */
  +    public String getMavenHome()
  +    {
  +        return (String) getVariable( MavenConstants.MAVEN_HOME );
  +    }
  +
  +    /**
        * retrieve the werkz project object
        * @param werkzProject [EMAIL PROTECTED] com.werken.werkz.WerkzProject Werkz 
Project}
        */
  @@ -310,4 +640,38 @@
       {
           return (GrantProject) getVariable( MavenConstants.MAVEN_ANT_PROJECT );
       }
  +
  +    public void display()
  +    {
  +        for (Iterator i = getVariableNames(); i.hasNext(); )
  +        {
  +            String key = (String) i.next();
  +
  +            if ( key.startsWith("maven"))
  +            {
  +                System.out.println(key + ": " + getVariable( key ));
  +            }
  +        }
  +    }
  +
  +    /**
  +     * Get local maven home.
  +     *
  +     * @return location of Maven local home installation.
  +     */
  +    public String getMavenHomeLocal()
  +    {
  +        return (String) getVariable( MavenConstants.MAVEN_HOME_LOCAL );
  +    }
  +
  +    /**
  +     * Get unpacked plugins location.
  +     *
  +     * @return unpacked plugins location.
  +     */
  +    public String getUnpackedPluginsDir()
  +    {
  +        return (String) getVariable( MavenConstants.MAVEN_UNPACKED_PLUGINS_DIR );
  +    }
  +
   }
  
  
  
  1.11      +0 -0      
maven/src/java/org/apache/maven/jelly/MavenExpressionFactory.java
  
  
  
  

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

Reply via email to