maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rfscho...@apache.org
Subject [3/6] maven-archetype git commit: getArchetypeCatalog now uses actual locaRepository
Date Sat, 28 Jan 2017 12:46:16 GMT
getArchetypeCatalog now uses actual locaRepository


Project: http://git-wip-us.apache.org/repos/asf/maven-archetype/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-archetype/commit/69a9513a
Tree: http://git-wip-us.apache.org/repos/asf/maven-archetype/tree/69a9513a
Diff: http://git-wip-us.apache.org/repos/asf/maven-archetype/diff/69a9513a

Branch: refs/heads/master
Commit: 69a9513ac5e3be7ff56462e8e034192abe75c9f2
Parents: 7571fa5
Author: rfscholte <rfscholte@apache.org>
Authored: Fri Jan 27 21:20:25 2017 +0100
Committer: rfscholte <rfscholte@apache.org>
Committed: Fri Jan 27 21:20:25 2017 +0100

----------------------------------------------------------------------
 .../maven/archetype/ArchetypeManager.java       |  19 +--
 .../archetype/DefaultArchetypeManager.java      |  20 +--
 .../archetype/source/ArchetypeDataSource.java   |   4 +-
 .../source/CatalogArchetypeDataSource.java      | 130 +-----------------
 .../InternalCatalogArchetypeDataSource.java     |  11 +-
 .../source/LocalCatalogArchetypeDataSource.java | 137 +++++++++++++++++++
 .../RemoteCatalogArchetypeDataSource.java       |   8 +-
 .../maven/archetype/ArchetypeCatalogsTest.java  |  24 +++-
 .../source/WikiArchetypeDataSource.java         |   2 +-
 .../source/WikiArchetypeDataSourceTest.java     |   5 +-
 .../archetype/test/ArchetypeGenerationTest.java |  16 +--
 .../ui/generation/DefaultArchetypeSelector.java |  20 +--
 12 files changed, 210 insertions(+), 186 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/69a9513a/archetype-common/src/main/java/org/apache/maven/archetype/ArchetypeManager.java
----------------------------------------------------------------------
diff --git a/archetype-common/src/main/java/org/apache/maven/archetype/ArchetypeManager.java
b/archetype-common/src/main/java/org/apache/maven/archetype/ArchetypeManager.java
index f14f8a8..fea2d1a 100644
--- a/archetype-common/src/main/java/org/apache/maven/archetype/ArchetypeManager.java
+++ b/archetype-common/src/main/java/org/apache/maven/archetype/ArchetypeManager.java
@@ -58,38 +58,33 @@ public interface ArchetypeManager
     ArchetypeCatalog getInternalCatalog();
 
     /**
-     * Gives the catalog of archetypes located in <code>${user.home}/.m2/repository/archetype-catalog.xml</code>.
-     * 
-     * @return the catalog.
-     */
-    ArchetypeCatalog getDefaultLocalCatalog();
-
-    /**
      * Gives the catalog of archetypes located in the given path.
      * if path is a file, it used as is.
      * if path is a directory, archetype-catalog.xml is appended to it.
      * 
-     * @param path the catalog file path or directory containing the catalog file.
+     * @param buildingRequest the catalog file path or directory containing the catalog file.
      * @return the catalog.
      */
-    ArchetypeCatalog getLocalCatalog( String path );
+    ArchetypeCatalog getLocalCatalog( ProjectBuildingRequest buildingRequest );
 
     /**
      * Gives the catalog of archetypes located at
      * <code>http://repo.maven.apache.org/maven2/archetype-catalog.xml</code>.
+     * @param buildingRequest TODO
      * 
      * @return the catalog.
      */
-    ArchetypeCatalog getRemoteCatalog();
+    ArchetypeCatalog getRemoteCatalog( ProjectBuildingRequest buildingRequest );
 
     /**
      * Gives the catalog of archetypes located at the given url.
      * if the url doesn't define a catalog, then <code>'archetype-catalog.xml'</code>
is appended to it for search.
-     * 
+     * @param buildingRequest TODO
      * @param url the catalog url or base url containing the catalog file.
+     * 
      * @return the catalog.
      */
-    ArchetypeCatalog getRemoteCatalog( String url );
+    ArchetypeCatalog getRemoteCatalog( ProjectBuildingRequest buildingRequest, String url
);
 
     /**
      * Creates a jar file for an archetype.

http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/69a9513a/archetype-common/src/main/java/org/apache/maven/archetype/DefaultArchetypeManager.java
----------------------------------------------------------------------
diff --git a/archetype-common/src/main/java/org/apache/maven/archetype/DefaultArchetypeManager.java
b/archetype-common/src/main/java/org/apache/maven/archetype/DefaultArchetypeManager.java
index cd2f216..301b8af 100644
--- a/archetype-common/src/main/java/org/apache/maven/archetype/DefaultArchetypeManager.java
+++ b/archetype-common/src/main/java/org/apache/maven/archetype/DefaultArchetypeManager.java
@@ -172,7 +172,7 @@ public class DefaultArchetypeManager
         {
             ArchetypeDataSource source = archetypeSources.get( "internal-catalog" );
 
-            return source.getArchetypeCatalog( new Properties() );
+            return source.getArchetypeCatalog( null, new Properties() );
         }
         catch ( ArchetypeDataSourceException e )
         {
@@ -180,20 +180,14 @@ public class DefaultArchetypeManager
         }
     }
 
-    public ArchetypeCatalog getDefaultLocalCatalog()
-    {
-        return getLocalCatalog( "${user.home}/.m2/archetype-catalog.xml" );
-    }
-
-    public ArchetypeCatalog getLocalCatalog( String path )
+    public ArchetypeCatalog getLocalCatalog( ProjectBuildingRequest buildingRequest )
     {
         try
         {
             Properties properties = new Properties();
-            properties.setProperty( "file", path );
             ArchetypeDataSource source = archetypeSources.get( "catalog" );
 
-            return source.getArchetypeCatalog( properties );
+            return source.getArchetypeCatalog( buildingRequest, properties );
         }
         catch ( ArchetypeDataSourceException e )
         {
@@ -201,12 +195,12 @@ public class DefaultArchetypeManager
         }
     }
 
-    public ArchetypeCatalog getRemoteCatalog()
+    public ArchetypeCatalog getRemoteCatalog( ProjectBuildingRequest buildingRequest )
     {
-        return getRemoteCatalog( "http://repo.maven.apache.org/maven2" );
+        return getRemoteCatalog( buildingRequest, "http://repo.maven.apache.org/maven2" );
     }
 
-    public ArchetypeCatalog getRemoteCatalog( String url )
+    public ArchetypeCatalog getRemoteCatalog( ProjectBuildingRequest buildingRequest, String
url )
     {
         try
         {
@@ -214,7 +208,7 @@ public class DefaultArchetypeManager
             properties.setProperty( "repository", url );
             ArchetypeDataSource source = archetypeSources.get( "remote-catalog" );
 
-            return source.getArchetypeCatalog( properties );
+            return source.getArchetypeCatalog( buildingRequest, properties );
         }
         catch ( ArchetypeDataSourceException e )
         {

http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/69a9513a/archetype-common/src/main/java/org/apache/maven/archetype/source/ArchetypeDataSource.java
----------------------------------------------------------------------
diff --git a/archetype-common/src/main/java/org/apache/maven/archetype/source/ArchetypeDataSource.java
b/archetype-common/src/main/java/org/apache/maven/archetype/source/ArchetypeDataSource.java
index dc87a69..05b416f 100644
--- a/archetype-common/src/main/java/org/apache/maven/archetype/source/ArchetypeDataSource.java
+++ b/archetype-common/src/main/java/org/apache/maven/archetype/source/ArchetypeDataSource.java
@@ -36,9 +36,9 @@ import java.util.Properties;
  */
 public interface ArchetypeDataSource
 {
-    String ROLE = ArchetypeDataSource.class.getName();
+    String ARCHETYPE_CATALOG_FILENAME = "archetype-catalog.xml";
 
-    ArchetypeCatalog getArchetypeCatalog( Properties properties )
+    ArchetypeCatalog getArchetypeCatalog( ProjectBuildingRequest buildingRequest, Properties
properties )
         throws ArchetypeDataSourceException;
 
     void updateCatalog( ProjectBuildingRequest buildingRequest, Archetype archetype )

http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/69a9513a/archetype-common/src/main/java/org/apache/maven/archetype/source/CatalogArchetypeDataSource.java
----------------------------------------------------------------------
diff --git a/archetype-common/src/main/java/org/apache/maven/archetype/source/CatalogArchetypeDataSource.java
b/archetype-common/src/main/java/org/apache/maven/archetype/source/CatalogArchetypeDataSource.java
index 4acdd44..27a49a7 100644
--- a/archetype-common/src/main/java/org/apache/maven/archetype/source/CatalogArchetypeDataSource.java
+++ b/archetype-common/src/main/java/org/apache/maven/archetype/source/CatalogArchetypeDataSource.java
@@ -19,145 +19,29 @@ package org.apache.maven.archetype.source;
  * under the License.
  */
 
-import org.apache.maven.archetype.catalog.Archetype;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.Reader;
+import java.io.Writer;
+
 import org.apache.maven.archetype.catalog.ArchetypeCatalog;
 import org.apache.maven.archetype.catalog.io.xpp3.ArchetypeCatalogXpp3Reader;
 import org.apache.maven.archetype.catalog.io.xpp3.ArchetypeCatalogXpp3Writer;
-import org.apache.maven.project.ProjectBuildingRequest;
-import org.apache.maven.shared.repository.RepositoryManager;
-import org.codehaus.plexus.component.annotations.Component;
-import org.codehaus.plexus.component.annotations.Requirement;
 import org.codehaus.plexus.logging.AbstractLogEnabled;
 import org.codehaus.plexus.util.IOUtil;
-import org.codehaus.plexus.util.ReaderFactory;
-import org.codehaus.plexus.util.StringUtils;
 import org.codehaus.plexus.util.WriterFactory;
 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
 
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.Reader;
-import java.io.Writer;
-import java.util.Iterator;
-import java.util.Properties;
-
 /**
  * @author Jason van Zyl
  */
-@Component( role = ArchetypeDataSource.class, hint = "catalog" )
-public class CatalogArchetypeDataSource
+public abstract  class CatalogArchetypeDataSource
     extends AbstractLogEnabled
     implements ArchetypeDataSource
 {
-    @Requirement
-    private RepositoryManager repositoryManager;
-    
     public static final String ARCHETYPE_CATALOG_PROPERTY = "file";
 
-    public static final String ARCHETYPE_CATALOG_FILENAME = "archetype-catalog.xml";
-
-    public static final File USER_HOME = new File( System.getProperty( "user.home" ) );
-
-    public static final File MAVEN_CONFIGURATION = new File( USER_HOME, ".m2" );
-
-    public static final File DEFAULT_ARCHETYPE_CATALOG = new File( MAVEN_CONFIGURATION, ARCHETYPE_CATALOG_FILENAME
);
-
-    public void updateCatalog( ProjectBuildingRequest buildingRequest, Archetype archetype
)
-        throws ArchetypeDataSourceException
-    {
-        File localRepo = repositoryManager.getLocalRepositoryBasedir( buildingRequest );
-        
-        File catalogFile = new File( localRepo, ARCHETYPE_CATALOG_FILENAME );
-
-        getLogger().debug( "Using catalog " + catalogFile.getAbsolutePath() );
-
-        ArchetypeCatalog catalog;
-        if ( catalogFile.exists() )
-        {
-            try
-            {
-                getLogger().debug( "Reading the catalog " + catalogFile );
-                catalog = readCatalog( ReaderFactory.newXmlReader( catalogFile ) );
-            }
-            catch ( FileNotFoundException ex )
-            {
-                getLogger().debug( "Catalog file don't exist" );
-                catalog = new ArchetypeCatalog();
-            }
-            catch ( IOException e )
-            {
-                throw new ArchetypeDataSourceException( "Error reading archetype catalog.",
e );
-            }
-        }
-        else
-        {
-            getLogger().debug( "Catalog file don't exist" );
-            catalog = new ArchetypeCatalog();
-        }
-
-        Iterator<Archetype> archetypes = catalog.getArchetypes().iterator();
-        boolean found = false;
-        Archetype newArchetype = archetype;
-        while ( !found && archetypes.hasNext() )
-        {
-            Archetype a = (Archetype) archetypes.next();
-            if ( a.getGroupId().equals( archetype.getGroupId() )
-                && a.getArtifactId().equals( archetype.getArtifactId() ) )
-            {
-                newArchetype = a;
-                found = true;
-            }
-        }
-        if ( !found )
-        {
-            catalog.addArchetype( newArchetype );
-        }
-
-        newArchetype.setVersion( archetype.getVersion() );
-        newArchetype.setRepository( archetype.getRepository() );
-        newArchetype.setDescription( archetype.getDescription() );
-        newArchetype.setProperties( archetype.getProperties() );
-        newArchetype.setGoals( archetype.getGoals() );
-
-        writeLocalCatalog( catalog, catalogFile );
-    }
-
-    public ArchetypeCatalog getArchetypeCatalog( Properties properties )
-        throws ArchetypeDataSourceException
-    {
-        String s = properties.getProperty( ARCHETYPE_CATALOG_PROPERTY );
-
-        s = StringUtils.replace( s, "${user.home}", System.getProperty( "user.home" ) );
-
-        File catalogFile = new File( s );
-        if ( catalogFile.exists() && catalogFile.isDirectory() )
-        {
-            catalogFile = new File( catalogFile, ARCHETYPE_CATALOG_FILENAME );
-        }
-        getLogger().debug( "Using catalog " + catalogFile );
-
-        if ( catalogFile.exists() )
-        {
-            try
-            {
-                return readCatalog( ReaderFactory.newXmlReader( catalogFile ) );
-            }
-            catch ( FileNotFoundException e )
-            {
-                throw new ArchetypeDataSourceException( "The specific archetype catalog does
not exist.", e );
-            }
-            catch ( IOException e )
-            {
-                throw new ArchetypeDataSourceException( "Error reading archetype catalog.",
e );
-            }
-        }
-        else
-        {
-            return new ArchetypeCatalog();
-        }
-    }
-
     protected void writeLocalCatalog( ArchetypeCatalog catalog, File catalogFile )
         throws ArchetypeDataSourceException
     {

http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/69a9513a/archetype-common/src/main/java/org/apache/maven/archetype/source/InternalCatalogArchetypeDataSource.java
----------------------------------------------------------------------
diff --git a/archetype-common/src/main/java/org/apache/maven/archetype/source/InternalCatalogArchetypeDataSource.java
b/archetype-common/src/main/java/org/apache/maven/archetype/source/InternalCatalogArchetypeDataSource.java
index ac89bbe..62ce96a 100644
--- a/archetype-common/src/main/java/org/apache/maven/archetype/source/InternalCatalogArchetypeDataSource.java
+++ b/archetype-common/src/main/java/org/apache/maven/archetype/source/InternalCatalogArchetypeDataSource.java
@@ -19,7 +19,9 @@ package org.apache.maven.archetype.source;
  * under the License.
  */
 
+import org.apache.maven.archetype.catalog.Archetype;
 import org.apache.maven.archetype.catalog.ArchetypeCatalog;
+import org.apache.maven.project.ProjectBuildingRequest;
 import org.codehaus.plexus.component.annotations.Component;
 import org.codehaus.plexus.util.ReaderFactory;
 
@@ -36,7 +38,7 @@ public class InternalCatalogArchetypeDataSource
     extends CatalogArchetypeDataSource
 {
 
-    public ArchetypeCatalog getArchetypeCatalog( Properties properties )
+    public ArchetypeCatalog getArchetypeCatalog( ProjectBuildingRequest buildingRequest,
Properties properties )
         throws ArchetypeDataSourceException
     {
         try
@@ -51,4 +53,11 @@ public class InternalCatalogArchetypeDataSource
             throw new ArchetypeDataSourceException( "Error reading archetype catalog.", e
);
         }
     }
+
+    @Override
+    public void updateCatalog( ProjectBuildingRequest buildingRequest, Archetype archetype
)
+        throws ArchetypeDataSourceException
+    {
+        throw new ArchetypeDataSourceException( "Not supported yet." );
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/69a9513a/archetype-common/src/main/java/org/apache/maven/archetype/source/LocalCatalogArchetypeDataSource.java
----------------------------------------------------------------------
diff --git a/archetype-common/src/main/java/org/apache/maven/archetype/source/LocalCatalogArchetypeDataSource.java
b/archetype-common/src/main/java/org/apache/maven/archetype/source/LocalCatalogArchetypeDataSource.java
new file mode 100644
index 0000000..8bb2d48
--- /dev/null
+++ b/archetype-common/src/main/java/org/apache/maven/archetype/source/LocalCatalogArchetypeDataSource.java
@@ -0,0 +1,137 @@
+package org.apache.maven.archetype.source;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Properties;
+
+import org.apache.maven.archetype.catalog.Archetype;
+import org.apache.maven.archetype.catalog.ArchetypeCatalog;
+import org.apache.maven.project.ProjectBuildingRequest;
+import org.apache.maven.shared.repository.RepositoryManager;
+
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
+import org.codehaus.plexus.util.ReaderFactory;
+
+@Component( role = ArchetypeDataSource.class, hint = "catalog" )
+public class LocalCatalogArchetypeDataSource
+    extends CatalogArchetypeDataSource
+{
+    @Requirement
+    private RepositoryManager repositoryManager;
+
+    public void updateCatalog( ProjectBuildingRequest buildingRequest, Archetype archetype
)
+        throws ArchetypeDataSourceException
+    {
+        File localRepo = repositoryManager.getLocalRepositoryBasedir( buildingRequest );
+
+        File catalogFile = new File( localRepo, ARCHETYPE_CATALOG_FILENAME );
+
+        getLogger().debug( "Using catalog " + catalogFile.getAbsolutePath() );
+
+        ArchetypeCatalog catalog;
+        if ( catalogFile.exists() )
+        {
+            try
+            {
+                getLogger().debug( "Reading the catalog " + catalogFile );
+                catalog = readCatalog( ReaderFactory.newXmlReader( catalogFile ) );
+            }
+            catch ( FileNotFoundException ex )
+            {
+                getLogger().debug( "Catalog file don't exist" );
+                catalog = new ArchetypeCatalog();
+            }
+            catch ( IOException e )
+            {
+                throw new ArchetypeDataSourceException( "Error reading archetype catalog.",
e );
+            }
+        }
+        else
+        {
+            getLogger().debug( "Catalog file don't exist" );
+            catalog = new ArchetypeCatalog();
+        }
+
+        Iterator<Archetype> archetypes = catalog.getArchetypes().iterator();
+        boolean found = false;
+        Archetype newArchetype = archetype;
+        while ( !found && archetypes.hasNext() )
+        {
+            Archetype a = (Archetype) archetypes.next();
+            if ( a.getGroupId().equals( archetype.getGroupId() )
+                && a.getArtifactId().equals( archetype.getArtifactId() ) )
+            {
+                newArchetype = a;
+                found = true;
+            }
+        }
+        if ( !found )
+        {
+            catalog.addArchetype( newArchetype );
+        }
+
+        newArchetype.setVersion( archetype.getVersion() );
+        newArchetype.setRepository( archetype.getRepository() );
+        newArchetype.setDescription( archetype.getDescription() );
+        newArchetype.setProperties( archetype.getProperties() );
+        newArchetype.setGoals( archetype.getGoals() );
+
+        writeLocalCatalog( catalog, catalogFile );
+    }
+
+    public ArchetypeCatalog getArchetypeCatalog( ProjectBuildingRequest buildingRequest,
Properties properties )
+        throws ArchetypeDataSourceException
+    {
+        File localRepo = repositoryManager.getLocalRepositoryBasedir( buildingRequest );
+
+        File catalogFile = new File( localRepo, ARCHETYPE_CATALOG_FILENAME );
+
+        if ( catalogFile.exists() && catalogFile.isDirectory() )
+        {
+            catalogFile = new File( catalogFile, ARCHETYPE_CATALOG_FILENAME );
+        }
+        getLogger().debug( "Using catalog " + catalogFile );
+
+        if ( catalogFile.exists() )
+        {
+            try
+            {
+                return readCatalog( ReaderFactory.newXmlReader( catalogFile ) );
+            }
+            catch ( FileNotFoundException e )
+            {
+                throw new ArchetypeDataSourceException( "The specific archetype catalog does
not exist.", e );
+            }
+            catch ( IOException e )
+            {
+                throw new ArchetypeDataSourceException( "Error reading archetype catalog.",
e );
+            }
+        }
+        else
+        {
+            return new ArchetypeCatalog();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/69a9513a/archetype-common/src/main/java/org/apache/maven/archetype/source/RemoteCatalogArchetypeDataSource.java
----------------------------------------------------------------------
diff --git a/archetype-common/src/main/java/org/apache/maven/archetype/source/RemoteCatalogArchetypeDataSource.java
b/archetype-common/src/main/java/org/apache/maven/archetype/source/RemoteCatalogArchetypeDataSource.java
index 9e4e58d..beda9a4 100644
--- a/archetype-common/src/main/java/org/apache/maven/archetype/source/RemoteCatalogArchetypeDataSource.java
+++ b/archetype-common/src/main/java/org/apache/maven/archetype/source/RemoteCatalogArchetypeDataSource.java
@@ -50,8 +50,7 @@ import org.codehaus.plexus.util.ReaderFactory;
  * @author Jason van Zyl
  */
 @Component( role = ArchetypeDataSource.class, hint = "remote-catalog" )
-public class RemoteCatalogArchetypeDataSource
-    extends CatalogArchetypeDataSource
+public class RemoteCatalogArchetypeDataSource extends CatalogArchetypeDataSource implements
ArchetypeDataSource
 {
     @Requirement
     private Map<String, Wagon> wagons;
@@ -70,7 +69,8 @@ public class RemoteCatalogArchetypeDataSource
      */
     public static final String REPOSITORY_ID = "archetype";
 
-    public ArchetypeCatalog getArchetypeCatalog( Properties properties )
+    @Override
+    public ArchetypeCatalog getArchetypeCatalog( ProjectBuildingRequest buildingRequest,
Properties properties )
         throws ArchetypeDataSourceException
     {
         String repository = properties.getProperty( REPOSITORY_PROPERTY );
@@ -124,6 +124,7 @@ public class RemoteCatalogArchetypeDataSource
 
         // We use wagon to take advantage of a Proxy that has already been setup in a Maven
environment.
         Repository wagonRepository = new Repository( REPOSITORY_ID, repositoryPath );
+        
         AuthenticationInfo authInfo = getAuthenticationInfo( wagonRepository.getId() );
         ProxyInfo proxyInfo = getProxy( wagonRepository.getProtocol() );
 
@@ -262,5 +263,4 @@ public class RemoteCatalogArchetypeDataSource
 
         return null;
     }
-
 }

http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/69a9513a/archetype-common/src/test/java/org/apache/maven/archetype/ArchetypeCatalogsTest.java
----------------------------------------------------------------------
diff --git a/archetype-common/src/test/java/org/apache/maven/archetype/ArchetypeCatalogsTest.java
b/archetype-common/src/test/java/org/apache/maven/archetype/ArchetypeCatalogsTest.java
index 952caa4..c4cc5ec 100644
--- a/archetype-common/src/test/java/org/apache/maven/archetype/ArchetypeCatalogsTest.java
+++ b/archetype-common/src/test/java/org/apache/maven/archetype/ArchetypeCatalogsTest.java
@@ -21,9 +21,13 @@ import org.apache.commons.io.IOUtils;
 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.project.DefaultProjectBuildingRequest;
+import org.apache.maven.project.ProjectBuildingRequest;
+import org.apache.maven.repository.internal.MavenRepositorySystemSession;
 import org.codehaus.plexus.PlexusTestCase;
 import org.mortbay.jetty.Server;
 import org.mortbay.jetty.webapp.WebAppContext;
+import org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager;
 
 import java.io.File;
 import java.io.FileWriter;
@@ -38,9 +42,11 @@ public class ArchetypeCatalogsTest
     public void testRemoteCatalog()
         throws Exception
     {
-        ArchetypeManager archetype = (ArchetypeManager) lookup( ArchetypeManager.class.getName()
);
+        ArchetypeManager archetype = lookup( ArchetypeManager.class );
 
-        ArchetypeCatalog result = archetype.getRemoteCatalog( "http://localhost:" + port
+ "/repo/" );
+        ProjectBuildingRequest buildingRequest = new DefaultProjectBuildingRequest();
+        
+        ArchetypeCatalog result = archetype.getRemoteCatalog( buildingRequest, "http://localhost:"
+ port + "/repo/" );
 
         assertEquals( 1, result.getArchetypes().size() );
         assertEquals( "groupId", result.getArchetypes().get( 0 ).getGroupId() );
@@ -52,11 +58,15 @@ public class ArchetypeCatalogsTest
     public void testLocalCatalog()
         throws Exception
     {
-        ArchetypeManager archetype = (ArchetypeManager) lookup( ArchetypeManager.class.getName()
);
-
-        ArchetypeCatalog result =
-            archetype.getLocalCatalog( getTestFile( "target/test-classes/repositories/test-catalog"
).
-                getAbsolutePath() );
+        ArchetypeManager archetype = lookup( ArchetypeManager.class );
+
+        ProjectBuildingRequest buildingRequest = new DefaultProjectBuildingRequest();
+        MavenRepositorySystemSession repositorySession = new MavenRepositorySystemSession();
+        repositorySession.setLocalRepositoryManager( new SimpleLocalRepositoryManager( getTestFile(
"target/test-classes/repositories/test-catalog" ) ) );
+        buildingRequest.setRepositorySession( repositorySession );
+        
+        
+        ArchetypeCatalog result = archetype.getLocalCatalog( buildingRequest );
 
         assertEquals( 1, result.getArchetypes().size() );
         assertEquals( "groupId", result.getArchetypes().get( 0 ).getGroupId() );

http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/69a9513a/archetype-common/src/test/java/org/apache/maven/archetype/source/WikiArchetypeDataSource.java
----------------------------------------------------------------------
diff --git a/archetype-common/src/test/java/org/apache/maven/archetype/source/WikiArchetypeDataSource.java
b/archetype-common/src/test/java/org/apache/maven/archetype/source/WikiArchetypeDataSource.java
index d6c4442..92e3a60 100644
--- a/archetype-common/src/test/java/org/apache/maven/archetype/source/WikiArchetypeDataSource.java
+++ b/archetype-common/src/test/java/org/apache/maven/archetype/source/WikiArchetypeDataSource.java
@@ -63,7 +63,7 @@ public class WikiArchetypeDataSource
         return val.replaceAll( "\\r|\\n|\\s{2,}|\\[|\\]|\\&nbsp;", "" );
     }
 
-    public ArchetypeCatalog getArchetypeCatalog( Properties properties )
+    public ArchetypeCatalog getArchetypeCatalog( ProjectBuildingRequest buildingRequest,
Properties properties )
         throws ArchetypeDataSourceException
     {
         ArchetypeCatalog ac = new ArchetypeCatalog();

http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/69a9513a/archetype-common/src/test/java/org/apache/maven/archetype/source/WikiArchetypeDataSourceTest.java
----------------------------------------------------------------------
diff --git a/archetype-common/src/test/java/org/apache/maven/archetype/source/WikiArchetypeDataSourceTest.java
b/archetype-common/src/test/java/org/apache/maven/archetype/source/WikiArchetypeDataSourceTest.java
index 4a3b920..4d8936f 100644
--- a/archetype-common/src/test/java/org/apache/maven/archetype/source/WikiArchetypeDataSourceTest.java
+++ b/archetype-common/src/test/java/org/apache/maven/archetype/source/WikiArchetypeDataSourceTest.java
@@ -21,6 +21,7 @@ package org.apache.maven.archetype.source;
 
 import org.apache.maven.archetype.catalog.Archetype;
 import org.apache.maven.archetype.catalog.ArchetypeCatalog;
+import org.apache.maven.project.ProjectBuildingRequest;
 import org.codehaus.plexus.PlexusTestCase;
 
 import java.io.File;
@@ -54,7 +55,9 @@ public class WikiArchetypeDataSourceTest
 
         ArchetypeDataSource ads = new WikiArchetypeDataSource();
 
-        ArchetypeCatalog catalog = ads.getArchetypeCatalog( p );
+        ProjectBuildingRequest buildingRequest = null;
+        
+        ArchetypeCatalog catalog = ads.getArchetypeCatalog( buildingRequest, p );
 
         int catalogSize = catalog.getArchetypes().size();
 

http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/69a9513a/archetype-common/src/test/java/org/apache/maven/archetype/test/ArchetypeGenerationTest.java
----------------------------------------------------------------------
diff --git a/archetype-common/src/test/java/org/apache/maven/archetype/test/ArchetypeGenerationTest.java
b/archetype-common/src/test/java/org/apache/maven/archetype/test/ArchetypeGenerationTest.java
index 7c26d0f..24a9aa8 100644
--- a/archetype-common/src/test/java/org/apache/maven/archetype/test/ArchetypeGenerationTest.java
+++ b/archetype-common/src/test/java/org/apache/maven/archetype/test/ArchetypeGenerationTest.java
@@ -54,10 +54,13 @@ public class ArchetypeGenerationTest
         ArtifactRepository localRepository = registryManager.createRepository(
             new File( getBasedir(), "target/test-classes/repositories/local" )
                 .toURI().toURL().toExternalForm(), "local-repo" );
+        
+        ProjectBuildingRequest buildingRequest = new DefaultProjectBuildingRequest();
+        MavenRepositorySystemSession repositorySession = new MavenRepositorySystemSession();
+        repositorySession.setLocalRepositoryManager( new SimpleLocalRepositoryManager( "target/test-classes/repositories/central"
) );
+        buildingRequest.setRepositorySession( repositorySession );
 
-        ArchetypeCatalog catalog = archetype.getLocalCatalog(
-            new File( getBasedir(), "target/test-classes/repositories/central" ).getAbsolutePath()
-                 );
+        ArchetypeCatalog catalog = archetype.getLocalCatalog( buildingRequest );
 
         System.err.println( "archetypes => " + catalog.getArchetypes() );
         // Here I am just grabbing a OldArchetype but in a UI you would take the OldArchetype
objects and present
@@ -98,13 +101,8 @@ public class ArchetypeGenerationTest
         archetypeRequiredProperties.setProperty( "property-without-default-3", "some-value-3"
);
         archetypeRequiredProperties.setProperty( "property-without-default-4", "some-value-4"
);
         agr.setProperties( archetypeRequiredProperties );
-        
-        ProjectBuildingRequest buildingRequest = new DefaultProjectBuildingRequest();
-        MavenRepositorySystemSession repositorySession = new MavenRepositorySystemSession();
-        repositorySession.setLocalRepositoryManager( new SimpleLocalRepositoryManager( localRepository.getBasedir()
) );
-        buildingRequest.setRepositorySession( repositorySession );
         agr.setProjectBuildingRequest( buildingRequest );
-
+        
         // Then generate away!
 
         ArchetypeGenerationResult result = archetype.generateProjectFromArchetype( agr );

http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/69a9513a/maven-archetype-plugin/src/main/java/org/apache/maven/archetype/ui/generation/DefaultArchetypeSelector.java
----------------------------------------------------------------------
diff --git a/maven-archetype-plugin/src/main/java/org/apache/maven/archetype/ui/generation/DefaultArchetypeSelector.java
b/maven-archetype-plugin/src/main/java/org/apache/maven/archetype/ui/generation/DefaultArchetypeSelector.java
index f3a6fb6..01ec947 100644
--- a/maven-archetype-plugin/src/main/java/org/apache/maven/archetype/ui/generation/DefaultArchetypeSelector.java
+++ b/maven-archetype-plugin/src/main/java/org/apache/maven/archetype/ui/generation/DefaultArchetypeSelector.java
@@ -28,6 +28,7 @@ import org.apache.maven.archetype.exception.ArchetypeSelectionFailure;
 import org.apache.maven.archetype.exception.UnknownArchetype;
 import org.apache.maven.archetype.exception.UnknownGroup;
 import org.apache.maven.archetype.ui.ArchetypeDefinition;
+import org.apache.maven.project.ProjectBuildingRequest;
 import org.codehaus.plexus.component.annotations.Component;
 import org.codehaus.plexus.component.annotations.Requirement;
 import org.codehaus.plexus.components.interactivity.PrompterException;
@@ -68,7 +69,7 @@ public class DefaultArchetypeSelector
             return;
         }
 
-        Map<String, List<Archetype>> archetypes = getArchetypesByCatalog( catalogs
);
+        Map<String, List<Archetype>> archetypes = getArchetypesByCatalog( request.getProjectBuildingRequest(),
catalogs );
 
         if ( StringUtils.isNotBlank( request.getFilter() ) )
         {
@@ -176,7 +177,7 @@ public class DefaultArchetypeSelector
     }
 
 
-    private Map<String, List<Archetype>> getArchetypesByCatalog( String catalogs
)
+    private Map<String, List<Archetype>> getArchetypesByCatalog( ProjectBuildingRequest
buildingRequest, String catalogs )
     {
         if ( catalogs == null )
         {
@@ -193,11 +194,13 @@ public class DefaultArchetypeSelector
             }
             else if ( "local".equalsIgnoreCase( catalog ) )
             {
-                archetypes.put( "local", archetypeManager.getDefaultLocalCatalog().getArchetypes()
);
+                archetypes.put( "local", archetypeManager.getLocalCatalog( buildingRequest
).getArchetypes() );
             }
             else if ( "remote".equalsIgnoreCase( catalog ) )
             {
-                List<Archetype> archetypesFromRemote = archetypeManager.getRemoteCatalog().getArchetypes();
+                List<Archetype> archetypesFromRemote =
+                    archetypeManager.getRemoteCatalog( buildingRequest ).getArchetypes();
+                
                 if ( archetypesFromRemote.size() > 0 )
                 {
                     archetypes.put( "remote", archetypesFromRemote );
@@ -208,15 +211,6 @@ public class DefaultArchetypeSelector
                     archetypes.put( "internal", archetypeManager.getInternalCatalog().getArchetypes()
);
                 }
             }
-            else if ( catalog.startsWith( "file://" ) )
-            {
-                String path = catalog.substring( 7 );
-                archetypes.put( catalog, archetypeManager.getLocalCatalog( path ).getArchetypes()
);
-            }
-            else if ( catalog.startsWith( "http://" ) || catalog.startsWith( "https://" )
)
-            {
-                archetypes.put( catalog, archetypeManager.getRemoteCatalog( catalog ).getArchetypes()
);
-            }
         }
 
         if ( archetypes.size() == 0 )


Mime
View raw message