You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ra...@apache.org on 2008/04/18 18:50:55 UTC

svn commit: r649606 - in /maven/archetype/trunk: archetype-common/src/main/java/org/apache/maven/archetype/ archetype-common/src/main/java/org/apache/maven/archetype/common/ archetype-common/src/main/java/org/apache/maven/archetype/downloader/ archetyp...

Author: rafale
Date: Fri Apr 18 09:50:50 2008
New Revision: 649606

URL: http://svn.apache.org/viewvc?rev=649606&view=rev
Log:
fix for archetype-159
The downloading is now better made and use the remote repositories.

Modified:
    maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/ArchetypeGenerationRequest.java
    maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/common/DefaultArchetypeArtifactManager.java
    maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/downloader/DefaultDownloader.java
    maven/archetype/trunk/archetype-plugin/src/main/java/org/apache/maven/archetype/mojos/CreateProjectFromArchetypeMojo.java
    maven/archetype/trunk/archetype-plugin/src/main/java/org/apache/maven/archetype/ui/ArchetypeFactory.java
    maven/archetype/trunk/archetype-plugin/src/main/java/org/apache/maven/archetype/ui/DefaultArchetypeFactory.java
    maven/archetype/trunk/archetype-plugin/src/main/java/org/apache/maven/archetype/ui/DefaultArchetypeGenerationConfigurator.java
    maven/archetype/trunk/archetype-plugin/src/main/java/org/apache/maven/archetype/ui/DefaultArchetypeSelector.java
    maven/archetype/trunk/archetype-plugin/src/test/java/org/apache/maven/archetype/ui/DefaultArchetypeGenerationConfiguratorTest.java

Modified: maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/ArchetypeGenerationRequest.java
URL: http://svn.apache.org/viewvc/maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/ArchetypeGenerationRequest.java?rev=649606&r1=649605&r2=649606&view=diff
==============================================================================
--- maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/ArchetypeGenerationRequest.java (original)
+++ maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/ArchetypeGenerationRequest.java Fri Apr 18 09:50:50 2008
@@ -43,6 +43,8 @@
 
     private ArtifactRepository localRepository;
 
+    private List remoteArtifactRepositories; 
+    
     private Proxy activeProxy;
 
     private List servers = new ArrayList(  );
@@ -315,4 +317,16 @@
     {
         return servers;
     }
-}
\ No newline at end of file
+    
+    public List getRemoteArtifactRepositories()
+    {
+        return remoteArtifactRepositories;
+    }
+
+    public ArchetypeGenerationRequest setRemoteArtifactRepositories( List remoteArtifactRepositories )
+    {
+        this.remoteArtifactRepositories = remoteArtifactRepositories;
+
+        return this;
+    }
+}

Modified: maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/common/DefaultArchetypeArtifactManager.java
URL: http://svn.apache.org/viewvc/maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/common/DefaultArchetypeArtifactManager.java?rev=649606&r1=649605&r2=649606&view=diff
==============================================================================
--- maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/common/DefaultArchetypeArtifactManager.java (original)
+++ maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/common/DefaultArchetypeArtifactManager.java Fri Apr 18 09:50:50 2008
@@ -1,684 +1,682 @@
-/*
- * 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.
- */
-
-package org.apache.maven.archetype.common;
-
-import org.apache.maven.archetype.downloader.DownloadException;
-import org.apache.maven.archetype.downloader.DownloadNotFoundException;
-import org.apache.maven.archetype.downloader.Downloader;
-import org.apache.maven.archetype.exception.UnknownArchetype;
-import org.apache.maven.archetype.metadata.ArchetypeDescriptor;
-import org.apache.maven.archetype.metadata.io.xpp3.ArchetypeDescriptorXpp3Reader;
-import org.apache.maven.archetype.old.descriptor.ArchetypeDescriptorBuilder;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager;
-import org.apache.maven.model.Model;
-
-import org.codehaus.plexus.logging.AbstractLogEnabled;
-import org.codehaus.plexus.util.StringUtils;
-import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipException;
-import java.util.zip.ZipFile;
-
-/**
- * @plexus.component
- */
-public class DefaultArchetypeArtifactManager
-extends AbstractLogEnabled
-implements ArchetypeArtifactManager
-{
-    /**
-     * @plexus.requirement
-     */
-    private Downloader downloader;
-
-    /**
-     * @plexus.requirement
-     */
-    private PomManager pomManager;
-
-    /**
-     * @plexus.requirement
-     */
-    private RepositoryMetadataManager repositoryMetadataManager;
-
-    public File getArchetypeFile (
-        final String groupId,
-        final String artifactId,
-        final String version,
-        ArtifactRepository archetypeRepository,
-        final ArtifactRepository localRepository,
-        final List repositories
-    )
-    throws UnknownArchetype
-    {
-        try
-        {
-            return
-                downloader.download (
-                    groupId,
-                    artifactId,
-                    version,
-                    archetypeRepository,
-                    localRepository,
-                    repositories
-                );
-        }
-        catch ( DownloadNotFoundException ex )
-        {
-            throw new UnknownArchetype ( ex );
-        }
-        catch ( DownloadException ex )
-        {
-            throw new UnknownArchetype ( ex );
-        }
-    }
-
-    public ClassLoader getArchetypeJarLoader ( File archetypeFile )
-    throws UnknownArchetype
-    {
-        try
-        {
-            URL[] urls = new URL[1];
-
-            urls[0] = archetypeFile.toURI ().toURL ();
-
-            return new URLClassLoader ( urls );
-        }
-        catch ( MalformedURLException e )
-        {
-            throw new UnknownArchetype ( e );
-        }
-    }
-
-    public Model getArchetypePom ( File jar )
-    throws XmlPullParserException, UnknownArchetype, IOException
-    {
-        String pomFileName = null;
-        ZipFile zipFile = getArchetypeZipFile ( jar );
-        Enumeration enumeration = zipFile.entries ();
-        while ( enumeration.hasMoreElements () )
-        {
-            ZipEntry el = (ZipEntry) enumeration.nextElement ();
-
-            String entry = el.getName ();
-            if ( entry.startsWith ( "META-INF" ) && entry.endsWith ( "pom.xml" ) )
-            {
-                pomFileName = entry;
-            }
-        }
-
-        if ( pomFileName == null )
-        {
-            return null;
-        }
-
-        ZipEntry pom =
-            zipFile.getEntry ( StringUtils.replace ( pomFileName, File.separator, "/" ) );
-        if ( pom == null )
-        {
-            pom = zipFile.getEntry ( StringUtils.replace ( pomFileName, "/", File.separator ) );
-        }
-        if ( pom == null )
-        {
-            return null;
-        }
-        return pomManager.readPom ( zipFile.getInputStream ( pom ) );
-    }
-
-    public ZipFile getArchetypeZipFile ( File archetypeFile )
-    throws UnknownArchetype
-    {
-        try
-        {
-            return new ZipFile ( archetypeFile );
-        }
-        catch ( ZipException e )
-        {
-            throw new UnknownArchetype ( e );
-        }
-        catch ( IOException e )
-        {
-            throw new UnknownArchetype ( e );
-        }
-    }
-
-    public boolean isFileSetArchetype ( File archetypeFile )
-    {
-        try
-        {
-            ZipFile zipFile = getArchetypeZipFile ( archetypeFile );
-
-            return isFileSetArchetype ( zipFile );
-        }
-        catch ( XmlPullParserException e )
-        {
-            return false;
-        }
-        catch ( IOException e )
-        {
-            return false;
-        }
-        catch ( UnknownArchetype e )
-        {
-            return false;
-        }
-    }
-
-    public boolean isFileSetArchetype (
-        String groupId,
-        String artifactId,
-        String version,
-        ArtifactRepository archetypeRepository,
-        ArtifactRepository localRepository,
-        List repositories
-    )
-    {
-        try
-        {
-            ZipFile zipFile =
-                getArchetypeZipFile (
-                    getArchetypeFile (
-                        groupId,
-                        artifactId,
-                        version,
-                        archetypeRepository,
-                        localRepository,
-                        repositories
-                    )
-                );
-
-            return isFileSetArchetype ( zipFile );
-        }
-        catch ( XmlPullParserException e )
-        {
-            return false;
-        }
-        catch ( IOException e )
-        {
-            return false;
-        }
-        catch ( UnknownArchetype e )
-        {
-            return false;
-        }
-    }
-
-    public boolean isOldArchetype ( File archetypeFile )
-    {
-        try
-        {
-            ZipFile zipFile = getArchetypeZipFile ( archetypeFile );
-
-            return isOldArchetype ( zipFile );
-        }
-        catch ( XmlPullParserException e )
-        {
-            return false;
-        }
-        catch ( IOException e )
-        {
-            return false;
-        }
-        catch ( UnknownArchetype e )
-        {
-            return false;
-        }
-    }
-
-    public boolean isOldArchetype (
-        String groupId,
-        String artifactId,
-        String version,
-        ArtifactRepository archetypeRepository,
-        ArtifactRepository localRepository,
-        List repositories
-    )
-    {
-        try
-        {
-            ZipFile zipFile =
-                getArchetypeZipFile (
-                    getArchetypeFile (
-                        groupId,
-                        artifactId,
-                        version,
-                        archetypeRepository,
-                        localRepository,
-                        repositories
-                    )
-                );
-
-            return isOldArchetype ( zipFile );
-        }
-        catch ( XmlPullParserException e )
-        {
-            return false;
-        }
-        catch ( IOException e )
-        {
-            return false;
-        }
-        catch ( UnknownArchetype e )
-        {
-            return false;
-        }
-    }
-
-    public boolean exists (
-        String archetypeGroupId,
-        String archetypeArtifactId,
-        String archetypeVersion,
-        ArtifactRepository archetypeRepository,
-        ArtifactRepository localRepository,
-        List remoteRepositories
-    )
-    {
-        try
-        {
-            File archetypeFile =
-                downloader.download (
-                    archetypeGroupId,
-                    archetypeArtifactId,
-                    archetypeVersion,
-                    archetypeRepository,
-                    localRepository,
-                    remoteRepositories
-                );
-
-            return archetypeFile.exists ();
-        }
-        catch ( DownloadException e )
-        {
-            e.printStackTrace ();
-            getLogger ().debug ( "Archetype don't exist", e );
-            return false;
-        }
-        catch ( DownloadNotFoundException e )
-        {
-            e.printStackTrace ();
-            getLogger ().debug ( "Archetype don't exist", e );
-            return false;
-        }
-    }
-
-    public ArchetypeDescriptor getFileSetArchetypeDescriptor ( File archetypeFile )
-    throws UnknownArchetype
-    {
-        try
-        {
-            ZipFile zipFile = getArchetypeZipFile ( archetypeFile );
-
-            return loadFileSetArchetypeDescriptor ( zipFile );
-        }
-        catch ( XmlPullParserException e )
-        {
-            throw new UnknownArchetype ( e );
-        }
-        catch ( IOException e )
-        {
-            throw new UnknownArchetype ( e );
-        }
-    }
-
-    public org.apache.maven.archetype.metadata.ArchetypeDescriptor getFileSetArchetypeDescriptor (
-        String groupId,
-        String artifactId,
-        String version,
-        ArtifactRepository archetypeRepository,
-        ArtifactRepository localRepository,
-        List repositories
-    )
-    throws UnknownArchetype
-    {
-        try
-        {
-            ZipFile zipFile =
-                getArchetypeZipFile (
-                    getArchetypeFile (
-                        groupId,
-                        artifactId,
-                        version,
-                        archetypeRepository,
-                        localRepository,
-                        repositories
-                    )
-                );
-
-            return loadFileSetArchetypeDescriptor ( zipFile );
-        }
-        catch ( XmlPullParserException e )
-        {
-            throw new UnknownArchetype ( e );
-        }
-        catch ( IOException e )
-        {
-            throw new UnknownArchetype ( e );
-        }
-    }
-
-    public List getFilesetArchetypeResources ( File archetypeFile )
-    throws UnknownArchetype
-    {
-        List archetypeResources = new ArrayList ();
-
-        ZipFile zipFile = getArchetypeZipFile ( archetypeFile );
-
-        Enumeration enumeration = zipFile.entries ();
-        while ( enumeration.hasMoreElements () )
-        {
-            ZipEntry entry = (ZipEntry) enumeration.nextElement ();
-
-            if ( !entry.isDirectory ()
-                && entry.getName ().startsWith ( Constants.ARCHETYPE_RESOURCES )
-            )
-            {
-                // not supposed to be file.seperator
-                String resource =
-                    StringUtils.replace (
-                        entry.getName (),
-                        Constants.ARCHETYPE_RESOURCES + "/",
-                        ""
-                    );
-                getLogger ().debug ( "Found resource " + resource );
-                // TODO:FIXME
-                archetypeResources.add ( resource );
-            }
-            else
-            {
-                getLogger ().debug ( "Not resource " + entry.getName () );
-            }
-        }
-        return archetypeResources;
-    }
-
-    public org.apache.maven.archetype.old.descriptor.ArchetypeDescriptor getOldArchetypeDescriptor (
-        File archetypeFile
-    )
-    throws UnknownArchetype
-    {
-        try
-        {
-            ZipFile zipFile = getArchetypeZipFile ( archetypeFile );
-
-            return loadOldArchetypeDescriptor ( zipFile );
-        }
-        catch ( XmlPullParserException e )
-        {
-            throw new UnknownArchetype ( e );
-        }
-        catch ( IOException e )
-        {
-            throw new UnknownArchetype ( e );
-        }
-    }
-
-    public org.apache.maven.archetype.old.descriptor.ArchetypeDescriptor getOldArchetypeDescriptor (
-        String groupId,
-        String artifactId,
-        String version,
-        ArtifactRepository archetypeRepository,
-        ArtifactRepository localRepository,
-        List repositories
-    )
-    throws UnknownArchetype
-    {
-        try
-        {
-            ZipFile zipFile =
-                getArchetypeZipFile (
-                    getArchetypeFile (
-                        groupId,
-                        artifactId,
-                        version,
-                        archetypeRepository,
-                        localRepository,
-                        repositories
-                    )
-                );
-
-            return loadOldArchetypeDescriptor ( zipFile );
-        }
-        catch ( XmlPullParserException e )
-        {
-            throw new UnknownArchetype ( e );
-        }
-        catch ( IOException e )
-        {
-            throw new UnknownArchetype ( e );
-        }
-    }
-
-    private Reader getArchetypeDescriptorReader ( ZipFile zipFile )
-    throws IOException
-    {
-        ZipEntry entry =
-            zipFile.getEntry (
-                StringUtils.replace ( Constants.ARCHETYPE_DESCRIPTOR, File.separator, "/" )
-            );
-
-        if ( entry == null )
-        {
-            getLogger ().debug (
-                "No found " + Constants.ARCHETYPE_DESCRIPTOR + " retrying with windows path"
-            );
-            entry =
-                zipFile.getEntry (
-                    StringUtils.replace ( Constants.ARCHETYPE_DESCRIPTOR, "/", File.separator )
-                );
-        }
-        if ( entry == null )
-        {
-            throw new IOException (
-                "The " + Constants.ARCHETYPE_DESCRIPTOR + " descriptor cannot be found."
-            );
-        }
-
-        InputStream is = zipFile.getInputStream ( entry );
-
-        if ( is == null )
-        {
-            throw new IOException (
-                "The " + Constants.ARCHETYPE_DESCRIPTOR + " descriptor cannot be found."
-            );
-        }
-        return new InputStreamReader ( is );
-    }
-
-    private boolean isFileSetArchetype ( ZipFile zipFile )
-    throws IOException, XmlPullParserException
-    {
-        org.apache.maven.archetype.metadata.ArchetypeDescriptor descriptor =
-            loadFileSetArchetypeDescriptor ( zipFile );
-
-        return descriptor.getName () != null;
-    }
-
-    private boolean isOldArchetype ( ZipFile zipFile )
-    throws IOException, XmlPullParserException
-    {
-        org.apache.maven.archetype.old.descriptor.ArchetypeDescriptor descriptor =
-            loadOldArchetypeDescriptor ( zipFile );
-
-        return descriptor.getId () != null;
-    }
-
-    private org.apache.maven.archetype.metadata.ArchetypeDescriptor loadFileSetArchetypeDescriptor (
-        ZipFile zipFile
-    )
-    throws IOException, XmlPullParserException
-    {
-        Reader reader = getArchetypeDescriptorReader ( zipFile );
-
-        ArchetypeDescriptorXpp3Reader archetypeReader = new ArchetypeDescriptorXpp3Reader ();
-
-        try
-        {
-            return archetypeReader.read ( reader, true );
-        }
-        finally
-        {
-            reader.close ();
-        }
-    }
-
-    private org.apache.maven.archetype.old.descriptor.ArchetypeDescriptor
-    loadOldArchetypeDescriptor ( ZipFile zipFile )
-    throws IOException, XmlPullParserException
-    {
-        ArchetypeDescriptorBuilder builder = new ArchetypeDescriptorBuilder ();
-
-        org.apache.maven.archetype.old.descriptor.ArchetypeDescriptor descriptor = null;
-
-        Reader reader = null;
-        try
-        {
-            reader = getOldArchetypeDescriptorReader ( zipFile );
-
-            descriptor = builder.build ( reader );
-        }
-        catch ( IOException ex )
-        {
-            getLogger ().debug ( "Can not load old archetype", ex );
-        }
-        catch ( XmlPullParserException ex )
-        {
-            getLogger ().debug ( "Can not load old archetype", ex );
-        }
-        finally
-        {
-            if ( reader != null )
-            {
-                reader.close ();
-            }
-        }
-
-        if ( descriptor == null )
-        {
-            try
-            {
-                reader = getOlderArchetypeDescriptorReader ( zipFile );
-
-                descriptor = builder.build ( reader );
-            }
-            finally
-            {
-                if ( reader != null )
-                {
-                    reader.close ();
-                }
-            }
-        }
-
-        return descriptor;
-    }
-
-    private Reader getOldArchetypeDescriptorReader ( ZipFile zipFile )
-    throws IOException
-    {
-        ZipEntry entry =
-            zipFile.getEntry (
-                StringUtils.replace ( Constants.OLD_ARCHETYPE_DESCRIPTOR, File.separator, "/" )
-            );
-
-        if ( entry == null )
-        {
-            getLogger ().debug (
-                "No found " + Constants.OLD_ARCHETYPE_DESCRIPTOR + " retrying with windows path"
-            );
-            entry =
-                zipFile.getEntry (
-                    StringUtils.replace ( Constants.OLD_ARCHETYPE_DESCRIPTOR, "/", File.separator )
-                );
-        }
-
-        if ( entry == null )
-        {
-            throw new IOException (
-                "The " + Constants.OLD_ARCHETYPE_DESCRIPTOR + " descriptor cannot be found."
-            );
-        }
-
-        InputStream is = zipFile.getInputStream ( entry );
-
-        if ( is == null )
-        {
-            throw new IOException (
-                "The " + Constants.OLD_ARCHETYPE_DESCRIPTOR + " descriptor cannot be found."
-            );
-        }
-        return new InputStreamReader ( is );
-    }
-
-    private Reader getOlderArchetypeDescriptorReader ( ZipFile zipFile )
-    throws IOException
-    {
-        ZipEntry entry =
-            zipFile.getEntry (
-                StringUtils.replace ( Constants.OLDER_ARCHETYPE_DESCRIPTOR, File.separator, "/" )
-            );
-
-        if ( entry == null )
-        {
-            getLogger ().debug (
-                "No found " + Constants.OLDER_ARCHETYPE_DESCRIPTOR + " retrying with windows path"
-            );
-            entry =
-                zipFile.getEntry (
-                    StringUtils.replace (
-                        Constants.OLDER_ARCHETYPE_DESCRIPTOR,
-                        "/",
-                        File.separator
-                    )
-                );
-        }
-        if ( entry == null )
-        {
-            throw new IOException (
-                "The " + Constants.OLDER_ARCHETYPE_DESCRIPTOR + " descriptor cannot be found."
-            );
-        }
-
-        InputStream is = zipFile.getInputStream ( entry );
-
-        if ( is == null )
-        {
-            throw new IOException (
-                "The " + Constants.OLDER_ARCHETYPE_DESCRIPTOR + " descriptor cannot be found."
-            );
-        }
-
-        return new InputStreamReader ( is );
-    }
-}
+/*
+ * 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.
+ */
+
+package org.apache.maven.archetype.common;
+
+import org.apache.maven.archetype.downloader.DownloadException;
+import org.apache.maven.archetype.downloader.DownloadNotFoundException;
+import org.apache.maven.archetype.downloader.Downloader;
+import org.apache.maven.archetype.exception.UnknownArchetype;
+import org.apache.maven.archetype.metadata.ArchetypeDescriptor;
+import org.apache.maven.archetype.metadata.io.xpp3.ArchetypeDescriptorXpp3Reader;
+import org.apache.maven.archetype.old.descriptor.ArchetypeDescriptorBuilder;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager;
+import org.apache.maven.model.Model;
+
+import org.codehaus.plexus.logging.AbstractLogEnabled;
+import org.codehaus.plexus.util.StringUtils;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipException;
+import java.util.zip.ZipFile;
+
+/**
+ * @plexus.component
+ */
+public class DefaultArchetypeArtifactManager
+extends AbstractLogEnabled
+implements ArchetypeArtifactManager
+{
+    /**
+     * @plexus.requirement
+     */
+    private Downloader downloader;
+
+    /**
+     * @plexus.requirement
+     */
+    private PomManager pomManager;
+
+    /**
+     * @plexus.requirement
+     */
+    private RepositoryMetadataManager repositoryMetadataManager;
+
+    public File getArchetypeFile (
+        final String groupId,
+        final String artifactId,
+        final String version,
+        ArtifactRepository archetypeRepository,
+        final ArtifactRepository localRepository,
+        final List repositories
+    )
+    throws UnknownArchetype
+    {
+        try
+        {
+            return
+                downloader.download (
+                    groupId,
+                    artifactId,
+                    version,
+                    archetypeRepository,
+                    localRepository,
+                    repositories
+                );
+        }
+        catch ( DownloadNotFoundException ex )
+        {
+            throw new UnknownArchetype ( ex );
+        }
+        catch ( DownloadException ex )
+        {
+            throw new UnknownArchetype ( ex );
+        }
+    }
+
+    public ClassLoader getArchetypeJarLoader ( File archetypeFile )
+    throws UnknownArchetype
+    {
+        try
+        {
+            URL[] urls = new URL[1];
+
+            urls[0] = archetypeFile.toURI ().toURL ();
+
+            return new URLClassLoader ( urls );
+        }
+        catch ( MalformedURLException e )
+        {
+            throw new UnknownArchetype ( e );
+        }
+    }
+
+    public Model getArchetypePom ( File jar )
+    throws XmlPullParserException, UnknownArchetype, IOException
+    {
+        String pomFileName = null;
+        ZipFile zipFile = getArchetypeZipFile ( jar );
+        Enumeration enumeration = zipFile.entries ();
+        while ( enumeration.hasMoreElements () )
+        {
+            ZipEntry el = (ZipEntry) enumeration.nextElement ();
+
+            String entry = el.getName ();
+            if ( entry.startsWith ( "META-INF" ) && entry.endsWith ( "pom.xml" ) )
+            {
+                pomFileName = entry;
+            }
+        }
+
+        if ( pomFileName == null )
+        {
+            return null;
+        }
+
+        ZipEntry pom =
+            zipFile.getEntry ( StringUtils.replace ( pomFileName, File.separator, "/" ) );
+        if ( pom == null )
+        {
+            pom = zipFile.getEntry ( StringUtils.replace ( pomFileName, "/", File.separator ) );
+        }
+        if ( pom == null )
+        {
+            return null;
+        }
+        return pomManager.readPom ( zipFile.getInputStream ( pom ) );
+    }
+
+    public ZipFile getArchetypeZipFile ( File archetypeFile )
+    throws UnknownArchetype
+    {
+        try
+        {
+            return new ZipFile ( archetypeFile );
+        }
+        catch ( ZipException e )
+        {
+            throw new UnknownArchetype ( e );
+        }
+        catch ( IOException e )
+        {
+            throw new UnknownArchetype ( e );
+        }
+    }
+
+    public boolean isFileSetArchetype ( File archetypeFile )
+    {
+        try
+        {
+            ZipFile zipFile = getArchetypeZipFile ( archetypeFile );
+
+            return isFileSetArchetype ( zipFile );
+        }
+        catch ( XmlPullParserException e )
+        {
+            return false;
+        }
+        catch ( IOException e )
+        {
+            return false;
+        }
+        catch ( UnknownArchetype e )
+        {
+            return false;
+        }
+    }
+
+    public boolean isFileSetArchetype (
+        String groupId,
+        String artifactId,
+        String version,
+        ArtifactRepository archetypeRepository,
+        ArtifactRepository localRepository,
+        List repositories
+    )
+    {
+        try
+        {
+            ZipFile zipFile =
+                getArchetypeZipFile (
+                    getArchetypeFile (
+                        groupId,
+                        artifactId,
+                        version,
+                        archetypeRepository,
+                        localRepository,
+                        repositories
+                    )
+                );
+
+            return isFileSetArchetype ( zipFile );
+        }
+        catch ( XmlPullParserException e )
+        {
+            return false;
+        }
+        catch ( IOException e )
+        {
+            return false;
+        }
+        catch ( UnknownArchetype e )
+        {
+            return false;
+        }
+    }
+
+    public boolean isOldArchetype ( File archetypeFile )
+    {
+        try
+        {
+            ZipFile zipFile = getArchetypeZipFile ( archetypeFile );
+
+            return isOldArchetype ( zipFile );
+        }
+        catch ( XmlPullParserException e )
+        {
+            return false;
+        }
+        catch ( IOException e )
+        {
+            return false;
+        }
+        catch ( UnknownArchetype e )
+        {
+            return false;
+        }
+    }
+
+    public boolean isOldArchetype (
+        String groupId,
+        String artifactId,
+        String version,
+        ArtifactRepository archetypeRepository,
+        ArtifactRepository localRepository,
+        List repositories
+    )
+    {
+        try
+        {
+            ZipFile zipFile =
+                getArchetypeZipFile (
+                    getArchetypeFile (
+                        groupId,
+                        artifactId,
+                        version,
+                        archetypeRepository,
+                        localRepository,
+                        repositories
+                    )
+                );
+
+            return isOldArchetype ( zipFile );
+        }
+        catch ( XmlPullParserException e )
+        {
+            return false;
+        }
+        catch ( IOException e )
+        {
+            return false;
+        }
+        catch ( UnknownArchetype e )
+        {
+            return false;
+        }
+    }
+
+    public boolean exists (
+        String archetypeGroupId,
+        String archetypeArtifactId,
+        String archetypeVersion,
+        ArtifactRepository archetypeRepository,
+        ArtifactRepository localRepository,
+        List remoteRepositories
+    )
+    {
+        try
+        {
+            File archetypeFile =
+                downloader.download (
+                    archetypeGroupId,
+                    archetypeArtifactId,
+                    archetypeVersion,
+                    archetypeRepository,
+                    localRepository,
+                    remoteRepositories
+                );
+
+            return archetypeFile.exists ();
+        }
+        catch ( DownloadException e )
+        {
+            getLogger ().debug ( "Archetype don't exist", e );
+            return false;
+        }
+        catch ( DownloadNotFoundException e )
+        {
+            getLogger ().debug ( "Archetype don't exist", e );
+            return false;
+        }
+    }
+
+    public ArchetypeDescriptor getFileSetArchetypeDescriptor ( File archetypeFile )
+    throws UnknownArchetype
+    {
+        try
+        {
+            ZipFile zipFile = getArchetypeZipFile ( archetypeFile );
+
+            return loadFileSetArchetypeDescriptor ( zipFile );
+        }
+        catch ( XmlPullParserException e )
+        {
+            throw new UnknownArchetype ( e );
+        }
+        catch ( IOException e )
+        {
+            throw new UnknownArchetype ( e );
+        }
+    }
+
+    public org.apache.maven.archetype.metadata.ArchetypeDescriptor getFileSetArchetypeDescriptor (
+        String groupId,
+        String artifactId,
+        String version,
+        ArtifactRepository archetypeRepository,
+        ArtifactRepository localRepository,
+        List repositories
+    )
+    throws UnknownArchetype
+    {
+        try
+        {
+            ZipFile zipFile =
+                getArchetypeZipFile (
+                    getArchetypeFile (
+                        groupId,
+                        artifactId,
+                        version,
+                        archetypeRepository,
+                        localRepository,
+                        repositories
+                    )
+                );
+
+            return loadFileSetArchetypeDescriptor ( zipFile );
+        }
+        catch ( XmlPullParserException e )
+        {
+            throw new UnknownArchetype ( e );
+        }
+        catch ( IOException e )
+        {
+            throw new UnknownArchetype ( e );
+        }
+    }
+
+    public List getFilesetArchetypeResources ( File archetypeFile )
+    throws UnknownArchetype
+    {
+        List archetypeResources = new ArrayList ();
+
+        ZipFile zipFile = getArchetypeZipFile ( archetypeFile );
+
+        Enumeration enumeration = zipFile.entries ();
+        while ( enumeration.hasMoreElements () )
+        {
+            ZipEntry entry = (ZipEntry) enumeration.nextElement ();
+
+            if ( !entry.isDirectory ()
+                && entry.getName ().startsWith ( Constants.ARCHETYPE_RESOURCES )
+            )
+            {
+                // not supposed to be file.seperator
+                String resource =
+                    StringUtils.replace (
+                        entry.getName (),
+                        Constants.ARCHETYPE_RESOURCES + "/",
+                        ""
+                    );
+                getLogger ().debug ( "Found resource " + resource );
+                // TODO:FIXME
+                archetypeResources.add ( resource );
+            }
+            else
+            {
+                getLogger ().debug ( "Not resource " + entry.getName () );
+            }
+        }
+        return archetypeResources;
+    }
+
+    public org.apache.maven.archetype.old.descriptor.ArchetypeDescriptor getOldArchetypeDescriptor (
+        File archetypeFile
+    )
+    throws UnknownArchetype
+    {
+        try
+        {
+            ZipFile zipFile = getArchetypeZipFile ( archetypeFile );
+
+            return loadOldArchetypeDescriptor ( zipFile );
+        }
+        catch ( XmlPullParserException e )
+        {
+            throw new UnknownArchetype ( e );
+        }
+        catch ( IOException e )
+        {
+            throw new UnknownArchetype ( e );
+        }
+    }
+
+    public org.apache.maven.archetype.old.descriptor.ArchetypeDescriptor getOldArchetypeDescriptor (
+        String groupId,
+        String artifactId,
+        String version,
+        ArtifactRepository archetypeRepository,
+        ArtifactRepository localRepository,
+        List repositories
+    )
+    throws UnknownArchetype
+    {
+        try
+        {
+            ZipFile zipFile =
+                getArchetypeZipFile (
+                    getArchetypeFile (
+                        groupId,
+                        artifactId,
+                        version,
+                        archetypeRepository,
+                        localRepository,
+                        repositories
+                    )
+                );
+
+            return loadOldArchetypeDescriptor ( zipFile );
+        }
+        catch ( XmlPullParserException e )
+        {
+            throw new UnknownArchetype ( e );
+        }
+        catch ( IOException e )
+        {
+            throw new UnknownArchetype ( e );
+        }
+    }
+
+    private Reader getArchetypeDescriptorReader ( ZipFile zipFile )
+    throws IOException
+    {
+        ZipEntry entry =
+            zipFile.getEntry (
+                StringUtils.replace ( Constants.ARCHETYPE_DESCRIPTOR, File.separator, "/" )
+            );
+
+        if ( entry == null )
+        {
+            getLogger ().debug (
+                "No found " + Constants.ARCHETYPE_DESCRIPTOR + " retrying with windows path"
+            );
+            entry =
+                zipFile.getEntry (
+                    StringUtils.replace ( Constants.ARCHETYPE_DESCRIPTOR, "/", File.separator )
+                );
+        }
+        if ( entry == null )
+        {
+            throw new IOException (
+                "The " + Constants.ARCHETYPE_DESCRIPTOR + " descriptor cannot be found."
+            );
+        }
+
+        InputStream is = zipFile.getInputStream ( entry );
+
+        if ( is == null )
+        {
+            throw new IOException (
+                "The " + Constants.ARCHETYPE_DESCRIPTOR + " descriptor cannot be found."
+            );
+        }
+        return new InputStreamReader ( is );
+    }
+
+    private boolean isFileSetArchetype ( ZipFile zipFile )
+    throws IOException, XmlPullParserException
+    {
+        org.apache.maven.archetype.metadata.ArchetypeDescriptor descriptor =
+            loadFileSetArchetypeDescriptor ( zipFile );
+
+        return descriptor.getName () != null;
+    }
+
+    private boolean isOldArchetype ( ZipFile zipFile )
+    throws IOException, XmlPullParserException
+    {
+        org.apache.maven.archetype.old.descriptor.ArchetypeDescriptor descriptor =
+            loadOldArchetypeDescriptor ( zipFile );
+
+        return descriptor.getId () != null;
+    }
+
+    private org.apache.maven.archetype.metadata.ArchetypeDescriptor loadFileSetArchetypeDescriptor (
+        ZipFile zipFile
+    )
+    throws IOException, XmlPullParserException
+    {
+        Reader reader = getArchetypeDescriptorReader ( zipFile );
+
+        ArchetypeDescriptorXpp3Reader archetypeReader = new ArchetypeDescriptorXpp3Reader ();
+
+        try
+        {
+            return archetypeReader.read ( reader, true );
+        }
+        finally
+        {
+            reader.close ();
+        }
+    }
+
+    private org.apache.maven.archetype.old.descriptor.ArchetypeDescriptor
+    loadOldArchetypeDescriptor ( ZipFile zipFile )
+    throws IOException, XmlPullParserException
+    {
+        ArchetypeDescriptorBuilder builder = new ArchetypeDescriptorBuilder ();
+
+        org.apache.maven.archetype.old.descriptor.ArchetypeDescriptor descriptor = null;
+
+        Reader reader = null;
+        try
+        {
+            reader = getOldArchetypeDescriptorReader ( zipFile );
+
+            descriptor = builder.build ( reader );
+        }
+        catch ( IOException ex )
+        {
+            getLogger ().debug ( "Can not load old archetype", ex );
+        }
+        catch ( XmlPullParserException ex )
+        {
+            getLogger ().debug ( "Can not load old archetype", ex );
+        }
+        finally
+        {
+            if ( reader != null )
+            {
+                reader.close ();
+            }
+        }
+
+        if ( descriptor == null )
+        {
+            try
+            {
+                reader = getOlderArchetypeDescriptorReader ( zipFile );
+
+                descriptor = builder.build ( reader );
+            }
+            finally
+            {
+                if ( reader != null )
+                {
+                    reader.close ();
+                }
+            }
+        }
+
+        return descriptor;
+    }
+
+    private Reader getOldArchetypeDescriptorReader ( ZipFile zipFile )
+    throws IOException
+    {
+        ZipEntry entry =
+            zipFile.getEntry (
+                StringUtils.replace ( Constants.OLD_ARCHETYPE_DESCRIPTOR, File.separator, "/" )
+            );
+
+        if ( entry == null )
+        {
+            getLogger ().debug (
+                "No found " + Constants.OLD_ARCHETYPE_DESCRIPTOR + " retrying with windows path"
+            );
+            entry =
+                zipFile.getEntry (
+                    StringUtils.replace ( Constants.OLD_ARCHETYPE_DESCRIPTOR, "/", File.separator )
+                );
+        }
+
+        if ( entry == null )
+        {
+            throw new IOException (
+                "The " + Constants.OLD_ARCHETYPE_DESCRIPTOR + " descriptor cannot be found."
+            );
+        }
+
+        InputStream is = zipFile.getInputStream ( entry );
+
+        if ( is == null )
+        {
+            throw new IOException (
+                "The " + Constants.OLD_ARCHETYPE_DESCRIPTOR + " descriptor cannot be found."
+            );
+        }
+        return new InputStreamReader ( is );
+    }
+
+    private Reader getOlderArchetypeDescriptorReader ( ZipFile zipFile )
+    throws IOException
+    {
+        ZipEntry entry =
+            zipFile.getEntry (
+                StringUtils.replace ( Constants.OLDER_ARCHETYPE_DESCRIPTOR, File.separator, "/" )
+            );
+
+        if ( entry == null )
+        {
+            getLogger ().debug (
+                "No found " + Constants.OLDER_ARCHETYPE_DESCRIPTOR + " retrying with windows path"
+            );
+            entry =
+                zipFile.getEntry (
+                    StringUtils.replace (
+                        Constants.OLDER_ARCHETYPE_DESCRIPTOR,
+                        "/",
+                        File.separator
+                    )
+                );
+        }
+        if ( entry == null )
+        {
+            throw new IOException (
+                "The " + Constants.OLDER_ARCHETYPE_DESCRIPTOR + " descriptor cannot be found."
+            );
+        }
+
+        InputStream is = zipFile.getInputStream ( entry );
+
+        if ( is == null )
+        {
+            throw new IOException (
+                "The " + Constants.OLDER_ARCHETYPE_DESCRIPTOR + " descriptor cannot be found."
+            );
+        }
+
+        return new InputStreamReader ( is );
+    }
+}

Modified: maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/downloader/DefaultDownloader.java
URL: http://svn.apache.org/viewvc/maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/downloader/DefaultDownloader.java?rev=649606&r1=649605&r2=649606&view=diff
==============================================================================
--- maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/downloader/DefaultDownloader.java (original)
+++ maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/downloader/DefaultDownloader.java Fri Apr 18 09:50:50 2008
@@ -38,30 +38,19 @@
         throws DownloadException, DownloadNotFoundException
    {
         Artifact artifact = artifactFactory.createArtifact( groupId, artifactId, version, Artifact.SCOPE_RUNTIME, "jar" );
-        if ( archetypeRepository != null )
-        {
-            artifact.setRepository(archetypeRepository);
-        }
-        else if ( localRepository != null )
-        {
-            artifact.setRepository(localRepository);
-            
-        }
+
         List repositories = new ArrayList(remoteRepositories);
         if ( repositories.isEmpty() && archetypeRepository != null )
         {
             repositories.add(archetypeRepository);
         }
-        else if ( repositories.isEmpty() && localRepository != null )
+        else
+        if ( repositories.isEmpty() && localRepository != null )
         {
             repositories.add(localRepository);
             
         }
         ArtifactRepository localRepo = localRepository;
-        if ( localRepository == null && archetypeRepository != null )
-        {
-            localRepo = archetypeRepository;
-        }
         try
         {
             artifactResolver.resolveAlways( artifact, repositories, localRepo );

Modified: maven/archetype/trunk/archetype-plugin/src/main/java/org/apache/maven/archetype/mojos/CreateProjectFromArchetypeMojo.java
URL: http://svn.apache.org/viewvc/maven/archetype/trunk/archetype-plugin/src/main/java/org/apache/maven/archetype/mojos/CreateProjectFromArchetypeMojo.java?rev=649606&r1=649605&r2=649606&view=diff
==============================================================================
--- maven/archetype/trunk/archetype-plugin/src/main/java/org/apache/maven/archetype/mojos/CreateProjectFromArchetypeMojo.java (original)
+++ maven/archetype/trunk/archetype-plugin/src/main/java/org/apache/maven/archetype/mojos/CreateProjectFromArchetypeMojo.java Fri Apr 18 09:50:50 2008
@@ -39,6 +39,7 @@
 
 import java.io.File;
 import java.util.Arrays;
+import java.util.List;
 import java.util.Properties;
 
 /**
@@ -118,7 +119,16 @@
      * @readonly
      */
     private ArtifactRepository localRepository;
-
+    
+    /**
+     * List of Remote Repositories used by the resolver.
+     *
+     * @parameter  expression="${project.remoteArtifactRepositories}"
+     * @readonly
+     * @required
+     */
+    private List remoteArtifactRepositories;
+        
     /**
      * User settings use to check the interactiveMode.
      *
@@ -153,10 +163,20 @@
             .setArchetypeVersion( archetypeVersion )
             .setOutputDirectory( basedir.getAbsolutePath() )
             .setLocalRepository( localRepository )
-            .setArchetypeRepository(archetypeRepository);
+            .setArchetypeRepository(archetypeRepository)
+            .setRemoteArtifactRepositories(remoteArtifactRepositories);
 
         try
         {
+            if( interactiveMode.booleanValue() )
+            {
+                getLog().info( "Generating project in Interactive mode" );
+            }
+            else
+            {
+                getLog().info( "Generating project in Batch mode" );
+            }
+            
             selector.selectArchetype( request, interactiveMode, archetypeCatalog );
 
             // TODO: it's confusing that request has fields that get populated but not accepted as input (eg, groupId)

Modified: maven/archetype/trunk/archetype-plugin/src/main/java/org/apache/maven/archetype/ui/ArchetypeFactory.java
URL: http://svn.apache.org/viewvc/maven/archetype/trunk/archetype-plugin/src/main/java/org/apache/maven/archetype/ui/ArchetypeFactory.java?rev=649606&r1=649605&r2=649606&view=diff
==============================================================================
--- maven/archetype/trunk/archetype-plugin/src/main/java/org/apache/maven/archetype/ui/ArchetypeFactory.java (original)
+++ maven/archetype/trunk/archetype-plugin/src/main/java/org/apache/maven/archetype/ui/ArchetypeFactory.java Fri Apr 18 09:50:50 2008
@@ -1,69 +1,63 @@
-/*
- * 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.
- */
-
-package org.apache.maven.archetype.ui;
-
-import org.apache.maven.project.MavenProject;
-import org.apache.maven.archetype.common.ArchetypeConfiguration;
-import org.apache.maven.archetype.common.ArchetypeDefinition;
-
-import java.util.Properties;
-
-public interface ArchetypeFactory
-{
-    String ROLE = ArchetypeFactory.class.getName();
-
-    /**
-     */
-    ArchetypeConfiguration createArchetypeConfiguration(
-        ArchetypeDefinition archetypeDefinition,
-        Properties properties
-    );
-
-    /**
-     */
-    ArchetypeConfiguration createArchetypeConfiguration(
-        org.apache.maven.archetype.old.descriptor.ArchetypeDescriptor archetypeDescriptor,
-        Properties properties
-    );
-
-    /**
-     */
-    ArchetypeConfiguration createArchetypeConfiguration(
-        org.apache.maven.archetype.metadata.ArchetypeDescriptor archetypeDescriptor,
-        Properties properties
-    );
-
-    /**
-     */
-    ArchetypeConfiguration createArchetypeConfiguration(
-        MavenProject project,
-        ArchetypeDefinition archetypeDefinition,
-        Properties properties
-    );
-
-    /**
-     */
-    ArchetypeDefinition createArchetypeDefinition( Properties properties );
-
-    void updateArchetypeConfiguration(
-        ArchetypeConfiguration archetypeConfiguration,
-        ArchetypeDefinition archetypeDefinition
-    );
-}
+/*
+ * 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.
+ */
+
+package org.apache.maven.archetype.ui;
+
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.archetype.common.ArchetypeConfiguration;
+import org.apache.maven.archetype.common.ArchetypeDefinition;
+
+import java.util.Properties;
+
+public interface ArchetypeFactory
+{
+    String ROLE = ArchetypeFactory.class.getName();
+
+
+    /**
+     */
+    ArchetypeConfiguration createArchetypeConfiguration(
+        org.apache.maven.archetype.old.descriptor.ArchetypeDescriptor archetypeDescriptor,
+        Properties properties
+    );
+
+    /**
+     */
+    ArchetypeConfiguration createArchetypeConfiguration(
+        org.apache.maven.archetype.metadata.ArchetypeDescriptor archetypeDescriptor,
+        Properties properties
+    );
+
+    /**
+     */
+    ArchetypeConfiguration createArchetypeConfiguration(
+        MavenProject project,
+        ArchetypeDefinition archetypeDefinition,
+        Properties properties
+    );
+
+    /**
+     */
+    ArchetypeDefinition createArchetypeDefinition( Properties properties );
+
+    void updateArchetypeConfiguration(
+        ArchetypeConfiguration archetypeConfiguration,
+        ArchetypeDefinition archetypeDefinition
+    );
+}

Modified: maven/archetype/trunk/archetype-plugin/src/main/java/org/apache/maven/archetype/ui/DefaultArchetypeFactory.java
URL: http://svn.apache.org/viewvc/maven/archetype/trunk/archetype-plugin/src/main/java/org/apache/maven/archetype/ui/DefaultArchetypeFactory.java?rev=649606&r1=649605&r2=649606&view=diff
==============================================================================
--- maven/archetype/trunk/archetype-plugin/src/main/java/org/apache/maven/archetype/ui/DefaultArchetypeFactory.java (original)
+++ maven/archetype/trunk/archetype-plugin/src/main/java/org/apache/maven/archetype/ui/DefaultArchetypeFactory.java Fri Apr 18 09:50:50 2008
@@ -80,33 +80,27 @@
 
         configuration.addRequiredProperty( Constants.GROUP_ID );
         getLogger().debug( "Adding requiredProperty " + Constants.GROUP_ID );
-        if( null != properties.getProperty( Constants.GROUP_ID, null ) )
+        if( null != properties.getProperty( Constants.GROUP_ID ) )
         {
             configuration.setProperty( Constants.GROUP_ID, properties.getProperty( Constants.GROUP_ID ) );
-        }
-        else
-        {
-            configuration.setProperty( Constants.GROUP_ID, "com.company" );
+            configuration.setDefaultProperty( Constants.GROUP_ID, configuration.getProperty( Constants.GROUP_ID ) );
         }
         getLogger().debug( "Setting property " + Constants.GROUP_ID + "="
             + configuration.getProperty( Constants.GROUP_ID ) );
 
         configuration.addRequiredProperty( Constants.ARTIFACT_ID );
         getLogger().debug( "Adding requiredProperty " + Constants.ARTIFACT_ID );
-        if( null != properties.getProperty( Constants.ARTIFACT_ID, null ) )
+        if( null != properties.getProperty( Constants.ARTIFACT_ID ) )
         {
             configuration.setProperty( Constants.ARTIFACT_ID, properties.getProperty( Constants.ARTIFACT_ID ) );
-        }
-        else
-        {
-            configuration.setProperty( Constants.ARTIFACT_ID, archetypeDescriptor.getId() );
+            configuration.setDefaultProperty( Constants.ARTIFACT_ID, configuration.getProperty( Constants.ARTIFACT_ID ) );
         }
         getLogger().debug( "Setting property " + Constants.ARTIFACT_ID + "="
             + configuration.getProperty( Constants.ARTIFACT_ID ) );
 
         configuration.addRequiredProperty( Constants.VERSION );
         getLogger().debug( "Adding requiredProperty " + Constants.VERSION );
-        if( null != properties.getProperty( Constants.VERSION, null ) )
+        if( null != properties.getProperty( Constants.VERSION ) )
         {
             configuration.setProperty( Constants.VERSION, properties.getProperty( Constants.VERSION ) );
         }
@@ -114,26 +108,24 @@
         {
             configuration.setProperty( Constants.VERSION, "1.0-SNAPSHOT" );
         }
+        configuration.setDefaultProperty( Constants.VERSION, configuration.getProperty( Constants.VERSION ) );
         getLogger().debug( "Setting property " + Constants.VERSION + "="
             + configuration.getProperty( Constants.VERSION ) );
-        configuration.setDefaultProperty( Constants.VERSION, "1.0-SNAPSHOT" );
 
         configuration.addRequiredProperty( Constants.PACKAGE );
         getLogger().debug( "Adding requiredProperty " + Constants.PACKAGE );
         if( null != properties.getProperty( Constants.PACKAGE ) )
         {
             configuration.setProperty( Constants.PACKAGE, properties.getProperty( Constants.PACKAGE ) );
+            configuration.setDefaultProperty( Constants.PACKAGE, configuration.getProperty( Constants.PACKAGE ) );
         }
-        else
+        else if( null != configuration.getProperty( Constants.GROUP_ID ) )
         {
             configuration.setProperty( Constants.PACKAGE, configuration.getProperty( Constants.GROUP_ID ) );
+            configuration.setDefaultProperty( Constants.PACKAGE, configuration.getProperty( Constants.PACKAGE ) );
         }
         getLogger().debug( "Setting property " + Constants.PACKAGE + "="
             + configuration.getProperty( Constants.PACKAGE ) );
-        if( configuration.getProperty( Constants.GROUP_ID ) != null )
-        {
-            configuration.setDefaultProperty( Constants.PACKAGE, configuration.getProperty( Constants.GROUP_ID ) );
-        }
 
         return configuration;
     }
@@ -184,10 +176,7 @@
             {
                 configuration.setProperty( Constants.GROUP_ID,
                     properties.getProperty( Constants.GROUP_ID, configuration.getDefaultValue( Constants.GROUP_ID ) ) );
-            }
-            else
-            {
-                configuration.setProperty( Constants.GROUP_ID, "com.company" );
+                configuration.setDefaultProperty( Constants.GROUP_ID, configuration.getProperty( Constants.GROUP_ID ) );
             }
             getLogger().debug( "Setting property " + Constants.GROUP_ID + "="
                 + configuration.getProperty( Constants.GROUP_ID ) );
@@ -201,10 +190,7 @@
                     configuration.getDefaultValue( Constants.ARTIFACT_ID ) ) )
             {
                 configuration.setProperty( Constants.ARTIFACT_ID, properties.getProperty( Constants.ARTIFACT_ID ) );
-            }
-            else
-            {
-                configuration.setProperty( Constants.ARTIFACT_ID, archetypeDescriptor.getName() );
+                configuration.setDefaultProperty( Constants.ARTIFACT_ID, configuration.getProperty( Constants.ARTIFACT_ID ) );
             }
             getLogger().debug( "Setting property " + Constants.ARTIFACT_ID + "="
                 + configuration.getProperty( Constants.ARTIFACT_ID ) );
@@ -223,6 +209,7 @@
             {
                 configuration.setProperty( Constants.VERSION, "1.0-SNAPSHOT" );
             }
+            configuration.setDefaultProperty( Constants.VERSION, configuration.getProperty( Constants.VERSION ) );
             getLogger().debug( "Setting property " + Constants.VERSION + "="
                 + configuration.getProperty( Constants.VERSION ) );
         }
@@ -235,10 +222,12 @@
             {
                 configuration.setProperty( Constants.PACKAGE,
                     properties.getProperty( Constants.PACKAGE, configuration.getDefaultValue( Constants.PACKAGE ) ) );
+                configuration.setDefaultProperty( Constants.PACKAGE, configuration.getProperty( Constants.PACKAGE ) );
             }
-            else
+            else if( null != configuration.getProperty( Constants.GROUP_ID ) )
             {
                 configuration.setProperty( Constants.PACKAGE, configuration.getProperty( Constants.GROUP_ID ) );
+                configuration.setDefaultProperty( Constants.PACKAGE, configuration.getProperty( Constants.PACKAGE ) );
             }
             getLogger().debug( "Setting property " + Constants.PACKAGE + "="
                 + configuration.getProperty( Constants.PACKAGE ) );

Modified: maven/archetype/trunk/archetype-plugin/src/main/java/org/apache/maven/archetype/ui/DefaultArchetypeGenerationConfigurator.java
URL: http://svn.apache.org/viewvc/maven/archetype/trunk/archetype-plugin/src/main/java/org/apache/maven/archetype/ui/DefaultArchetypeGenerationConfigurator.java?rev=649606&r1=649605&r2=649606&view=diff
==============================================================================
--- maven/archetype/trunk/archetype-plugin/src/main/java/org/apache/maven/archetype/ui/DefaultArchetypeGenerationConfigurator.java (original)
+++ maven/archetype/trunk/archetype-plugin/src/main/java/org/apache/maven/archetype/ui/DefaultArchetypeGenerationConfigurator.java Fri Apr 18 09:50:50 2008
@@ -122,6 +122,11 @@
                     ad.getArtifactId() + "-repo" );
             repositories.add( archetypeRepository );
         }
+        if( request.getRemoteArtifactRepositories() != null )
+        {
+            repositories.addAll( request.getRemoteArtifactRepositories() );
+        }
+
         if( !archetypeArtifactManager.exists( ad.getGroupId(), ad.getArtifactId(), ad.getVersion(), archetypeRepository,
                 localRepository, repositories ) )
         {

Modified: maven/archetype/trunk/archetype-plugin/src/main/java/org/apache/maven/archetype/ui/DefaultArchetypeSelector.java
URL: http://svn.apache.org/viewvc/maven/archetype/trunk/archetype-plugin/src/main/java/org/apache/maven/archetype/ui/DefaultArchetypeSelector.java?rev=649606&r1=649605&r2=649606&view=diff
==============================================================================
--- maven/archetype/trunk/archetype-plugin/src/main/java/org/apache/maven/archetype/ui/DefaultArchetypeSelector.java (original)
+++ maven/archetype/trunk/archetype-plugin/src/main/java/org/apache/maven/archetype/ui/DefaultArchetypeSelector.java Fri Apr 18 09:50:50 2008
@@ -178,6 +178,9 @@
             // if artifact ID is set to it's default, we still prompt to confirm 
             if ( definition.getArtifactId() == null )
             {
+                getLogger().info( "No archetype defined. Using " + DEFAULT_ARCHETYPE_ARTIFACTID + " ("
+                    + definition.getGroupId() + ":" + DEFAULT_ARCHETYPE_ARTIFACTID + ":" + definition.getVersion()
+                    + ")" );
                 definition.setArtifactId( DEFAULT_ARCHETYPE_ARTIFACTID );
             }
 
@@ -248,7 +251,7 @@
         }
 
         if (archetypes.size() == 0) {
-            getLogger().debug("Using internal catalog");
+            getLogger().info("No catalog defined. Using internal catalog");
 
             archetypes.put("internal", archetype.getInternalCatalog().getArchetypes());
         }

Modified: maven/archetype/trunk/archetype-plugin/src/test/java/org/apache/maven/archetype/ui/DefaultArchetypeGenerationConfiguratorTest.java
URL: http://svn.apache.org/viewvc/maven/archetype/trunk/archetype-plugin/src/test/java/org/apache/maven/archetype/ui/DefaultArchetypeGenerationConfiguratorTest.java?rev=649606&r1=649605&r2=649606&view=diff
==============================================================================
--- maven/archetype/trunk/archetype-plugin/src/test/java/org/apache/maven/archetype/ui/DefaultArchetypeGenerationConfiguratorTest.java (original)
+++ maven/archetype/trunk/archetype-plugin/src/test/java/org/apache/maven/archetype/ui/DefaultArchetypeGenerationConfiguratorTest.java Fri Apr 18 09:50:50 2008
@@ -121,8 +121,11 @@
         Properties properties = new Properties();
         properties.setProperty( "artifactId", "preset-artifactId" );
 
-        
-        configurator.configureArchetype( request, Boolean.FALSE, properties );
-        assertEquals( "com.company", request.getGroupId() );
+        try{
+            configurator.configureArchetype( request, Boolean.FALSE, properties );
+            fail("An exception must be thrown");
+        }catch (ArchetypeNotConfigured e){
+            
+        }
     }
 }