maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jvan...@apache.org
Subject svn commit: r586244 - in /maven/sandbox/trunk/archetypeng/archetypeng-common: ./ src/main/java/org/apache/maven/archetype/source/ src/test/java/org/apache/maven/archetype/source/
Date Fri, 19 Oct 2007 03:15:30 GMT
Author: jvanzyl
Date: Thu Oct 18 20:15:29 2007
New Revision: 586244

URL: http://svn.apache.org/viewvc?rev=586244&view=rev
Log:
o adding a sink for the catalog so that I can read from any source and create a local catalog
that can be used a lot faster then then trying to hit the wiki. We could also couple this
with a method to pull down all the archetypes and their deps as well so someone could work
completely off line.

Added:
    maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/source/ArchetypeDataSink.java
  (with props)
    maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/source/ArchetypeDataSinkException.java
  (with props)
    maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/source/CatalogArchetypeDataSink.java
  (with props)
    maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/java/org/apache/maven/archetype/source/
    maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/java/org/apache/maven/archetype/source/CatalogArchetypeDataSinkTest.java
  (with props)
Modified:
    maven/sandbox/trunk/archetypeng/archetypeng-common/pom.xml

Modified: maven/sandbox/trunk/archetypeng/archetypeng-common/pom.xml
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/archetypeng/archetypeng-common/pom.xml?rev=586244&r1=586243&r2=586244&view=diff
==============================================================================
--- maven/sandbox/trunk/archetypeng/archetypeng-common/pom.xml (original)
+++ maven/sandbox/trunk/archetypeng/archetypeng-common/pom.xml Thu Oct 18 20:15:29 2007
@@ -111,6 +111,10 @@
       <artifactId>commons-collections</artifactId>
     </dependency>
     <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.apache.maven.shared</groupId>
       <artifactId>maven-invoker</artifactId>
       <version>2.0.6</version>

Added: maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/source/ArchetypeDataSink.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/source/ArchetypeDataSink.java?rev=586244&view=auto
==============================================================================
--- maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/source/ArchetypeDataSink.java
(added)
+++ maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/source/ArchetypeDataSink.java
Thu Oct 18 20:15:29 2007
@@ -0,0 +1,11 @@
+package org.apache.maven.archetype.source;
+
+import java.io.Writer;
+import java.util.List;
+
+/** @author Jason van Zyl */
+public interface ArchetypeDataSink
+{
+    void putArchetypes( List archetypes, Writer writer )
+        throws ArchetypeDataSinkException;
+}

Propchange: maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/source/ArchetypeDataSink.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/source/ArchetypeDataSink.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/source/ArchetypeDataSinkException.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/source/ArchetypeDataSinkException.java?rev=586244&view=auto
==============================================================================
--- maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/source/ArchetypeDataSinkException.java
(added)
+++ maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/source/ArchetypeDataSinkException.java
Thu Oct 18 20:15:29 2007
@@ -0,0 +1,22 @@
+package org.apache.maven.archetype.source;
+
+/** @author Jason van Zyl */
+public class ArchetypeDataSinkException
+    extends Exception
+{
+    public ArchetypeDataSinkException( String s )
+    {
+        super( s );
+    }
+
+    public ArchetypeDataSinkException( String s,
+                                       Throwable throwable )
+    {
+        super( s, throwable );
+    }
+
+    public ArchetypeDataSinkException( Throwable throwable )
+    {
+        super( throwable );
+    }
+}

Propchange: maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/source/ArchetypeDataSinkException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/source/ArchetypeDataSinkException.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/source/CatalogArchetypeDataSink.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/source/CatalogArchetypeDataSink.java?rev=586244&view=auto
==============================================================================
--- maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/source/CatalogArchetypeDataSink.java
(added)
+++ maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/source/CatalogArchetypeDataSink.java
Thu Oct 18 20:15:29 2007
@@ -0,0 +1,47 @@
+package org.apache.maven.archetype.source;
+
+import org.apache.maven.archetype.catalog.Archetype;
+import org.apache.maven.archetype.catalog.ArchetypeCatalog;
+import org.apache.maven.archetype.catalog.io.xpp3.ArchetypeCatalogXpp3Writer;
+import org.codehaus.plexus.logging.AbstractLogEnabled;
+import org.codehaus.plexus.util.IOUtil;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Iterator;
+import java.util.List;
+
+/** @author Jason van Zyl */
+public class CatalogArchetypeDataSink
+    extends AbstractLogEnabled
+    implements ArchetypeDataSink
+{
+    private ArchetypeCatalogXpp3Writer catalogWriter = new ArchetypeCatalogXpp3Writer();
+
+    public void putArchetypes( List archetypes,
+                               Writer writer )
+        throws ArchetypeDataSinkException
+    {
+        ArchetypeCatalog catalog = new ArchetypeCatalog();
+
+        for ( Iterator i = archetypes.iterator(); i.hasNext(); )
+        {
+            Archetype archetype = (Archetype) i.next();
+
+            catalog.addArchetype( archetype );
+        }
+
+        try
+        {
+            catalogWriter.write( writer, catalog );
+        }
+        catch ( IOException e )
+        {
+            throw new ArchetypeDataSinkException( "Error writing archetype catalog.", e );
+        }
+        finally
+        {
+            IOUtil.close( writer );
+        }
+    }
+}

Propchange: maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/source/CatalogArchetypeDataSink.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/source/CatalogArchetypeDataSink.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/java/org/apache/maven/archetype/source/CatalogArchetypeDataSinkTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/java/org/apache/maven/archetype/source/CatalogArchetypeDataSinkTest.java?rev=586244&view=auto
==============================================================================
--- maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/java/org/apache/maven/archetype/source/CatalogArchetypeDataSinkTest.java
(added)
+++ maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/java/org/apache/maven/archetype/source/CatalogArchetypeDataSinkTest.java
Thu Oct 18 20:15:29 2007
@@ -0,0 +1,61 @@
+package org.apache.maven.archetype.source;
+
+import org.apache.maven.archetype.catalog.Archetype;
+import org.apache.maven.archetype.catalog.ArchetypeCatalog;
+import org.apache.maven.archetype.catalog.io.xpp3.ArchetypeCatalogXpp3Reader;
+import org.codehaus.plexus.PlexusTestCase;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.List;
+
+/** @author Jason van Zyl */
+public class CatalogArchetypeDataSinkTest
+    extends PlexusTestCase
+{
+    public void testCatalogArchetypeDataSink()
+        throws Exception
+    {
+        Archetype a0 = new Archetype();
+
+        a0.setGroupId( "groupId" );
+
+        a0.setArtifactId( "artifactId" );
+
+        a0.setVersion( "1.0" );
+
+        a0.setDescription( "description" );
+
+        a0.setRepository( "http://magicbunny.com/maven2" );
+
+        List archetypes = new ArrayList();
+
+        archetypes.add( a0 );
+
+        ArchetypeDataSink sink = new CatalogArchetypeDataSink();
+
+        Writer writer = new StringWriter();
+
+        sink.putArchetypes( archetypes, writer );
+
+        StringReader reader = new StringReader( writer.toString() );
+
+        ArchetypeCatalogXpp3Reader catalogReader = new ArchetypeCatalogXpp3Reader();
+
+        ArchetypeCatalog catalog = catalogReader.read( reader );
+
+        Archetype a1 = (Archetype) catalog.getArchetypes().get( 0 );
+
+        assertEquals( "groupId", a1.getGroupId()  );
+
+        assertEquals( "artifactId", a1.getArtifactId() );
+
+        assertEquals( "1.0", a1.getVersion()  );
+
+        assertEquals( "description", a1.getDescription()  );
+
+        assertEquals( "http://magicbunny.com/maven2", a1.getRepository()  );
+    }
+}

Propchange: maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/java/org/apache/maven/archetype/source/CatalogArchetypeDataSinkTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/java/org/apache/maven/archetype/source/CatalogArchetypeDataSinkTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision



Mime
View raw message