Author: rafale
Date: Tue Apr  8 11:45:23 2008
New Revision: 646026

URL: http://svn.apache.org/viewvc?rev=646026&view=rev
Log:
Adding default properties behaviour.
thus removing the auto-confirmation in interactive mode.

Modified:
    
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/DefaultArchetypeFactory.java
    
maven/archetype/trunk/archetype-plugin/src/main/java/org/apache/maven/archetype/ui/DefaultArchetypeGenerationConfigurator.java
    
maven/archetype/trunk/archetype-plugin/src/test/java/org/apache/maven/archetype/ui/DefaultArchetypeGenerationConfiguratorTest.java

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=646026&r1=646025&r2=646026&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
 Tue Apr  8 11:45:23 2008
@@ -1,221 +1,221 @@
-/*
- * 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.mojos;
-
-import org.apache.maven.archetype.Archetype;
-import org.apache.maven.archetype.ArchetypeGenerationRequest;
-import org.apache.maven.archetype.ArchetypeGenerationResult;
-import org.apache.maven.archetype.generator.ArchetypeGenerator;
-import org.apache.maven.archetype.ui.ArchetypeGenerationConfigurator;
-import org.apache.maven.archetype.ui.ArchetypeSelector;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.execution.MavenSession;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.ContextEnabled;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.shared.invoker.DefaultInvocationRequest;
-import org.apache.maven.shared.invoker.InvocationRequest;
-import org.apache.maven.shared.invoker.Invoker;
-import org.apache.maven.shared.invoker.MavenInvocationException;
-import org.codehaus.plexus.util.StringUtils;
-
-import java.io.File;
-import java.util.Arrays;
-import java.util.Properties;
-
-/**
- * Generates sample project from archetype.
- *
- * @author rafale
- * @requiresProject false
- * @goal generate
- * @execute phase="generate-sources"
- */
-public class CreateProjectFromArchetypeMojo
-    extends AbstractMojo
-    implements ContextEnabled
-{
-    /** @component */
-    private Archetype archetype;
-
-    /** @component */
-    private ArchetypeSelector selector;
-
-    /** @component */
-    ArchetypeGenerationConfigurator configurator;
-
-    /** @component */
-    ArchetypeGenerator generator;
-
-    /** @component */
-    private Invoker invoker;
-
-    /**
-     * The archetype's artifactId.
-     *
-     * @parameter expression="${archetypeArtifactId}"
-     */
-    private String archetypeArtifactId;
-
-    /**
-     * The archetype's groupId.
-     *
-     * @parameter expression="${archetypeGroupId}"
-     */
-    private String archetypeGroupId;
-
-    /**
-     * The archetype's version.
-     *
-     * @parameter expression="${archetypeVersion}"
-     */
-    private String archetypeVersion;
-
-    /**
-     * The archetype's repository.
-     *
-     * @parameter expression="${archetypeRepository}"
-     */
-    private String archetypeRepository;
-
-    /**
-     * The archetype's catalogs.
-     * It is a comma separated list of catalogs.
-     * Catalogs use scheme:
-     * - 'file://...' with archetype-catalog.xml automatically appended when 
defining a directory
-     * - 'http://...' with archetype-catalog.xml always appended
-     * - 'local' which is the shortcut for 'file://~/.m2/archetype-catalog.xml'
-     * - 'remote' which is the shortcut for 'http://repo1.maven.org/maven2'
-     * - 'internal' which is an internal catalog
-     *
-     * @parameter expression="${archetypeCatalog}" default-value="internal"
-     */
-    private String archetypeCatalog;
-
-    /**
-     * Local maven repository.
-     *
-     * @parameter expression="${localRepository}"
-     * @required
-     * @readonly
-     */
-    private ArtifactRepository localRepository;
-
-    /**
-     * User settings use to check the interactiveMode.
-     *
-     * @parameter expression="${archetype.interactive}" 
default-value="${settings.interactiveMode}"
-     * @required
-     */
-    private Boolean interactiveMode;
-
-    /** @parameter expression="${basedir}" */
-    private File basedir;
-
-    /** 
-     *  @parameter expression="${session}" 
-     *  @readonly
-     */
-    private MavenSession session;
-    /**
-     * Additional goals that can be specified by the user during the creation 
of the archetype.
-     *
-     * @parameter expression="${goals}"
-     */
-    private String goals;
-
-    public void execute()
-        throws MojoExecutionException, MojoFailureException
-    {        
-        Properties executionProperties = session.getExecutionProperties();
-        
-        ArchetypeGenerationRequest request = new ArchetypeGenerationRequest()
-            .setArchetypeGroupId( archetypeGroupId )
-            .setArchetypeArtifactId( archetypeArtifactId )
-            .setArchetypeVersion( archetypeVersion )
-            .setOutputDirectory( basedir.getAbsolutePath() )
-            .setLocalRepository( localRepository )
-            .setArchetypeRepository(archetypeRepository);
-
-        try
-        {
-            selector.selectArchetype( request, interactiveMode, 
archetypeCatalog );
-
-            // TODO: it's confusing that request has fields that get populated 
but not accepted as input (eg, groupId)
-            configurator.configureArchetype( request, interactiveMode, 
executionProperties );
-
-            ArchetypeGenerationResult generationResult =
-                archetype.generateProjectFromArchetype( request );
-            if( generationResult.getCause() != null )
-            {
-                throw new MojoFailureException(
-                    generationResult.getCause(),
-                    generationResult.getCause().getMessage(),
-                    generationResult.getCause().getMessage()
-                );
-            }
-        }
-        catch ( MojoFailureException ex )
-        {
-            throw ex;
-        }
-        catch ( Exception ex )
-        {
-            throw new MojoFailureException( ex, ex.getMessage(), 
ex.getMessage() );
-        }
-
-        String artifactId = request.getArtifactId();
-
-        String postArchetypeGenerationGoals = request.getArchetypeGoals();
-
-        if ( StringUtils.isEmpty( postArchetypeGenerationGoals ) )
-        {
-            postArchetypeGenerationGoals = goals;
-        }
-
-        if ( StringUtils.isNotEmpty( postArchetypeGenerationGoals ) )
-        {
-            invokePostArchetypeGenerationGoals( postArchetypeGenerationGoals, 
artifactId );
-        }
-    }
-
-    private void invokePostArchetypeGenerationGoals( String goals, String 
artifactId )
-        throws MojoExecutionException, MojoFailureException
-    {
-        File projectBasedir = new File( basedir, artifactId );
-
-        if ( projectBasedir.exists() )
-        {
-            InvocationRequest request = new DefaultInvocationRequest()
-                .setBaseDirectory( projectBasedir )
-                .setGoals( Arrays.asList( StringUtils.split( goals, "," ) ) );
-
-            try
-            {
-                invoker.execute( request );
-            }
-            catch ( MavenInvocationException e )
-            {
-                throw new MojoExecutionException( "Cannot run additions 
goals." );
-            }
-        }
-    }
-}
+/*
+ * 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.mojos;
+
+import org.apache.maven.archetype.Archetype;
+import org.apache.maven.archetype.ArchetypeGenerationRequest;
+import org.apache.maven.archetype.ArchetypeGenerationResult;
+import org.apache.maven.archetype.generator.ArchetypeGenerator;
+import org.apache.maven.archetype.ui.ArchetypeGenerationConfigurator;
+import org.apache.maven.archetype.ui.ArchetypeSelector;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.ContextEnabled;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.shared.invoker.DefaultInvocationRequest;
+import org.apache.maven.shared.invoker.InvocationRequest;
+import org.apache.maven.shared.invoker.Invoker;
+import org.apache.maven.shared.invoker.MavenInvocationException;
+import org.codehaus.plexus.util.StringUtils;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.Properties;
+
+/**
+ * Generates sample project from archetype.
+ *
+ * @author rafale
+ * @requiresProject false
+ * @goal generate
+ * @execute phase="generate-sources"
+ */
+public class CreateProjectFromArchetypeMojo
+    extends AbstractMojo
+    implements ContextEnabled
+{
+    /** @component */
+    private Archetype archetype;
+
+    /** @component */
+    private ArchetypeSelector selector;
+
+    /** @component */
+    ArchetypeGenerationConfigurator configurator;
+
+    /** @component */
+    ArchetypeGenerator generator;
+
+    /** @component */
+    private Invoker invoker;
+
+    /**
+     * The archetype's artifactId.
+     *
+     * @parameter expression="${archetypeArtifactId}"
+     */
+    private String archetypeArtifactId;
+
+    /**
+     * The archetype's groupId.
+     *
+     * @parameter expression="${archetypeGroupId}"
+     */
+    private String archetypeGroupId;
+
+    /**
+     * The archetype's version.
+     *
+     * @parameter expression="${archetypeVersion}"
+     */
+    private String archetypeVersion;
+
+    /**
+     * The archetype's repository.
+     *
+     * @parameter expression="${archetypeRepository}"
+     */
+    private String archetypeRepository;
+
+    /**
+     * The archetype's catalogs.
+     * It is a comma separated list of catalogs.
+     * Catalogs use scheme:
+     * - 'file://...' with archetype-catalog.xml automatically appended when 
defining a directory
+     * - 'http://...' with archetype-catalog.xml always appended
+     * - 'local' which is the shortcut for 'file://~/.m2/archetype-catalog.xml'
+     * - 'remote' which is the shortcut for 'http://repo1.maven.org/maven2'
+     * - 'internal' which is an internal catalog
+     *
+     * @parameter expression="${archetypeCatalog}" default-value="internal"
+     */
+    private String archetypeCatalog;
+
+    /**
+     * Local maven repository.
+     *
+     * @parameter expression="${localRepository}"
+     * @required
+     * @readonly
+     */
+    private ArtifactRepository localRepository;
+
+    /**
+     * User settings use to check the interactiveMode.
+     *
+     * @parameter expression="${archetype.interactive}" 
default-value="${settings.interactiveMode}"
+     * @required
+     */
+    private Boolean interactiveMode;
+
+    /** @parameter expression="${basedir}" */
+    private File basedir;
+
+    /** 
+     *  @parameter expression="${session}" 
+     *  @readonly
+     */
+    private MavenSession session;
+    /**
+     * Additional goals that can be specified by the user during the creation 
of the archetype.
+     *
+     * @parameter expression="${goals}"
+     */
+    private String goals;
+
+    public void execute()
+        throws MojoExecutionException, MojoFailureException
+    {        
+        Properties executionProperties = session.getExecutionProperties();
+        
+        ArchetypeGenerationRequest request = new ArchetypeGenerationRequest()
+            .setArchetypeGroupId( archetypeGroupId )
+            .setArchetypeArtifactId( archetypeArtifactId )
+            .setArchetypeVersion( archetypeVersion )
+            .setOutputDirectory( basedir.getAbsolutePath() )
+            .setLocalRepository( localRepository )
+            .setArchetypeRepository(archetypeRepository);
+
+        try
+        {
+            selector.selectArchetype( request, interactiveMode, 
archetypeCatalog );
+
+            // TODO: it's confusing that request has fields that get populated 
but not accepted as input (eg, groupId)
+            configurator.configureArchetype( request, interactiveMode, 
executionProperties );
+
+            ArchetypeGenerationResult generationResult =
+                archetype.generateProjectFromArchetype( request );
+            if( generationResult.getCause() != null )
+            {
+                throw new MojoFailureException(
+                    generationResult.getCause(),
+                    generationResult.getCause().getMessage(),
+                    generationResult.getCause().getMessage()
+                );
+            }
+        }
+        catch ( MojoFailureException ex )
+        {
+            throw ex;
+        }
+        catch ( Exception ex )
+        {
+            throw new MojoFailureException( ex, ex.getMessage(), 
ex.getMessage() );
+        }
+
+        String artifactId = request.getArtifactId();
+
+        String postArchetypeGenerationGoals = request.getArchetypeGoals();
+
+        if ( StringUtils.isEmpty( postArchetypeGenerationGoals ) )
+        {
+            postArchetypeGenerationGoals = goals;
+        }
+
+        if ( StringUtils.isNotEmpty( postArchetypeGenerationGoals ) )
+        {
+            invokePostArchetypeGenerationGoals( postArchetypeGenerationGoals, 
artifactId );
+        }
+    }
+
+    private void invokePostArchetypeGenerationGoals( String goals, String 
artifactId )
+        throws MojoExecutionException, MojoFailureException
+    {
+        File projectBasedir = new File( basedir, artifactId );
+
+        if ( projectBasedir.exists() )
+        {
+            InvocationRequest request = new DefaultInvocationRequest()
+                .setBaseDirectory( projectBasedir )
+                .setGoals( Arrays.asList( StringUtils.split( goals, "," ) ) );
+
+            try
+            {
+                invoker.execute( request );
+            }
+            catch ( MavenInvocationException e )
+            {
+                throw new MojoExecutionException( "Cannot run additions 
goals." );
+            }
+        }
+    }
+}

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=646026&r1=646025&r2=646026&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
 Tue Apr  8 11:45:23 2008
@@ -23,39 +23,35 @@
 import org.apache.maven.archetype.common.ArchetypeDefinition;
 import org.apache.maven.archetype.common.Constants;
 import org.apache.maven.project.MavenProject;
+
 import org.codehaus.plexus.logging.AbstractLogEnabled;
 
 import java.util.Iterator;
 import java.util.Properties;
-import org.codehaus.plexus.util.StringUtils;
 
-/** @plexus.component */
+/**
+ * @plexus.component
+ */
 public class DefaultArchetypeFactory
-    extends AbstractLogEnabled
-    implements ArchetypeFactory
+extends AbstractLogEnabled
+implements ArchetypeFactory
 {
-    public ArchetypeConfiguration createArchetypeConfiguration(
-        ArchetypeDefinition archetypeDefinition,
-        Properties properties
-    )
+    public ArchetypeConfiguration createArchetypeConfiguration( 
ArchetypeDefinition archetypeDefinition,
+        Properties properties )
     {
         ArchetypeConfiguration configuration = new ArchetypeConfiguration();
-        getLogger().debug(
-            "Creating ArchetypeConfiguration from ArchetypeDefinition and 
Properties"
-        );
+        getLogger().debug( "Creating ArchetypeConfiguration from 
ArchetypeDefinition and Properties" );
 
         configuration.setGroupId( archetypeDefinition.getGroupId() );
         configuration.setArtifactId( archetypeDefinition.getArtifactId() );
         configuration.setVersion( archetypeDefinition.getVersion() );
 
         Iterator propertiesIterator = properties.keySet().iterator();
-        while ( propertiesIterator.hasNext() )
+        while( propertiesIterator.hasNext() )
         {
             String property = (String) propertiesIterator.next();
-            if ( !Constants.ARCHETYPE_GROUP_ID.equals( property )
-                && !Constants.ARCHETYPE_ARTIFACT_ID.equals( property )
-                && !Constants.ARCHETYPE_VERSION.equals( property )
-                )
+            if( !Constants.ARCHETYPE_GROUP_ID.equals( property ) && 
!Constants.ARCHETYPE_ARTIFACT_ID.equals( property )
+                && !Constants.ARCHETYPE_VERSION.equals( property ) )
             {
                 configuration.addRequiredProperty( property );
 
@@ -63,9 +59,7 @@
 
                 configuration.setProperty( property, properties.getProperty( 
property ) );
 
-                getLogger().debug(
-                    "Adding property " + property + "=" + 
properties.getProperty( property )
-                );
+                getLogger().debug( "Adding property " + property + "=" + 
properties.getProperty( property ) );
             }
         }
 
@@ -73,80 +67,70 @@
     }
 
     public ArchetypeConfiguration createArchetypeConfiguration(
-        org.apache.maven.archetype.old.descriptor.ArchetypeDescriptor 
archetypeDescriptor,
-        Properties properties
-    )
+        org.apache.maven.archetype.old.descriptor.ArchetypeDescriptor 
archetypeDescriptor, Properties properties )
     {
         ArchetypeConfiguration configuration = new ArchetypeConfiguration();
-        getLogger().debug(
-            "Creating ArchetypeConfiguration from legacy descriptor and 
Properties"
-        );
+        getLogger().debug( "Creating ArchetypeConfiguration from legacy 
descriptor and Properties" );
 
         configuration.setGroupId( properties.getProperty( 
Constants.ARCHETYPE_GROUP_ID, null ) );
-        configuration.setArtifactId(
-            properties.getProperty( Constants.ARCHETYPE_ARTIFACT_ID, null )
-        );
+        configuration.setArtifactId( properties.getProperty( 
Constants.ARCHETYPE_ARTIFACT_ID, null ) );
         configuration.setVersion( properties.getProperty( 
Constants.ARCHETYPE_VERSION, null ) );
 
         configuration.setName( archetypeDescriptor.getId() );
 
         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, null ) )
+        {
+            configuration.setProperty( Constants.GROUP_ID, 
properties.getProperty( Constants.GROUP_ID ) );
+        }
+        else
         {
-            configuration.setProperty(
-                Constants.GROUP_ID,
-                properties.getProperty( Constants.GROUP_ID )
-            );
-            getLogger().debug(
-                "Setting property " + Constants.GROUP_ID + "="
-                    + configuration.getProperty( Constants.GROUP_ID )
-            );
+            configuration.setProperty( Constants.GROUP_ID, "com.company" );
         }
+        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, null ) )
+        {
+            configuration.setProperty( Constants.ARTIFACT_ID, 
properties.getProperty( Constants.ARTIFACT_ID ) );
+        }
+        else
         {
-            configuration.setProperty(
-                Constants.ARTIFACT_ID,
-                properties.getProperty( Constants.ARTIFACT_ID )
-            );
-            getLogger().debug(
-                "Setting property " + Constants.ARTIFACT_ID + "="
-                    + configuration.getProperty( Constants.ARTIFACT_ID )
-            );
+            configuration.setProperty( Constants.ARTIFACT_ID, 
archetypeDescriptor.getId() );
         }
+        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, null ) )
         {
-            configuration.setProperty(
-                Constants.VERSION,
-                properties.getProperty( Constants.VERSION )
-            );
-            getLogger().debug(
-                "Setting property " + Constants.VERSION + "="
-                    + configuration.getProperty( Constants.VERSION )
-            );
+            configuration.setProperty( Constants.VERSION, 
properties.getProperty( Constants.VERSION ) );
         }
+        else
+        {
+            configuration.setProperty( Constants.VERSION, "1.0-SNAPSHOT" );
+        }
+        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
-                )
-            );
+        if( null != properties.getProperty( Constants.PACKAGE ) )
+        {
+            configuration.setProperty( Constants.PACKAGE, 
properties.getProperty( Constants.PACKAGE ) );
         }
-        if ( configuration.getProperty( Constants.GROUP_ID ) != null )
+        else
+        {
+            configuration.setProperty( Constants.PACKAGE, 
configuration.getProperty( Constants.GROUP_ID ) );
+        }
+        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 ) );
         }
@@ -155,26 +139,20 @@
     }
 
     public ArchetypeConfiguration createArchetypeConfiguration(
-        org.apache.maven.archetype.metadata.ArchetypeDescriptor 
archetypeDescriptor,
-        Properties properties
-    )
+        org.apache.maven.archetype.metadata.ArchetypeDescriptor 
archetypeDescriptor, Properties properties )
     {
         ArchetypeConfiguration configuration = new ArchetypeConfiguration();
-        getLogger().debug(
-            "Creating ArchetypeConfiguration from fileset descriptor and 
Properties"
-        );
+        getLogger().debug( "Creating ArchetypeConfiguration from fileset 
descriptor and Properties" );
 
         configuration.setGroupId( properties.getProperty( 
Constants.ARCHETYPE_GROUP_ID, null ) );
-        configuration.setArtifactId(
-            properties.getProperty( Constants.ARCHETYPE_ARTIFACT_ID, null )
-        );
+        configuration.setArtifactId( properties.getProperty( 
Constants.ARCHETYPE_ARTIFACT_ID, null ) );
         configuration.setVersion( properties.getProperty( 
Constants.ARCHETYPE_VERSION, null ) );
 
         configuration.setName( archetypeDescriptor.getName() );
 
         Iterator requiredProperties = 
archetypeDescriptor.getRequiredProperties().iterator();
 
-        while ( requiredProperties.hasNext() )
+        while( requiredProperties.hasNext() )
         {
             org.apache.maven.archetype.metadata.RequiredProperty 
requiredProperty =
                 (org.apache.maven.archetype.metadata.RequiredProperty) 
requiredProperties.next();
@@ -182,137 +160,109 @@
             configuration.addRequiredProperty( requiredProperty.getKey() );
             getLogger().debug( "Adding requiredProperty " + 
requiredProperty.getKey() );
 
-            if ( null
-                != properties.getProperty(
-                requiredProperty.getKey(),
-                requiredProperty.getDefaultValue()
-            )
-                )
-            {
-                configuration.setProperty(
-                    requiredProperty.getKey(),
-                    properties.getProperty(
-                        requiredProperty.getKey(),
-                        requiredProperty.getDefaultValue()
-                    )
-                );
-                getLogger().debug(
-                    "Setting property " + requiredProperty.getKey() + "="
-                        + configuration.getProperty( requiredProperty.getKey() 
)
-                );
-            }
-            if ( null != requiredProperty.getDefaultValue() )
-            {
-                configuration.setDefaultProperty(
-                    requiredProperty.getKey(),
-                    requiredProperty.getDefaultValue()
-                );
-                getLogger().debug(
-                    "Setting defaultProperty " + requiredProperty.getKey() + 
"="
-                        + configuration.getDefaultValue( 
requiredProperty.getKey() )
-                );
+            if( null != properties.getProperty( requiredProperty.getKey(), 
requiredProperty.getDefaultValue() ) )
+            {
+                configuration.setProperty( requiredProperty.getKey(),
+                    properties.getProperty( requiredProperty.getKey(), 
requiredProperty.getDefaultValue() ) );
+                getLogger().debug( "Setting property " + 
requiredProperty.getKey() + "="
+                    + configuration.getProperty( requiredProperty.getKey() ) );
+            }
+            if( null != requiredProperty.getDefaultValue() )
+            {
+                configuration.setDefaultProperty( requiredProperty.getKey(), 
requiredProperty.getDefaultValue() );
+                getLogger().debug( "Setting defaultProperty " + 
requiredProperty.getKey() + "="
+                    + configuration.getDefaultValue( requiredProperty.getKey() 
) );
             }
         } // end while
 
-        if ( !configuration.isConfigured( Constants.GROUP_ID ) )
+        if( !configuration.isConfigured( Constants.GROUP_ID ) )
         {
             configuration.addRequiredProperty( Constants.GROUP_ID );
             getLogger().debug( "Adding requiredProperty " + Constants.GROUP_ID 
);
-            if ( null != properties.getProperty( Constants.GROUP_ID, 
configuration.getDefaultValue( Constants.GROUP_ID ) ) )
+            if( null
+                != properties.getProperty( Constants.GROUP_ID, 
configuration.getDefaultValue( Constants.GROUP_ID ) ) )
+            {
+                configuration.setProperty( Constants.GROUP_ID,
+                    properties.getProperty( Constants.GROUP_ID, 
configuration.getDefaultValue( Constants.GROUP_ID ) ) );
+            }
+            else
             {
-                configuration.setProperty(
-                    Constants.GROUP_ID,
-                    properties.getProperty( Constants.GROUP_ID, 
configuration.getDefaultValue( Constants.GROUP_ID ) )
-                );
-                getLogger().debug(
-                    "Setting property " + Constants.GROUP_ID + "="
-                        + configuration.getProperty( Constants.GROUP_ID )
-                );
+                configuration.setProperty( Constants.GROUP_ID, "com.company" );
             }
+            getLogger().debug( "Setting property " + Constants.GROUP_ID + "="
+                + configuration.getProperty( Constants.GROUP_ID ) );
         }
-        if ( !configuration.isConfigured( Constants.ARTIFACT_ID ) )
+        if( !configuration.isConfigured( Constants.ARTIFACT_ID ) )
         {
             configuration.addRequiredProperty( Constants.ARTIFACT_ID );
             getLogger().debug( "Adding requiredProperty " + 
Constants.ARTIFACT_ID );
-            if ( null != properties.getProperty( Constants.ARTIFACT_ID, 
configuration.getDefaultValue( Constants.ARTIFACT_ID ) ) )
+            if( null
+                != properties.getProperty( Constants.ARTIFACT_ID,
+                    configuration.getDefaultValue( Constants.ARTIFACT_ID ) ) )
             {
-                configuration.setProperty(
-                    Constants.ARTIFACT_ID,
-                    properties.getProperty( Constants.ARTIFACT_ID )
-                );
-                getLogger().debug(
-                    "Setting property " + Constants.ARTIFACT_ID + "="
-                        + configuration.getProperty( Constants.ARTIFACT_ID )
-                );
+                configuration.setProperty( Constants.ARTIFACT_ID, 
properties.getProperty( Constants.ARTIFACT_ID ) );
             }
+            else
+            {
+                configuration.setProperty( Constants.ARTIFACT_ID, 
archetypeDescriptor.getName() );
+            }
+            getLogger().debug( "Setting property " + Constants.ARTIFACT_ID + 
"="
+                + configuration.getProperty( Constants.ARTIFACT_ID ) );
         }
-        if ( !configuration.isConfigured( Constants.VERSION ) )
+        if( !configuration.isConfigured( Constants.VERSION ) )
         {
             configuration.addRequiredProperty( Constants.VERSION );
             getLogger().debug( "Adding requiredProperty " + Constants.VERSION 
);
-            if ( null != properties.getProperty( Constants.VERSION, 
configuration.getDefaultValue( Constants.VERSION ) ) )
+            if( null != properties.getProperty( Constants.VERSION,
+                    configuration.getDefaultValue( Constants.VERSION ) ) )
+            {
+                configuration.setProperty( Constants.VERSION,
+                    properties.getProperty( Constants.VERSION, 
configuration.getDefaultValue( Constants.VERSION ) ) );
+            }
+            else
             {
-                configuration.setProperty(
-                    Constants.VERSION,
-                    properties.getProperty( Constants.VERSION, 
configuration.getDefaultValue( Constants.VERSION ) )
-                );
-                getLogger().debug(
-                    "Setting property " + Constants.VERSION + "="
-                        + configuration.getProperty( Constants.VERSION )
-                );
+                configuration.setProperty( Constants.VERSION, "1.0-SNAPSHOT" );
             }
+            getLogger().debug( "Setting property " + Constants.VERSION + "="
+                + configuration.getProperty( Constants.VERSION ) );
         }
-        if ( !configuration.isConfigured( Constants.PACKAGE ) )
+        if( !configuration.isConfigured( Constants.PACKAGE ) )
         {
             configuration.addRequiredProperty( Constants.PACKAGE );
             getLogger().debug( "Adding requiredProperty " + Constants.PACKAGE 
);
-            if ( null
-                != properties.getProperty(
-                Constants.PACKAGE, configuration.getDefaultValue( 
Constants.PACKAGE )
-            )
-                )
-            {
-                configuration.setProperty(
-                    Constants.PACKAGE,
-                    properties.getProperty(
-                        Constants.PACKAGE, configuration.getDefaultValue( 
Constants.PACKAGE )
-                    )
-                );
-                getLogger().debug(
-                    "Setting property " + Constants.PACKAGE + "="
-                        + configuration.getProperty( Constants.PACKAGE )
-                );
+            if( null != properties.getProperty( Constants.PACKAGE,
+                    configuration.getDefaultValue( Constants.PACKAGE ) ) )
+            {
+                configuration.setProperty( Constants.PACKAGE,
+                    properties.getProperty( Constants.PACKAGE, 
configuration.getDefaultValue( Constants.PACKAGE ) ) );
+            }
+            else
+            {
+                configuration.setProperty( Constants.PACKAGE, 
configuration.getProperty( Constants.GROUP_ID ) );
             }
+            getLogger().debug( "Setting property " + Constants.PACKAGE + "="
+                + configuration.getProperty( Constants.PACKAGE ) );
         }
 
-        if ( null != properties.getProperty( 
Constants.ARCHETYPE_POST_GENERATION_GOALS ) )
-        {
-            configuration.setProperty(
-                Constants.ARCHETYPE_POST_GENERATION_GOALS,
-                properties.getProperty(
-                    Constants.ARCHETYPE_POST_GENERATION_GOALS ) );
+        if( null != properties.getProperty( 
Constants.ARCHETYPE_POST_GENERATION_GOALS ) )
+        {
+            configuration.setProperty( 
Constants.ARCHETYPE_POST_GENERATION_GOALS,
+                properties.getProperty( 
Constants.ARCHETYPE_POST_GENERATION_GOALS ) );
         }
 
         return configuration;
     }
 
-    public ArchetypeConfiguration createArchetypeConfiguration(
-        MavenProject project,
-        ArchetypeDefinition archetypeDefinition,
-        Properties properties
-    )
+    public ArchetypeConfiguration createArchetypeConfiguration( MavenProject 
project,
+        ArchetypeDefinition archetypeDefinition, Properties properties )
     {
         ArchetypeConfiguration configuration = new ArchetypeConfiguration();
-        getLogger().debug(
-            "Creating ArchetypeConfiguration from ArchetypeDefinition, 
MavenProject and Properties"
-        );
+        getLogger().debug( "Creating ArchetypeConfiguration from 
ArchetypeDefinition, MavenProject and Properties" );
 
         configuration.setGroupId( archetypeDefinition.getGroupId() );
         configuration.setArtifactId( archetypeDefinition.getArtifactId() );
         configuration.setVersion( archetypeDefinition.getVersion() );
-        
-        
-        
+
         Iterator requiredProperties = properties.keySet().iterator();
 
         while( requiredProperties.hasNext() )
@@ -323,73 +273,50 @@
             {
                 configuration.addRequiredProperty( requiredProperty );
                 getLogger().debug( "Adding requiredProperty " + 
requiredProperty );
-                configuration.setProperty(
-                    requiredProperty,
-                    properties.getProperty( requiredProperty )
-                );
-                getLogger().debug(
-                    "Setting property " + requiredProperty + "="
-                    + configuration.getProperty( requiredProperty )
-                );
+                configuration.setProperty( requiredProperty, 
properties.getProperty( requiredProperty ) );
+                getLogger().debug( "Setting property " + requiredProperty + "="
+                    + configuration.getProperty( requiredProperty ) );
             }
         }
-        
 
         configuration.addRequiredProperty( Constants.GROUP_ID );
         getLogger().debug( "Adding requiredProperty " + Constants.GROUP_ID );
         configuration.setDefaultProperty( Constants.GROUP_ID, 
project.getGroupId() );
-        if ( null != properties.getProperty( Constants.GROUP_ID, null ) )
+        if( null != properties.getProperty( Constants.GROUP_ID, null ) )
         {
-            configuration.setProperty(
-                Constants.GROUP_ID,
-                properties.getProperty( Constants.GROUP_ID )
-            );
-            getLogger().debug(
-                "Setting property " + Constants.GROUP_ID + "="
-                    + configuration.getProperty( Constants.GROUP_ID )
-            );
+            configuration.setProperty( Constants.GROUP_ID, 
properties.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 
);
         configuration.setDefaultProperty( Constants.ARTIFACT_ID, 
project.getArtifactId() );
-        if ( null != properties.getProperty( Constants.ARTIFACT_ID, null ) )
+        if( null != properties.getProperty( Constants.ARTIFACT_ID, null ) )
         {
-            configuration.setProperty(
-                Constants.ARTIFACT_ID,
-                properties.getProperty( Constants.ARTIFACT_ID )
-            );
-            getLogger().debug(
-                "Setting property " + Constants.ARTIFACT_ID + "="
-                    + configuration.getProperty( Constants.ARTIFACT_ID )
-            );
+            configuration.setProperty( Constants.ARTIFACT_ID, 
properties.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 );
         configuration.setDefaultProperty( Constants.VERSION, 
project.getVersion() );
-        if ( null != properties.getProperty( Constants.VERSION, null ) )
+        if( null != properties.getProperty( Constants.VERSION, null ) )
         {
-            configuration.setProperty(
-                Constants.VERSION,
-                properties.getProperty( Constants.VERSION )
-            );
-            getLogger().debug(
-                "Setting property " + Constants.VERSION + "="
-                    + configuration.getProperty( Constants.VERSION )
-            );
+            configuration.setProperty( Constants.VERSION, 
properties.getProperty( Constants.VERSION ) );
+            getLogger().debug( "Setting property " + Constants.VERSION + "="
+                + configuration.getProperty( Constants.VERSION ) );
         }
 
         configuration.addRequiredProperty( Constants.PACKAGE );
         getLogger().debug( "Adding requiredProperty " + Constants.PACKAGE );
-        if ( null != properties.getProperty( Constants.PACKAGE ) )
+        if( null != properties.getProperty( Constants.PACKAGE ) )
         {
             configuration.setProperty( Constants.PACKAGE, 
properties.getProperty( Constants.PACKAGE ) );
-            
-            getLogger().debug(
-                "Setting property " + Constants.PACKAGE + "="
-                    + configuration.getProperty( Constants.PACKAGE )
-            );
+
+            getLogger().debug( "Setting property " + Constants.PACKAGE + "="
+                + configuration.getProperty( Constants.PACKAGE ) );
         }
 
         return configuration;
@@ -410,10 +337,8 @@
         return definition;
     }
 
-    public void updateArchetypeConfiguration(
-        ArchetypeConfiguration archetypeConfiguration,
-        ArchetypeDefinition archetypeDefinition
-    )
+    public void updateArchetypeConfiguration( ArchetypeConfiguration 
archetypeConfiguration,
+        ArchetypeDefinition archetypeDefinition )
     {
         archetypeConfiguration.setGroupId( archetypeDefinition.getGroupId() );
         archetypeConfiguration.setArtifactId( 
archetypeDefinition.getArtifactId() );

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=646026&r1=646025&r2=646026&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
 Tue Apr  8 11:45:23 2008
@@ -16,8 +16,8 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.maven.archetype.ui;
 
+package org.apache.maven.archetype.ui;
 
 import org.apache.maven.archetype.ArchetypeGenerationRequest;
 import org.apache.maven.archetype.common.ArchetypeArtifactManager;
@@ -31,42 +31,58 @@
 import org.apache.maven.archetype.exception.UnknownArchetype;
 import org.apache.maven.archetype.old.OldArchetype;
 import org.apache.maven.artifact.repository.ArtifactRepository;
+
 import org.codehaus.plexus.components.interactivity.PrompterException;
 import org.codehaus.plexus.logging.AbstractLogEnabled;
 
 import java.io.IOException;
+
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Properties;
 
 // TODO: this seems to have more responsibilities than just a configurator
-/** @plexus.component */
+/**
+ * @plexus.component
+ */
 public class DefaultArchetypeGenerationConfigurator
-    extends AbstractLogEnabled
-    implements ArchetypeGenerationConfigurator
+extends AbstractLogEnabled
+implements ArchetypeGenerationConfigurator
 {
-    /** @plexus.requirement */
+    /**
+     * @plexus.requirement
+     */
     OldArchetype oldArchetype;
 
-    /** @plexus.requirement */
+    /**
+     * @plexus.requirement
+     */
     private ArchetypeArtifactManager archetypeArtifactManager;
 
-    /** @plexus.requirement */
+    /**
+     * @plexus.requirement
+     */
     private ArchetypeFactory archetypeFactory;
 
-    /** @plexus.requirement */
+    /**
+     * @plexus.requirement
+     */
     private ArchetypeGenerationQueryer archetypeGenerationQueryer;
 
-    /** @plexus.requirement */
+    /**
+     * @plexus.requirement
+     */
     private ArchetypeRegistryManager archetypeRegistryManager;
 
-    public void configureArchetype(
-        ArchetypeGenerationRequest request,
-        Boolean interactiveMode,
+    public void setArchetypeArtifactManager( ArchetypeArtifactManager 
archetypeArtifactManager )
+    {
+        this.archetypeArtifactManager = archetypeArtifactManager;
+    }
+
+    public void configureArchetype( ArchetypeGenerationRequest request, 
Boolean interactiveMode,
         Properties executionProperties )
-        throws
-        ArchetypeNotDefined,
+    throws ArchetypeNotDefined,
         UnknownArchetype,
         ArchetypeNotConfigured,
         IOException,
@@ -89,135 +105,126 @@
 
         ad.setVersion( request.getArchetypeVersion() );
 
-        if ( !ad.isDefined() )
+        if( !ad.isDefined() )
         {
-            if ( !interactiveMode.booleanValue () )
+            if( !interactiveMode.booleanValue() )
             {
-                throw new ArchetypeNotDefined ( "No archetype was chosen" );
+                throw new ArchetypeNotDefined( "No archetype was chosen" );
             }
             else
             {
-                throw new ArchetypeNotDefined ( "The archetype is not defined" 
);
+                throw new ArchetypeNotDefined( "The archetype is not defined" 
);
             }
         }
-        if ( request.getArchetypeRepository() != null )
+        if( request.getArchetypeRepository() != null )
         {
             archetypeRepository = archetypeRegistryManager.createRepository( 
request.getArchetypeRepository(),
-                ad.getArtifactId() + "-repo" );
+                    ad.getArtifactId() + "-repo" );
             repositories.add( archetypeRepository );
         }
-        if ( !archetypeArtifactManager.exists( ad.getGroupId(), 
ad.getArtifactId(),
-            ad.getVersion(), archetypeRepository, localRepository, 
repositories ) )
+        if( !archetypeArtifactManager.exists( ad.getGroupId(), 
ad.getArtifactId(), ad.getVersion(), archetypeRepository,
+                localRepository, repositories ) )
         {
-            throw new UnknownArchetype(
-                "The desired archetype does not exist (" + ad.getGroupId() + 
":" + ad.getArtifactId() + ":" + ad.getVersion() + ")" );
+            throw new UnknownArchetype( "The desired archetype does not exist 
(" + ad.getGroupId() + ":"
+                + ad.getArtifactId() + ":" + ad.getVersion() + ")" );
         }
 
         request.setArchetypeVersion( ad.getVersion() );
 
         ArchetypeConfiguration archetypeConfiguration;
 
-        if ( archetypeArtifactManager.isFileSetArchetype( ad.getGroupId(),
-            ad.getArtifactId(), ad.getVersion(), archetypeRepository, 
localRepository,
-            repositories ) )
-        {
-            org.apache.maven.archetype.metadata.ArchetypeDescriptor 
archetypeDescriptor =
-                archetypeArtifactManager.getFileSetArchetypeDescriptor( 
ad.getGroupId(),
-                ad.getArtifactId(), ad.getVersion(), archetypeRepository, 
localRepository,
-                repositories );
-
-            archetypeConfiguration = 
archetypeFactory.createArchetypeConfiguration( archetypeDescriptor,
-                properties );
-        }
-        else if ( archetypeArtifactManager.isOldArchetype( ad.getGroupId(),
-            ad.getArtifactId(), ad.getVersion(), archetypeRepository, 
localRepository,
-            repositories ) )
-        {
-            org.apache.maven.archetype.old.descriptor.ArchetypeDescriptor 
archetypeDescriptor =
-                archetypeArtifactManager.getOldArchetypeDescriptor( 
ad.getGroupId(),
-                ad.getArtifactId(), ad.getVersion(), archetypeRepository, 
localRepository,
-                repositories );
+        if( archetypeArtifactManager.isFileSetArchetype( ad.getGroupId(), 
ad.getArtifactId(), ad.getVersion(),
+                archetypeRepository, localRepository, repositories ) )
+        {
+            org.apache.maven.archetype.metadata.ArchetypeDescriptor 
archetypeDescriptor = archetypeArtifactManager
+                .getFileSetArchetypeDescriptor( ad.getGroupId(), 
ad.getArtifactId(), ad.getVersion(),
+                    archetypeRepository, localRepository, repositories );
+
+            archetypeConfiguration = 
archetypeFactory.createArchetypeConfiguration( archetypeDescriptor, properties 
);
+        }
+        else if( archetypeArtifactManager.isOldArchetype( ad.getGroupId(), 
ad.getArtifactId(), ad.getVersion(),
+                archetypeRepository, localRepository, repositories ) )
+        {
+            org.apache.maven.archetype.old.descriptor.ArchetypeDescriptor 
archetypeDescriptor = archetypeArtifactManager
+                .getOldArchetypeDescriptor( ad.getGroupId(), 
ad.getArtifactId(), ad.getVersion(), archetypeRepository,
+                    localRepository, repositories );
 
-            archetypeConfiguration = 
archetypeFactory.createArchetypeConfiguration( archetypeDescriptor,
-                properties );
+            archetypeConfiguration = 
archetypeFactory.createArchetypeConfiguration( archetypeDescriptor, properties 
);
         }
         else
         {
             throw new ArchetypeGenerationConfigurationFailure( "The defined 
artifact is not an archetype" );
         }
-        
-        // mkleint: if already preconfigured, don't ask for confirmation, 
assume it's fine.
-        if ( !archetypeConfiguration.isConfigured() )
+
+        if( interactiveMode.booleanValue() )
         {
-            if ( interactiveMode.booleanValue() )
-            {
-                boolean confirmed = false;
+            boolean confirmed = false;
 
-                while ( !confirmed )
+            while( !confirmed )
+            {
+                if( !archetypeConfiguration.isConfigured() )
                 {
-                    if ( !archetypeConfiguration.isConfigured() )
+                    Iterator requiredProperties = 
archetypeConfiguration.getRequiredProperties().iterator();
+
+                    while( requiredProperties.hasNext() )
                     {
-                        Iterator requiredProperties = 
archetypeConfiguration.getRequiredProperties().
-                            iterator();
+                        String requiredProperty = (String) 
requiredProperties.next();
 
-                        while ( requiredProperties.hasNext() )
+                        if( !archetypeConfiguration.isConfigured( 
requiredProperty ) )
                         {
-                            String requiredProperty = (String) 
requiredProperties.next();
-
-                            if ( !archetypeConfiguration.isConfigured( 
requiredProperty ) )
-                            {
-                                archetypeConfiguration.setProperty( 
requiredProperty,
-                                    
archetypeGenerationQueryer.getPropertyValue( requiredProperty,
+                            archetypeConfiguration.setProperty( 
requiredProperty,
+                                archetypeGenerationQueryer.getPropertyValue( 
requiredProperty,
                                     archetypeConfiguration.getDefaultValue( 
requiredProperty ) ) );
-                            }
                         }
                     }
+                }
 
-                    if ( !archetypeConfiguration.isConfigured() )
-                    {
-                        throw new ArchetypeGenerationConfigurationFailure(
-                            "The archetype generation must be configured here" 
);
-                    }
-                    else if ( 
!archetypeGenerationQueryer.confirmConfiguration( archetypeConfiguration ) )
-                    {
-                        getLogger().debug( "Archetype generation configuration 
not confirmed" );
-                        archetypeConfiguration.reset();
-                        restoreCommandLineProperties(archetypeConfiguration, 
executionProperties);
-                    }
-                    else
-                    {
-                        getLogger().debug( "Archetype generation configuration 
confirmed" );
+                if( !archetypeConfiguration.isConfigured() )
+                {
+                    throw new ArchetypeGenerationConfigurationFailure(
+                        "The archetype generation must be configured here" );
+                }
+                else if( !archetypeGenerationQueryer.confirmConfiguration( 
archetypeConfiguration ) )
+                {
+                    getLogger().debug( "Archetype generation configuration not 
confirmed" );
+                    archetypeConfiguration.reset();
+                    restoreCommandLineProperties( archetypeConfiguration, 
executionProperties );
+                }
+                else
+                {
+                    getLogger().debug( "Archetype generation configuration 
confirmed" );
 
-                        confirmed = true;
-                    }
+                    confirmed = true;
                 }
             }
-            else
+        }
+        else
+        {
+            if( !archetypeConfiguration.isConfigured() )
             {
-                Iterator requiredProperties = 
archetypeConfiguration.getRequiredProperties().
-                    iterator();
+                Iterator requiredProperties = 
archetypeConfiguration.getRequiredProperties().iterator();
 
-                while ( requiredProperties.hasNext() )
+                while( requiredProperties.hasNext() )
                 {
                     String requiredProperty = (String) 
requiredProperties.next();
 
-                    if ( !archetypeConfiguration.isConfigured( 
requiredProperty ) )
+                    if( !archetypeConfiguration.isConfigured( requiredProperty 
)
+                        && ( archetypeConfiguration.getDefaultValue( 
requiredProperty ) != null ) )
                     {
-                        if ( archetypeConfiguration.getDefaultValue( 
requiredProperty ) != null )
-                        {
-                            archetypeConfiguration.setProperty( 
requiredProperty, archetypeConfiguration.getDefaultValue(
-                                requiredProperty ) );
-                        }
+                        archetypeConfiguration.setProperty( requiredProperty,
+                            archetypeConfiguration.getDefaultValue( 
requiredProperty ) );
                     }
                 }
 
                 // in batch mode, we assume the defaults, and if still not 
configured fail
-                if ( !archetypeConfiguration.isConfigured() )
+                if( !archetypeConfiguration.isConfigured() )
                 {
-                    throw new ArchetypeNotConfigured ( "Archetype " + 
request.getArchetypeGroupId() + ":" + request.getArchetypeArtifactId() + ":" + 
request.getArchetypeVersion() + " is not configured" );                    
+                    throw new ArchetypeNotConfigured( "Archetype " + 
request.getArchetypeGroupId() + ":"
+                        + request.getArchetypeArtifactId() + ":" + 
request.getArchetypeVersion()
+                        + " is not configured" );
                 }
             }
-        }
+        } // end if-else
 
         request.setGroupId( archetypeConfiguration.getProperty( 
Constants.GROUP_ID ) );
 
@@ -232,15 +239,8 @@
         request.setProperties( properties );
     }
 
-    public void setArchetypeArtifactManager( ArchetypeArtifactManager 
archetypeArtifactManager )
-    {
-        this.archetypeArtifactManager = archetypeArtifactManager;
-    }
-
-    private void restoreCommandLineProperties(
-        ArchetypeConfiguration archetypeConfiguration,
-        Properties executionProperties
-    )
+    private void restoreCommandLineProperties( ArchetypeConfiguration 
archetypeConfiguration,
+        Properties executionProperties )
     {
         getLogger().debug( "Restoring command line properties" );
 
@@ -250,13 +250,8 @@
             String property = (String) properties.next();
             if( executionProperties.containsKey( property ) )
             {
-                archetypeConfiguration.setProperty(
-                    property,
-                    executionProperties.getProperty( property )
-                );
-                getLogger().debug(
-                    "Restored " + property + "=" + 
archetypeConfiguration.getProperty( property )
-                );
+                archetypeConfiguration.setProperty( property, 
executionProperties.getProperty( property ) );
+                getLogger().debug( "Restored " + property + "=" + 
archetypeConfiguration.getProperty( property ) );
             }
         }
     }

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=646026&r1=646025&r2=646026&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
 Tue Apr  8 11:45:23 2008
@@ -112,7 +112,7 @@
     // TODO: should test this in interactive mode to check for prompting
     public void testOldArchetypeGeneratedFieldsDefaultsMissingGroupId()
         throws PrompterException, IOException, UnknownGroup, 
ArchetypeSelectionFailure, UnknownArchetype,
-        ArchetypeNotDefined, ArchetypeGenerationConfigurationFailure
+        ArchetypeNotDefined, ArchetypeGenerationConfigurationFailure, 
ArchetypeNotConfigured
     {
         ArchetypeGenerationRequest request = new ArchetypeGenerationRequest();
         request.setArchetypeGroupId( "archetypeGroupId" );
@@ -121,14 +121,8 @@
         Properties properties = new Properties();
         properties.setProperty( "artifactId", "preset-artifactId" );
 
-        try
-        {
-            configurator.configureArchetype( request, Boolean.FALSE, 
properties );
-            fail( "Archetype was not fully configured - fail" );
-        }
-        catch ( ArchetypeNotConfigured archetypeNotDefined )
-        {
-            assertTrue( true );
-        }
+        
+        configurator.configureArchetype( request, Boolean.FALSE, properties );
+        assertEquals( "com.company", request.getGroupId() );
     }
 }


Reply via email to