maven-m2-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tryg...@apache.org
Subject cvs commit: maven-components/maven-plugin/src/test/java/org/apache/maven/plugin/generator AbstractGeneratorTestCase.java PluginDescriptorGeneratorTest.java
Date Sat, 26 Jun 2004 15:50:26 GMT
trygvis     2004/06/26 08:50:26

  Modified:    maven-plugin/src/main/java/org/apache/maven/plugin/descriptor
                        PluginDescriptor.java PluginDescriptorBuilder.java
               maven-plugin/src/main/java/org/apache/maven/plugin/generator
                        PluginDescriptorGenerator.java
               maven-plugin/src/test/java/org/apache/maven/plugin/generator
                        AbstractGeneratorTestCase.java
                        PluginDescriptorGeneratorTest.java
  Added:       maven-plugin/src/main/java/org/apache/maven/plugin/descriptor
                        Dependency.java
  Log:
  o Added <dependencies> to plugin.xml
  o Added dependencies to PluginDescriptor.
  
  Revision  Changes    Path
  1.5       +13 -1     maven-components/maven-plugin/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java
  
  Index: PluginDescriptor.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-plugin/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- PluginDescriptor.java	24 Jun 2004 16:36:16 -0000	1.4
  +++ PluginDescriptor.java	26 Jun 2004 15:50:26 -0000	1.5
  @@ -16,6 +16,7 @@
    * limitations under the License.
    */
   
  +import java.util.LinkedList;
   import java.util.List;
   
   /**
  @@ -28,6 +29,8 @@
   
       private String id;
   
  +    private List dependencies;
  +
       // ----------------------------------------------------------------------
       //
       // ----------------------------------------------------------------------
  @@ -45,5 +48,14 @@
       public void setId( String id )
       {
           this.id = id;
  +    }
  +
  +    // ----------------------------------------------------------------------
  +    // Dependencies
  +    // ----------------------------------------------------------------------
  +
  +    public List getDependencies()
  +    {
  +        return dependencies;
       }
   }
  
  
  
  1.4       +3 -1      maven-components/maven-plugin/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptorBuilder.java
  
  Index: PluginDescriptorBuilder.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-plugin/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptorBuilder.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- PluginDescriptorBuilder.java	21 Jun 2004 19:40:20 -0000	1.3
  +++ PluginDescriptorBuilder.java	26 Jun 2004 15:50:26 -0000	1.4
  @@ -48,6 +48,8 @@
           xstream.alias( "prereq", String.class );
   
           xstream.alias( "parameter", Parameter.class );
  +
  +        xstream.alias( "dependency", Dependency.class );
       }
   
       public PluginDescriptor build( Reader reader )
  
  
  
  1.1                  maven-components/maven-plugin/src/main/java/org/apache/maven/plugin/descriptor/Dependency.java
  
  Index: Dependency.java
  ===================================================================
  package org.apache.maven.plugin.descriptor;
  
  /*
   * LICENSE
   */
  
  /**
   * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
   * @version $Id: Dependency.java,v 1.1 2004/06/26 15:50:26 trygvis Exp $
   */
  public class Dependency
  {
      private String groupId;
  
      private String artifactId;
  
      private String type;
  
      private String version;
  
      public String getGroupId()
      {
          return groupId;
      }
  
      public void setGroupId( String groupId )
      {
          this.groupId = groupId;
      }
  
      public String getArtifactId()
      {
          return artifactId;
      }
  
      public void setArtifactId( String artifactId )
      {
          this.artifactId = artifactId;
      }
  
      public String getType()
      {
          return type;
      }
  
      public void setType( String type )
      {
          this.type = type;
      }
  
      public String getVersion()
      {
          return version;
      }
  
      public void setVersion( String version )
      {
          this.version = version;
      }
  }
  
  
  
  1.19      +52 -0     maven-components/maven-plugin/src/main/java/org/apache/maven/plugin/generator/PluginDescriptorGenerator.java
  
  Index: PluginDescriptorGenerator.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-plugin/src/main/java/org/apache/maven/plugin/generator/PluginDescriptorGenerator.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- PluginDescriptorGenerator.java	24 Jun 2004 16:36:16 -0000	1.18
  +++ PluginDescriptorGenerator.java	26 Jun 2004 15:50:26 -0000	1.19
  @@ -61,6 +61,8 @@
   
           w.endElement();
   
  +        writeDependencies( w, pomDom );
  +
           w.endElement();
   
           writer.flush();
  @@ -164,6 +166,56 @@
           // ----------------------------------------------------------------------
           //
           // ----------------------------------------------------------------------
  +
  +        w.endElement();
  +    }
  +
  +    public void writeDependencies( XMLWriter w, Xpp3Dom pomDom )
  +        throws Exception
  +    {
  +        w.startElement( "dependencies" );
  +
  +        Xpp3Dom deps = pomDom.getChild( "dependencies" );
  +
  +        if ( deps != null )
  +        {
  +            Xpp3Dom dependencies[] = deps.getChildren( "dependency" );
  +    
  +            for ( int i = 0; i < dependencies.length; i++ )
  +            {
  +                w.startElement( "dependency" );
  +    
  +                Xpp3Dom groupId = pomDom.getChild( "groupId" );
  +    
  +                if ( groupId == null )
  +                    throw new Exception( "Missing element: 'groupId'." );
  +    
  +                element( w, "groupId", groupId.getValue() );
  +    
  +                Xpp3Dom artifactId = pomDom.getChild( "artifactId" );
  +    
  +                if ( artifactId == null )
  +                    throw new Exception( "Missing element: 'artifactId'." );
  +    
  +                element( w, "artifactId", artifactId.getValue() );
  +    
  +                Xpp3Dom type = pomDom.getChild( "type" );
  +    
  +                if ( type != null )
  +                {
  +                    element( w, "type", type.getValue() );
  +                }
  +    
  +                Xpp3Dom version = pomDom.getChild( "version" );
  +    
  +                if ( version == null )
  +                    throw new Exception( "Missing element: 'version'." );
  +    
  +                element( w, "version", version.getValue() );
  +    
  +                w.endElement();
  +            }
  +        }
   
           w.endElement();
       }
  
  
  
  1.6       +3 -2      maven-components/maven-plugin/src/test/java/org/apache/maven/plugin/generator/AbstractGeneratorTestCase.java
  
  Index: AbstractGeneratorTestCase.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-plugin/src/test/java/org/apache/maven/plugin/generator/AbstractGeneratorTestCase.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- AbstractGeneratorTestCase.java	25 Jun 2004 18:43:40 -0000	1.5
  +++ AbstractGeneratorTestCase.java	26 Jun 2004 15:50:26 -0000	1.6
  @@ -24,7 +24,7 @@
    * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
    * @version $Id$
    */
  -public class AbstractGeneratorTestCase
  +public abstract class AbstractGeneratorTestCase
       extends TestCase
   {
       protected Generator generator;
  @@ -85,5 +85,6 @@
       protected void validate()
           throws Exception
       {
  +        // empty
       }
   }
  
  
  
  1.8       +11 -1     maven-components/maven-plugin/src/test/java/org/apache/maven/plugin/generator/PluginDescriptorGeneratorTest.java
  
  Index: PluginDescriptorGeneratorTest.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-plugin/src/test/java/org/apache/maven/plugin/generator/PluginDescriptorGeneratorTest.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- PluginDescriptorGeneratorTest.java	25 Jun 2004 18:43:40 -0000	1.7
  +++ PluginDescriptorGeneratorTest.java	26 Jun 2004 15:50:26 -0000	1.8
  @@ -49,6 +49,8 @@
   
           assertEquals( "singleton", mojoDescriptor.getInstantiationStrategy() );
   
  +        assertTrue( mojoDescriptor.requiresDependencyResolution() );
  +
           // ----------------------------------------------------------------------
           // Parameters
           // ----------------------------------------------------------------------
  @@ -62,5 +64,13 @@
           assertEquals( "project", pd.getName() );
   
           assertEquals( "#project", pd.getExpression() );
  +
  +        // ----------------------------------------------------------------------
  +        // Dependencies
  +        // ----------------------------------------------------------------------
  +
  +        List dependencies = pluginDescriptor.getDependencies();
  +
  +        assertEquals( 3, dependencies.size() );
       }
   }
  
  
  

Mime
View raw message