Author: rafale
Date: Mon Aug 25 14:19:19 2008
New Revision: 688887

URL: http://svn.apache.org/viewvc?rev=688887&view=rev
Log:
Fix for archetype-198

Modified:
    
maven/archetype/trunk/archetype-common/src/main/resources/archetype-catalog.xml
    
maven/archetype/trunk/archetype-common/src/test/java/org/apache/maven/archetype/source/CatalogArchetypeDataSinkTest.java
    
maven/archetype/trunk/archetype-common/src/test/java/org/apache/maven/archetype/source/WikiArchetypeDataSourceTest.java
    
maven/archetype/trunk/archetype-common/src/test/java/org/apache/maven/archetype/test/InternalCatalogFromWiki.java

Modified: 
maven/archetype/trunk/archetype-common/src/main/resources/archetype-catalog.xml
URL: 
http://svn.apache.org/viewvc/maven/archetype/trunk/archetype-common/src/main/resources/archetype-catalog.xml?rev=688887&r1=688886&r2=688887&view=diff
==============================================================================
--- 
maven/archetype/trunk/archetype-common/src/main/resources/archetype-catalog.xml 
(original)
+++ 
maven/archetype/trunk/archetype-common/src/main/resources/archetype-catalog.xml 
Mon Aug 25 14:19:19 2008
@@ -184,7 +184,7 @@
     <archetype>
       <groupId>org.scala-tools.archetypes</groupId>
       <artifactId>scala-archetype-simple</artifactId>
-      <version>1.1</version>
+      <version>1.2</version>
       <repository>http://scala-tools.org/repo-releases</repository>
       <description>A simple scala project</description>
     </archetype>
@@ -244,5 +244,17 @@
       <version>1.0.0</version>
       <description>A simple archetype for create custom JSF components using 
MyFaces</description>
     </archetype>
+    <archetype>
+      <groupId>org.codehaus.groovy.maven.archetypes</groupId>
+      <artifactId>gmaven-archetype-basic</artifactId>
+      <version>1.0-rc-3</version>
+      <description>Groovy basic archetype</description>
+    </archetype>
+    <archetype>
+      <groupId>org.codehaus.groovy.maven.archetypes</groupId>
+      <artifactId>gmaven-archetype-mojo</artifactId>
+      <version>1.0-rc-3</version>
+      <description>Groovy mojo archetype</description>
+    </archetype>
   </archetypes>
 </archetype-catalog>
\ No newline at end of file

Modified: 
maven/archetype/trunk/archetype-common/src/test/java/org/apache/maven/archetype/source/CatalogArchetypeDataSinkTest.java
URL: 
http://svn.apache.org/viewvc/maven/archetype/trunk/archetype-common/src/test/java/org/apache/maven/archetype/source/CatalogArchetypeDataSinkTest.java?rev=688887&r1=688886&r2=688887&view=diff
==============================================================================
--- 
maven/archetype/trunk/archetype-common/src/test/java/org/apache/maven/archetype/source/CatalogArchetypeDataSinkTest.java
 (original)
+++ 
maven/archetype/trunk/archetype-common/src/test/java/org/apache/maven/archetype/source/CatalogArchetypeDataSinkTest.java
 Mon Aug 25 14:19:19 2008
@@ -86,6 +86,6 @@
 
         int catalogSize = catalog.getArchetypes().size();
 
-        assertEquals( 39, catalogSize );
+        assertEquals( 41, catalogSize );
     }
 }

Modified: 
maven/archetype/trunk/archetype-common/src/test/java/org/apache/maven/archetype/source/WikiArchetypeDataSourceTest.java
URL: 
http://svn.apache.org/viewvc/maven/archetype/trunk/archetype-common/src/test/java/org/apache/maven/archetype/source/WikiArchetypeDataSourceTest.java?rev=688887&r1=688886&r2=688887&view=diff
==============================================================================
--- 
maven/archetype/trunk/archetype-common/src/test/java/org/apache/maven/archetype/source/WikiArchetypeDataSourceTest.java
 (original)
+++ 
maven/archetype/trunk/archetype-common/src/test/java/org/apache/maven/archetype/source/WikiArchetypeDataSourceTest.java
 Mon Aug 25 14:19:19 2008
@@ -17,11 +17,11 @@
         ArchetypeDataSource ads = new InternalCatalogArchetypeDataSource();
         List archetypes = ads.getArchetypeCatalog( p ).getArchetypes();
 
-        assertEquals( 39, archetypes.size() );
+        assertEquals( 41, archetypes.size() );
 
         Archetype a = (Archetype) lookup(Archetype.class.getName());
         archetypes=a.getInternalCatalog().getArchetypes();
 
-        assertEquals( 39, archetypes.size() );
+        assertEquals( 41, archetypes.size() );
     }
 }

Modified: 
maven/archetype/trunk/archetype-common/src/test/java/org/apache/maven/archetype/test/InternalCatalogFromWiki.java
URL: 
http://svn.apache.org/viewvc/maven/archetype/trunk/archetype-common/src/test/java/org/apache/maven/archetype/test/InternalCatalogFromWiki.java?rev=688887&r1=688886&r2=688887&view=diff
==============================================================================
--- 
maven/archetype/trunk/archetype-common/src/test/java/org/apache/maven/archetype/test/InternalCatalogFromWiki.java
 (original)
+++ 
maven/archetype/trunk/archetype-common/src/test/java/org/apache/maven/archetype/test/InternalCatalogFromWiki.java
 Mon Aug 25 14:19:19 2008
@@ -27,7 +27,10 @@
 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.apache.maven.archetype.common.ArchetypeArtifactManager;
 import org.apache.maven.archetype.common.ArchetypeRegistryManager;
+import org.apache.maven.archetype.metadata.ArchetypeDescriptor;
+import org.apache.maven.archetype.metadata.RequiredProperty;
 import org.apache.maven.archetype.source.ArchetypeDataSource;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.codehaus.plexus.PlexusTestCase;
@@ -53,14 +56,14 @@
         outputDirectory.mkdirs();
 
         org.apache.maven.archetype.Archetype plexusarchetype = 
(org.apache.maven.archetype.Archetype) 
lookup(org.apache.maven.archetype.Archetype.class.getName());
+        ArchetypeArtifactManager aam = (ArchetypeArtifactManager) 
lookup(ArchetypeArtifactManager.class.getName());
+        ArchetypeRegistryManager arm = (ArchetypeRegistryManager) 
lookup(ArchetypeRegistryManager.class.getName());
 
 
-        Properties properties = new Properties();
-
 //        ArchetypeDataSource ads =  (ArchetypeDataSource) lookup( 
ArchetypeDataSource.ROLE, "wiki" );
         ArchetypeDataSource ads = new WikiArchetypeDataSource();
 
-        ArchetypeCatalog ac = ads.getArchetypeCatalog(properties);
+        ArchetypeCatalog ac = ads.getArchetypeCatalog(new Properties());
         List modifiedArchetypes = new ArrayList();
         Iterator archetypes = ac.getArchetypes().iterator();
         while (archetypes.hasNext()) {
@@ -88,6 +91,7 @@
         List archetypesRemoved = new ArrayList();
         archetypes = ac.getArchetypes().iterator();
         int count = 1;
+
         while (archetypes.hasNext()) {
             org.apache.maven.archetype.catalog.Archetype a = 
(org.apache.maven.archetype.catalog.Archetype) archetypes.next();
             org.apache.maven.archetype.catalog.Archetype ar = new 
org.apache.maven.archetype.catalog.Archetype();
@@ -99,21 +103,57 @@
             ar.setGoals(a.getGoals());
             ar.setProperties(a.getProperties());
             ar.setRepository(a.getRepository());
+
             if (ar.getRepository() == null) {
                 ar.setRepository("http://repo1.maven.org/maven2";);
             }
             System.err.println("\n\n\n\n\n\nTesting archetype " + ar);
             ArchetypeGenerationRequest request = new 
ArchetypeGenerationRequest(ar).setGroupId("groupId" + 
count).setArtifactId("artifactId" + count).setVersion("version" + 
count).setPackage("package" + 
count).setOutputDirectory(outputDirectory.getPath()).setLocalRepository(localRepository);
+
+            Properties properties = new Properties();
+            if (aam.isFileSetArchetype(a.getGroupId(), a.getArtifactId(), 
"RELEASE", arm.createRepository(
+                    a.getRepository(),
+                    a.getRepository() + "-repo"), localRepository, new 
ArrayList( /*repositories*/))) {
+                ArchetypeDescriptor descriptor = 
aam.getFileSetArchetypeDescriptor(a.getGroupId(), a.getArtifactId(), "RELEASE", 
arm.createRepository(
+                        a.getRepository(),
+                        a.getRepository() + "-repo"), localRepository, new 
ArrayList( /*repositories*/));
+
+                Iterator required = 
descriptor.getRequiredProperties().iterator();
+                while (required.hasNext()) {
+                    RequiredProperty prop = (RequiredProperty) required.next();
+
+                    properties.setProperty(prop.getKey(), 
prop.getDefaultValue() != null && !"".equals(prop.getDefaultValue()) ? 
prop.getDefaultValue() : "test-value");
+                }
+
+            }
+            request.setProperties(properties);
             ArchetypeGenerationResult generationResult = 
plexusarchetype.generateProjectFromArchetype(request);
             if (generationResult != null && generationResult.getCause() != 
null) {
                 ar.setVersion(a.getVersion());
                 request = new 
ArchetypeGenerationRequest(ar).setGroupId("groupId" + 
count).setArtifactId("artifactId" + count).setVersion("version" + 
count).setPackage("package" + 
count).setOutputDirectory(outputDirectory.getPath()).setLocalRepository(localRepository);
+                properties = new Properties();
+                if (aam.isFileSetArchetype(a.getGroupId(), a.getArtifactId(), 
a.getVersion(), arm.createRepository(
+                        a.getRepository(),
+                        a.getRepository() + "-repo"), localRepository, new 
ArrayList( /*repositories*/))) {
+                    ArchetypeDescriptor descriptor = 
aam.getFileSetArchetypeDescriptor(a.getGroupId(), a.getArtifactId(), 
a.getVersion(), arm.createRepository(
+                            a.getRepository(),
+                            a.getRepository() + "-repo"), localRepository, new 
ArrayList( /*repositories*/));
+
+                    Iterator required = 
descriptor.getRequiredProperties().iterator();
+                    while (required.hasNext()) {
+                        RequiredProperty prop = (RequiredProperty) 
required.next();
+
+                        properties.setProperty(prop.getKey(), 
prop.getDefaultValue() != null && !"".equals(prop.getDefaultValue()) ? 
prop.getDefaultValue() : "test-value");
+                    }
+
+                }
+                request.setProperties(properties);
                 generationResult = 
plexusarchetype.generateProjectFromArchetype(request);
                 if (generationResult != null && generationResult.getCause() != 
null) {
                     if 
("http://repo1.maven.org/maven2".equals(ar.getRepository())) {
                         ar.setRepository(null);
                     }
-                    archetypesRemoved.add(ar);
+//                    archetypesRemoved.add(ar);
                 } else {
                     if 
("http://repo1.maven.org/maven2".equals(ar.getRepository())) {
                         ar.setRepository(null);


Reply via email to