jvanzyl     2003/07/30 19:56:18

  Modified:    src/java/org/apache/maven/jelly/tags/maven AddPathTag.java
                        MavenTagLibrary.java
  Added:       src/java/org/apache/maven/jelly/tags/maven
                        PluginPropertyTag.java
  Log:
  o Adding tag to allow to addition/alteration of a plugins properties.
  First test of this is the touchstone build.
  
  Revision  Changes    Path
  1.10      +5 -25     maven/src/java/org/apache/maven/jelly/tags/maven/AddPathTag.java
  
  Index: AddPathTag.java
  ===================================================================
  RCS file: 
/home/cvs/maven/src/java/org/apache/maven/jelly/tags/maven/AddPathTag.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- AddPathTag.java   30 Jul 2003 05:02:04 -0000      1.9
  +++ AddPathTag.java   31 Jul 2003 02:56:18 -0000      1.10
  @@ -61,7 +61,6 @@
   import org.apache.commons.jelly.MissingAttributeException;
   import org.apache.commons.jelly.XMLOutput;
   import org.apache.maven.jelly.tags.BaseTagSupport;
  -import org.apache.tools.ant.types.Path;
   
   /**
    * This class takes a given path using an <code>id</code> and appends another
  @@ -104,37 +103,18 @@
               throw new MissingAttributeException( "id must be specified" );
           }
   
  -        if ( getRefid() == null && getPath() == null )
  +        if ( getPath() == null )
           {
  -            throw new MissingAttributeException( "refid|path" );
  +            throw new MissingAttributeException( "path" );
           }
   
  -        Path path = (Path) project.getReferences().get( getId() );
  -        if (path == null)
  -        {
  -            throw new JellyTagException( "path with specified id was not found" );
  -        }
  -
  -        Path addPath;
  -        if ( getRefid() != null )
  -        {
  -            addPath = (Path) project.getReferences().get( getRefid() );
  -        }
  -        else
  -        {
  -            addPath = new Path( getMavenContext().getAntProject() );
  -            addPath.setPath( getPath() );
  -        }
  -
  -        path.append( addPath );
  -
           if ( getId().equals( "maven.compile.src.set" ) )
           {
  -            getMavenContext().getProject().addCompileSourceRoot( addPath.toString() 
);
  +            getMavenContext().getProject().addCompileSourceRoot( getPath() );
           }
           else if ( getId().equals( "maven.test.compile.src.set" ) )
           {
  -            getMavenContext().getProject().addTestCompileSourceRoot( 
addPath.toString() );
  +            getMavenContext().getProject().addTestCompileSourceRoot( getPath() );
           }
       }
   
  
  
  
  1.6       +2 -1      
maven/src/java/org/apache/maven/jelly/tags/maven/MavenTagLibrary.java
  
  Index: MavenTagLibrary.java
  ===================================================================
  RCS file: 
/home/cvs/maven/src/java/org/apache/maven/jelly/tags/maven/MavenTagLibrary.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- MavenTagLibrary.java      27 Jul 2003 23:33:57 -0000      1.5
  +++ MavenTagLibrary.java      31 Jul 2003 02:56:18 -0000      1.6
  @@ -82,5 +82,6 @@
           registerTag( "input", InputTag.class );
           registerTag( "exists", Exists.class );
           registerTag( "display", DisplayTag.class );
  +        registerTag( "set-plugin-property", PluginPropertyTag.class );
       }
   }
  
  
  
  1.1                  
maven/src/java/org/apache/maven/jelly/tags/maven/PluginPropertyTag.java
  
  Index: PluginPropertyTag.java
  ===================================================================
  package org.apache.maven.jelly.tags.maven;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Maven" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Maven", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  
  import org.apache.commons.jelly.JellyTagException;
  import org.apache.commons.jelly.MissingAttributeException;
  import org.apache.commons.jelly.XMLOutput;
  import org.apache.maven.jelly.tags.BaseTagSupport;
  
  import java.util.Map;
  
  /**
   * This class takes a given value using an <code>plugin</code> and appends another
   * value (using <code>var</code>) to it.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
   * @version $Id: PluginPropertyTag.java,v 1.1 2003/07/31 02:56:18 jvanzyl Exp $
   *
   * @todo The properties should be retrieved from the project and not from the
   * JellyContext. This will be necessary for plugins not written using Jelly.
   */
  public class PluginPropertyTag
      extends BaseTagSupport
  {
      /** the plugin of the value to be appended to. */
      private String plugin;
  
      /** The reference to the value to append */
      private String var;
  
      /** A value to append. */
      private String value;
  
      /**
       * Perform the tag processing. Look up the value by [EMAIL PROTECTED] #plugin} 
and append
       * the [EMAIL PROTECTED] #var other value} to it.
       *
       * @param output used to write output
       * @throws JellyTagException when anything goes wrong. FIXME
       */
      public void doTag( XMLOutput output )
          throws JellyTagException
      {
          if ( getPlugin() == null )
          {
              throw new MissingAttributeException( "plugin must be specified" );
          }
  
          if ( getVar() == null )
          {
              throw new MissingAttributeException( "var" );
          }
  
          if ( getValue() == null )
          {
              throw new MissingAttributeException( "value" );
          }
  
          // We need access to any of the plugins that are being used by this project
          // so that we can diddle its properties.
          Map pluginProperties = (Map) ((Map) getMavenContext().getVariable( "plugins" 
)).get( plugin );
  
          if ( pluginProperties == null )
          {
              System.out.println( "!!!!!!!!!!!!!!!!!! null = " + plugin );
              return;
          }
  
          // Stick in the new value or override the existing value.
          pluginProperties.put( var, value );
      }
  
      /**
       * Setter for the plugin property
       *
       * @param plugin the reference plugin of the value in the ant project that will 
be
       * appended to
       */
      public void setPlugin( String plugin )
      {
          this.plugin = plugin;
      }
  
      /**
       * Getter for the plugin property
       *
       * @return the reference plugin of the value in the ant project that will be
       * appended to
       */
      public String getPlugin()
      {
          return plugin;
      }
  
      /**
       * Setter for the var property
       *
       * @param var the reference plugin of the value in the ant project that will
       * be appended
       */
      public void setVar( String var )
      {
          this.var = var;
      }
  
      /**
       * Getter for the var property
       *
       * @return the reference plugin of the value in the ant project that will be
       * appended
       */
      public String getVar()
      {
          return var;
      }
  
      public String getValue()
      {
          return value;
      }
  
      public void setValue( String value )
      {
          System.out.println( "value = " + value );
  
          this.value = value;
      }
  }
  
  
  
  

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

Reply via email to