You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by vm...@apache.org on 2004/04/29 23:52:34 UTC

cvs commit: maven/maven-jelly-tags/src/java/main/org/apache/maven/jelly/tags/maven PluginVarTag.java

vmassol     2004/04/29 14:52:34

  Modified:    maven-jelly-tags/src/java/main/org/apache/maven/jelly/tags/maven
                        Tag: MAVEN-1_0-BRANCH PluginVarTag.java
  Log:
  Put back PluginVarTag code. I've tried to be too clever and somehow my change failed in some jelly tag initialization stuff... Everything is now working again.
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.1.4.9   +64 -24    maven/maven-jelly-tags/src/java/main/org/apache/maven/jelly/tags/maven/PluginVarTag.java
  
  Index: PluginVarTag.java
  ===================================================================
  RCS file: /home/cvs/maven/maven-jelly-tags/src/java/main/org/apache/maven/jelly/tags/maven/PluginVarTag.java,v
  retrieving revision 1.1.4.8
  retrieving revision 1.1.4.9
  diff -u -r1.1.4.8 -r1.1.4.9
  --- PluginVarTag.java	29 Apr 2004 20:57:42 -0000	1.1.4.8
  +++ PluginVarTag.java	29 Apr 2004 21:52:34 -0000	1.1.4.9
  @@ -19,78 +19,118 @@
   
   import org.apache.commons.jelly.JellyTagException;
   import org.apache.commons.jelly.XMLOutput;
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogFactory;
  +import org.apache.maven.jelly.MavenJellyContext;
   import org.apache.maven.jelly.tags.BaseTagSupport;
  +import org.apache.maven.plugin.UnknownPluginException;
  +import org.apache.maven.project.Project;
   
   /**
    * A tag to retrieve values from plugins
  - * 
  - * @deprecated use GetTag instead
  + * @deprecated replaced by the GetTag tag
    */
   public class PluginVarTag extends BaseTagSupport
   {
  -    private GetTag getTag = new GetTag();
  +    /** log for debug output */
  +    private static final Log log = LogFactory.getLog(PluginVarTag.class);
  +
  +    /** the variable to set*/
  +    private String var;
  +
  +    /** the plugin to get the variable from*/
  +    private String plugin;
  +
  +    /** the name of the plugin property to retrieve */
  +    private String property;
   
       /**
  -     * @see GetTag#doTag(XMLOutput)
  -     * @deprecated use GetTag instead 
  +     * @see org.apache.commons.jelly.Tag#doTag(org.apache.commons.jelly.XMLOutput)
  +     * @deprecated replaced by the GetTag tag
        */
       public void doTag(XMLOutput output) throws JellyTagException
       {
  -        this.getTag.doTag(output);
  +        checkAttribute(var, "var");
  +        checkAttribute(plugin, "plugin");
  +        checkAttribute(property, "property");
  +        Project project = getMavenContext().getProject();
  +        try
  +        {
  +            MavenJellyContext context = project.getPluginContext(plugin);
  +            if (context != null)
  +            {
  +                Object value = context.getVariable(property);
  +                getContext().setVariable(var, value);
  +            }
  +            else
  +            {
  +                log.error( "context for plugin '" + plugin + "' in project '"
  +                    + project + "' is null" );
  +            }
  +        }
  +        catch ( UnknownPluginException e )
  +        {
  +            log.error( "Plugin '" + plugin + "' in project '"
  +                + project + "' is not available" );
  +        }
  +        catch ( Exception e )
  +        {
  +            throw new JellyTagException( "Error loading plugin", e );
  +        }
       }
   
       /**
  -     * @see GetTag#getPlugin()
  -     * @deprecated use GetTag instead 
  +     * @return the plugin to retrieve the property from.
  +     * @deprecated replaced by the GetTag tag
        */
       public String getPlugin()
       {
  -        return this.getTag.getPlugin();
  +        return plugin;
       }
   
       /**
  -     * @see GetTag#getProperty()
  -     * @deprecated use GetTag instead 
  +     * @return the name of the property being retrieved
  +     * @deprecated replaced by the GetTag tag
        */
       public String getProperty()
       {
  -        return this.getTag.getProperty();
  +        return property;
       }
   
       /**
  -     * @see GetTag#getVar()
  -     * @deprecated use GetTag instead 
  +     * @return the variable name to set
  +     * @deprecated replaced by the GetTag tag
        */
       public String getVar()
       {
  -        return this.getTag.getVar();
  +        return var;
       }
   
       /**
  -     * @see GetTag#setPlugin(String)
  -     * @deprecated use GetTag instead 
  +     * @param pluginId the id of the plugin to retrieve the property from
  +     * @deprecated replaced by the GetTag tag
        */
       public void setPlugin(String pluginId)
       {
  -        this.getTag.setPlugin(pluginId);
  +        plugin = pluginId;
       }
   
       /**
  -     * @see GetTag#setProperty(String)
  -     * @deprecated use GetTag instead 
  +     * @param propertyName the name of the property being retrieved
  +     * @deprecated replaced by the GetTag tag
        */
       public void setProperty(String propertyName)
       {
  -        this.getTag.setProperty(propertyName);
  +        property = propertyName;
       }
   
       /**
  -     * @see GetTag#setVar(String)
  -     * @deprecated use GetTag instead 
  +     * @param variable the variable name to set
  +     * @deprecated replaced by the GetTag tag
        */
       public void setVar(String variable)
       {
  -        this.getTag.setVar(variable);
  +        this.var = variable;
       }
   
   }
  
  
  

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