Author: rafale Date: Thu Jun 5 13:41:34 2008 New Revision: 663729 URL: http://svn.apache.org/viewvc?rev=663729&view=rev Log: Fix for archetype-179 Updated the wiki catalog retreiving testcase
Modified: maven/archetype/trunk/archetype-common/pom.xml 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/InternalCatalogArchetypesVerification.java maven/archetype/trunk/archetype-common/src/test/java/org/apache/maven/archetype/test/InternalCatalogFromWiki.java Modified: maven/archetype/trunk/archetype-common/pom.xml URL: http://svn.apache.org/viewvc/maven/archetype/trunk/archetype-common/pom.xml?rev=663729&r1=663728&r2=663729&view=diff ============================================================================== --- maven/archetype/trunk/archetype-common/pom.xml (original) +++ maven/archetype/trunk/archetype-common/pom.xml Thu Jun 5 13:41:34 2008 @@ -407,7 +407,7 @@ <configuration> <includes> <include>**/InternalCatalogFromWiki.java</include> - <include>**/InternalCatalogArchetypesVerification.java</include> + <!--include>**/InternalCatalogArchetypesVerification.java</include--> </includes> </configuration> </plugin> 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=663729&r1=663728&r2=663729&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 Thu Jun 5 13:41:34 2008 @@ -1,138 +1,112 @@ -<?xml version="1.0" encoding="UTF-8"?><archetype-catalog> +<?xml version="1.0" encoding="UTF-8"?> +<archetype-catalog> <archetypes> <archetype> <groupId>org.appfuse.archetypes</groupId> <artifactId>appfuse-basic-jsf</artifactId> - <version>2.0</version> - <repository>http://repo1.maven.org/maven2</repository> + <version>RELEASE</version> <description>AppFuse archetype for creating a web application with Hibernate, Spring and JSF</description> </archetype> <archetype> <groupId>org.appfuse.archetypes</groupId> <artifactId>appfuse-basic-spring</artifactId> - <version>2.0</version> - <repository>http://repo1.maven.org/maven2</repository> + <version>RELEASE</version> <description>AppFuse archetype for creating a web application with Hibernate, Spring and Spring MVC</description> </archetype> <archetype> <groupId>org.appfuse.archetypes</groupId> <artifactId>appfuse-basic-struts</artifactId> - <version>2.0</version> - <repository>http://repo1.maven.org/maven2</repository> + <version>RELEASE</version> <description>AppFuse archetype for creating a web application with Hibernate, Spring and Struts 2</description> </archetype> <archetype> <groupId>org.appfuse.archetypes</groupId> <artifactId>appfuse-basic-tapestry</artifactId> - <version>2.0</version> - <repository>http://repo1.maven.org/maven2</repository> + <version>RELEASE</version> <description>AppFuse archetype for creating a web application with Hibernate, Spring and Tapestry 4</description> </archetype> <archetype> <groupId>org.appfuse.archetypes</groupId> <artifactId>appfuse-core</artifactId> - <version>2.0</version> - <repository>http://repo1.maven.org/maven2</repository> + <version>RELEASE</version> <description>AppFuse archetype for creating a jar application with Hibernate and Spring and XFire</description> </archetype> <archetype> <groupId>org.appfuse.archetypes</groupId> <artifactId>appfuse-modular-jsf</artifactId> - <version>2.0</version> - <repository>http://repo1.maven.org/maven2</repository> + <version>RELEASE</version> <description>AppFuse archetype for creating a modular application with Hibernate, Spring and JSF</description> </archetype> <archetype> <groupId>org.appfuse.archetypes</groupId> <artifactId>appfuse-modular-spring</artifactId> - <version>2.0</version> - <repository>http://repo1.maven.org/maven2</repository> + <version>RELEASE</version> <description>AppFuse archetype for creating a modular application with Hibernate, Spring and Spring MVC</description> </archetype> <archetype> <groupId>org.appfuse.archetypes</groupId> <artifactId>appfuse-modular-struts</artifactId> - <version>2.0</version> - <repository>http://repo1.maven.org/maven2</repository> + <version>RELEASE</version> <description>AppFuse archetype for creating a modular application with Hibernate, Spring and Struts 2</description> </archetype> <archetype> <groupId>org.appfuse.archetypes</groupId> <artifactId>appfuse-modular-tapestry</artifactId> - <version>2.0</version> - <repository>http://repo1.maven.org/maven2</repository> + <version>RELEASE</version> <description>AppFuse archetype for creating a modular application with Hibernate, Spring and Tapestry 4</description> </archetype> <archetype> <groupId>org.apache.maven.archetypes</groupId> <artifactId>maven-archetype-j2ee-simple</artifactId> <version>RELEASE</version> - <repository>http://repo1.maven.org/maven2</repository> <description>A simple J2EE Java application</description> </archetype> <archetype> <groupId>org.apache.maven.archetypes</groupId> <artifactId>maven-archetype-marmalade-mojo</artifactId> <version>RELEASE</version> - <repository>http://repo1.maven.org/maven2</repository> <description>A Maven plugin development project using marmalade</description> </archetype> <archetype> <groupId>org.apache.maven.archetypes</groupId> <artifactId>maven-archetype-mojo</artifactId> <version>RELEASE</version> - <repository>http://repo1.maven.org/maven2</repository> <description>A Maven Java plugin development project</description> </archetype> <archetype> <groupId>org.apache.maven.archetypes</groupId> <artifactId>maven-archetype-portlet</artifactId> <version>RELEASE</version> - <repository>http://repo1.maven.org/maven2</repository> <description>A simple portlet application</description> </archetype> <archetype> <groupId>org.apache.maven.archetypes</groupId> <artifactId>maven-archetype-profiles</artifactId> <version>RELEASE</version> - <repository>http://repo1.maven.org/maven2</repository> <description></description> </archetype> <archetype> <groupId>org.apache.maven.archetypes</groupId> <artifactId>maven-archetype-quickstart</artifactId> <version>RELEASE</version> - <repository>http://repo1.maven.org/maven2</repository> <description></description> </archetype> - <!-- missing archetype.xml - <archetype> - <groupId>org.apache.maven.archetypes</groupId> - <artifactId>maven-archetype-simple</artifactId> - <version>RELEASE</version> - <repository>http://repo1.maven.org/maven2</repository> - <description></description> - </archetype> - --> <archetype> <groupId>org.apache.maven.archetypes</groupId> <artifactId>maven-archetype-site-simple</artifactId> <version>RELEASE</version> - <repository>http://repo1.maven.org/maven2</repository> <description>A simple site generation project</description> </archetype> <archetype> <groupId>org.apache.maven.archetypes</groupId> <artifactId>maven-archetype-site</artifactId> <version>RELEASE</version> - <repository>http://repo1.maven.org/maven2</repository> <description>A more complex site project</description> </archetype> <archetype> <groupId>org.apache.maven.archetypes</groupId> <artifactId>maven-archetype-webapp</artifactId> <version>RELEASE</version> - <repository>http://repo1.maven.org/maven2</repository> <description>A simple Java web application</description> </archetype> <archetype> @@ -185,17 +159,9 @@ <description>Archetype to ease the burden of creating a new application based with ADF</description> </archetype> <archetype> - <groupId>net.databinder</groupId> - <artifactId>data-app</artifactId> - <version>1.0</version> - <repository>http://repo1.maven.org/maven2</repository> - <description>A new Databinder application with sources and resources.</description> - </archetype> - <archetype> <groupId>org.jini.maven-jini-plugin</groupId> <artifactId>jini-service-archetype</artifactId> <version>2.0</version> - <repository>http://repo1.maven.org/maven2</repository> <description>Archetype for Jini service project creation</description> </archetype> <archetype> @@ -229,14 +195,13 @@ <archetype> <groupId>org.springframework.osgi</groupId> <artifactId>spring-osgi-bundle-archetype</artifactId> - <version>1.0</version> - <repository>http://repo1.maven.org/maven2</repository> + <version>1.0.2</version> <description>Spring-OSGi archetype</description> </archetype> <archetype> <groupId>com.atlassian.maven.archetypes</groupId> <artifactId>confluence-plugin-archetype</artifactId> - <version>4</version> + <version>RELEASE</version> <repository>https://maven.atlassian.com/public</repository> <description>Atlassian Confluence plugin archetype</description> </archetype> @@ -251,31 +216,21 @@ <groupId>net.sf.maven-har</groupId> <artifactId>maven-archetype-har</artifactId> <version>0.9</version> - <repository>http://repo1.maven.org/maven2</repository> <description>Hibernate Archive</description> </archetype> <archetype> <groupId>net.sf.maven-sar</groupId> <artifactId>maven-archetype-sar</artifactId> <version>0.9</version> - <repository>http://repo1.maven.org/maven2</repository> <description>JBoss Service Archive</description> </archetype> <archetype> <groupId>org.apache.wicket</groupId> <artifactId>wicket-archetype-quickstart</artifactId> - <version>1.3.0-beta3</version> - <repository>http://repo1.maven.org/maven2</repository> + <version>1.3.2</version> <description>A simple Apache Wicket project</description> </archetype> <archetype> - <groupId>org.apache.tapestry</groupId> - <artifactId>quickstart</artifactId> - <version>LATEST</version> - <repository>http://tapestry.formos.com/maven-snapshot-repository/</repository> - <description>A simple Apache Tapestry 5 Project</description> - </archetype> - <archetype> <groupId>org.scala-tools.archetypes</groupId> <artifactId>scala-archetype-simple</artifactId> <version>1.1</version> @@ -285,37 +240,58 @@ <archetype> <groupId>net.liftweb</groupId> <artifactId>lift-archetype-blank</artifactId> - <version>0.6</version> + <version>RELEASE</version> <repository>http://scala-tools.org/repo-releases</repository> <description>A blank/empty liftweb project</description> </archetype> <archetype> <groupId>net.liftweb</groupId> <artifactId>lift-archetype-basic</artifactId> - <version>0.6</version> + <version>RELEASE</version> <repository>http://scala-tools.org/repo-releases</repository> <description>The basic (liftweb) project</description> </archetype> <archetype> <groupId>org.apache.cocoon</groupId> <artifactId>cocoon-22-archetype-block-plain</artifactId> - <version>1.0.0-RC2</version> - <repository>http://repo1.maven.org/maven2</repository> + <version>RELEASE</version> <description>[http://cocoon.apache.org/2.2/maven-plugins/]</description> </archetype> <archetype> <groupId>org.apache.cocoon</groupId> <artifactId>cocoon-22-archetype-block</artifactId> - <version>1.0.0-RC2</version> - <repository>http://repo1.maven.org/maven2</repository> + <version>RELEASE</version> <description>[http://cocoon.apache.org/2.2/maven-plugins/]</description> </archetype> <archetype> <groupId>org.apache.cocoon</groupId> <artifactId>cocoon-22-archetype-webapp</artifactId> - <version>1.0.0-RC2</version> - <repository>http://repo1.maven.org/maven2</repository> + <version>RELEASE</version> <description>[http://cocoon.apache.org/2.2/maven-plugins/]</description> </archetype> + <archetype> + <groupId>org.apache.myfaces.buildtools</groupId> + <artifactId>myfaces-archetype-helloworld</artifactId> + <version>1.0.0</version> + <description>A simple archetype using MyFaces</description> + </archetype> + <archetype> + <groupId>org.apache.myfaces.buildtools</groupId> + <artifactId>myfaces-archetype-helloworld-facelets</artifactId> + <version>1.0.0</version> + <description>A simple archetype using MyFaces and facelets</description> + </archetype> + <archetype> + <groupId>org.apache.myfaces.buildtools</groupId> + <artifactId>myfaces-archetype-trinidad</artifactId> + <version>1.0.0</version> + <description>A simple archetype using Myfaces and Trinidad</description> + </archetype> + <archetype> + <groupId>org.apache.myfaces.buildtools</groupId> + <artifactId>myfaces-archetype-jsfcomponents</artifactId> + <version>1.0.0</version> + <description>A simple archetype for create custom JSF components using MyFaces</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=663729&r1=663728&r2=663729&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 Thu Jun 5 13:41:34 2008 @@ -86,6 +86,6 @@ int catalogSize = catalog.getArchetypes().size(); - assertEquals( 44, catalogSize ); + assertEquals( 46, 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=663729&r1=663728&r2=663729&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 Thu Jun 5 13:41:34 2008 @@ -18,11 +18,11 @@ ArchetypeDataSource ads = new InternalCatalogArchetypeDataSource(); List archetypes = ads.getArchetypeCatalog( p ).getArchetypes(); - assertEquals( 44, archetypes.size() ); + assertEquals( 46, archetypes.size() ); Archetype a = (Archetype) lookup(Archetype.class.getName()); archetypes=a.getInternalCatalog().getArchetypes(); - assertEquals( 44, archetypes.size() ); + assertEquals( 46, archetypes.size() ); } } Modified: maven/archetype/trunk/archetype-common/src/test/java/org/apache/maven/archetype/test/InternalCatalogArchetypesVerification.java URL: http://svn.apache.org/viewvc/maven/archetype/trunk/archetype-common/src/test/java/org/apache/maven/archetype/test/InternalCatalogArchetypesVerification.java?rev=663729&r1=663728&r2=663729&view=diff ============================================================================== --- maven/archetype/trunk/archetype-common/src/test/java/org/apache/maven/archetype/test/InternalCatalogArchetypesVerification.java (original) +++ maven/archetype/trunk/archetype-common/src/test/java/org/apache/maven/archetype/test/InternalCatalogArchetypesVerification.java Thu Jun 5 13:41:34 2008 @@ -16,14 +16,18 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.maven.archetype.test; import java.io.File; +import java.io.StringWriter; +import java.util.ArrayList; import java.util.Iterator; +import java.util.List; import org.apache.maven.archetype.Archetype; import org.apache.maven.archetype.ArchetypeGenerationRequest; +import org.apache.maven.archetype.ArchetypeGenerationResult; import org.apache.maven.archetype.catalog.ArchetypeCatalog; +import org.apache.maven.archetype.catalog.io.xpp3.ArchetypeCatalogXpp3Writer; import org.apache.maven.archetype.common.ArchetypeRegistryManager; import org.apache.maven.artifact.repository.ArtifactRepository; import org.codehaus.plexus.PlexusTestCase; @@ -32,47 +36,69 @@ * * @author rafale */ -public class InternalCatalogArchetypesVerification - extends PlexusTestCase{ +public class InternalCatalogArchetypesVerification + extends PlexusTestCase { - + public void testInternalCatalog() + throws Exception { + ArchetypeRegistryManager registryManager = (ArchetypeRegistryManager) lookup(ArchetypeRegistryManager.ROLE); + + ArtifactRepository localRepository = registryManager.createRepository(new File(getBasedir(), + "target/test-classes/repositories/local").toURI(). + toURL(). + toExternalForm(), + "local-repo"); - public void testInternalCatalog () - throws Exception - { - ArchetypeRegistryManager registryManager = (ArchetypeRegistryManager) lookup( ArchetypeRegistryManager.ROLE ); - - ArtifactRepository localRepository = registryManager.createRepository( new File( getBasedir(), - "target/test-classes/repositories/local" ).toURI(). - toURL(). - toExternalForm(), - "local-repo" ); - File outputDirectory = new File(getBasedir(), "target/internal-archetypes-projects"); outputDirectory.mkdirs(); - - Archetype archetype = (Archetype) lookup ( Archetype.class.getName() ); - ArchetypeCatalog result = archetype.getInternalCatalog (); + Archetype archetype = (Archetype) lookup(Archetype.class.getName()); + + ArchetypeCatalog result = archetype.getInternalCatalog(); - Iterator archetypes = result.getArchetypes ().iterator (); + List archetypesUsed = new ArrayList(); + List archetypesRemoved = new ArrayList(); + Iterator archetypes = result.getArchetypes().iterator(); int count = 1; - while ( archetypes.hasNext () ) - { - org.apache.maven.archetype.catalog.Archetype a = - (org.apache.maven.archetype.catalog.Archetype) archetypes.next (); - - System.err.println("\n\n\n\n\n\nTesting archetype "+a); - ArchetypeGenerationRequest request = new ArchetypeGenerationRequest ( a ) - .setGroupId ( "groupId" + count ) - .setArtifactId ( "artifactId" + count ) - .setVersion ( "version" + count ) - .setPackage ( "package" + count ) - .setOutputDirectory(outputDirectory.getPath()) - .setLocalRepository( localRepository ); - archetype.generateProjectFromArchetype ( request ); + 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(); + + ar.setGroupId(a.getGroupId()); + ar.setArtifactId(a.getArtifactId()); + ar.setVersion("RELEASE"); + ar.setDescription(a.getDescription()); + 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); + ArchetypeGenerationResult generationResult = archetype.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); + generationResult = archetype.generateProjectFromArchetype(request); + if (generationResult != null && generationResult.getCause() != null) { + archetypesRemoved.add(a); + } else { + archetypesUsed.add(a); + } + } else { + archetypesUsed.add(a); + } count++; System.err.println("\n\n\n\n\n"); } + result.setArchetypes(archetypesUsed); + + StringWriter sw = new StringWriter(); + ArchetypeCatalogXpp3Writer acxw = new ArchetypeCatalogXpp3Writer(); + acxw.write(sw, result); + + System.err.println("Resulting catalog is\n" + sw.toString()); + System.err.println("Removed archetypes are \n" + archetypesRemoved); } } 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=663729&r1=663728&r2=663729&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 Thu Jun 5 13:41:34 2008 @@ -14,14 +14,22 @@ * limitations under the License. * under the License. */ - package org.apache.maven.archetype.test; +import java.io.File; import java.io.StringWriter; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; import java.util.Properties; +import org.apache.maven.archetype.ArchetypeGenerationRequest; +import org.apache.maven.archetype.ArchetypeGenerationResult; +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.ArchetypeRegistryManager; import org.apache.maven.archetype.source.ArchetypeDataSource; +import org.apache.maven.artifact.repository.ArtifactRepository; import org.codehaus.plexus.PlexusTestCase; /** @@ -29,25 +37,106 @@ * @author rafale */ public class InternalCatalogFromWiki - extends PlexusTestCase { + extends PlexusTestCase { + + public void testInternalCatalog() + throws Exception { + ArchetypeRegistryManager registryManager = (ArchetypeRegistryManager) lookup(ArchetypeRegistryManager.ROLE); + + ArtifactRepository localRepository = registryManager.createRepository(new File(getBasedir(), + "target/test-classes/repositories/local").toURI(). + toURL(). + toExternalForm(), + "local-repo"); + + File outputDirectory = new File(getBasedir(), "target/internal-archetypes-projects"); + outputDirectory.mkdirs(); + + org.apache.maven.archetype.Archetype plexusarchetype = (org.apache.maven.archetype.Archetype) lookup(org.apache.maven.archetype.Archetype.class.getName()); + - public void testInternalCatalog () - throws Exception - { Properties properties = new Properties(); - + // ArchetypeDataSource ads = (ArchetypeDataSource) lookup( ArchetypeDataSource.ROLE, "wiki" ); - ArchetypeDataSource ads = new WikiArchetypeDataSource(); - - ArchetypeCatalog ac=ads.getArchetypeCatalog(properties); - - System.out.println("AR="+ac.getArchetypes()); - - StringWriter sw=new StringWriter(); - - ArchetypeCatalogXpp3Writer acxw=new ArchetypeCatalogXpp3Writer(); + ArchetypeDataSource ads = new WikiArchetypeDataSource(); + + ArchetypeCatalog ac = ads.getArchetypeCatalog(properties); + List modifiedArchetypes = new ArrayList(); + Iterator archetypes = ac.getArchetypes().iterator(); + while (archetypes.hasNext()) { + Archetype archetype = (Archetype) archetypes.next(); + if (archetype.getRepository() != null && + archetype.getRepository().contains("repo1.apache.org/maven2")) { + archetype.setRepository(null); + } + modifiedArchetypes.add(archetype); + } + ac.setArchetypes(modifiedArchetypes); + + System.out.println("AR=" + ac.getArchetypes()); + + StringWriter sw = new StringWriter(); + + ArchetypeCatalogXpp3Writer acxw = new ArchetypeCatalogXpp3Writer(); acxw.write(sw, ac); - - System.out.println("AC="+sw.toString()); + + System.out.println("AC=" + sw.toString()); + + + + List archetypesUsed = new ArrayList(); + 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(); + + ar.setGroupId(a.getGroupId()); + ar.setArtifactId(a.getArtifactId()); + ar.setVersion("RELEASE"); + ar.setDescription(a.getDescription()); + 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); + 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); + 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); + } else { + if ("http://repo1.maven.org/maven2".equals(ar.getRepository())) { + ar.setRepository(null); + } + archetypesUsed.add(ar); + } + } else { + if ("http://repo1.maven.org/maven2".equals(ar.getRepository())) { + ar.setRepository(null); + } + archetypesUsed.add(ar); + } + count++; + System.err.println("\n\n\n\n\n"); + } + ac = new ArchetypeCatalog(); + ac.setArchetypes(archetypesUsed); + + sw = new StringWriter(); + acxw = new ArchetypeCatalogXpp3Writer(); + acxw.write(sw, ac); + + System.err.println("Resulting catalog is\n" + sw.toString()); + System.err.println("Removed archetypes are \n" + archetypesRemoved); } }