Author: brett
Date: Wed Jun  8 18:09:32 2005
New Revision: 189679

URL: http://svn.apache.org/viewcvs?rev=189679&view=rev
Log:
PR: MNG-276
Submitted by: Rahul Thakur
Reviewed by:  Brett Porter

improve output during archetype creation


Modified:
    
maven/components/trunk/maven-archetype/maven-archetype-core/src/main/java/org/apache/maven/archetype/DefaultArchetype.java

Modified: 
maven/components/trunk/maven-archetype/maven-archetype-core/src/main/java/org/apache/maven/archetype/DefaultArchetype.java
URL: 
http://svn.apache.org/viewcvs/maven/components/trunk/maven-archetype/maven-archetype-core/src/main/java/org/apache/maven/archetype/DefaultArchetype.java?rev=189679&r1=189678&r2=189679&view=diff
==============================================================================
--- 
maven/components/trunk/maven-archetype/maven-archetype-core/src/main/java/org/apache/maven/archetype/DefaultArchetype.java
 (original)
+++ 
maven/components/trunk/maven-archetype/maven-archetype-core/src/main/java/org/apache/maven/archetype/DefaultArchetype.java
 Wed Jun  8 18:09:32 2005
@@ -25,6 +25,7 @@
 import org.apache.maven.artifact.resolver.ArtifactResolver;
 import org.apache.velocity.VelocityContext;
 import org.apache.velocity.context.Context;
+import org.codehaus.plexus.logging.AbstractLogEnabled;
 import org.codehaus.plexus.util.FileUtils;
 import org.codehaus.plexus.util.StringUtils;
 import org.codehaus.plexus.velocity.VelocityComponent;
@@ -39,12 +40,14 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 /**
  * @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
  * @version $Id$
  */
 public class DefaultArchetype
+    extends AbstractLogEnabled
     implements Archetype
 {
     // ----------------------------------------------------------------------
@@ -65,23 +68,16 @@
     // artifactId = maven-foo-archetype
     // version = latest
 
-    public void createArchetype( String archetypeGroupId,
-                                 String archetypeArtifactId,
-                                 String archetypeVersion,
-                                 ArtifactRepository localRepository,
-                                 List remoteRepositories,
-                                 Map parameters )
+    public void createArchetype( String archetypeGroupId, String 
archetypeArtifactId, String archetypeVersion,
+                                 ArtifactRepository localRepository, List 
remoteRepositories, Map parameters )
         throws ArchetypeNotFoundException, ArchetypeDescriptorException, 
ArchetypeTemplateProcessingException
     {
         // 
----------------------------------------------------------------------
         // Download the archetype
         // 
----------------------------------------------------------------------
 
-        Artifact archetypeArtifact = artifactFactory.createArtifact( 
archetypeGroupId,
-                                                                     
archetypeArtifactId,
-                                                                     
archetypeVersion,
-                                                                     
Artifact.SCOPE_RUNTIME,
-                                                                     "jar" );
+        Artifact archetypeArtifact = artifactFactory.createArtifact( 
archetypeGroupId, archetypeArtifactId,
+                                                                     
archetypeVersion, Artifact.SCOPE_RUNTIME, "jar" );
 
         try
         {
@@ -92,6 +88,47 @@
             throw new ArchetypeNotFoundException( "Cannot download 
archetype.", e );
         }
 
+        // 
---------------------------------------------------------------------
+        // Get Logger and display all parameters used 
+        // 
---------------------------------------------------------------------
+        if ( getLogger().isInfoEnabled() )
+        {
+
+            if ( !parameters.isEmpty() )
+            {
+
+                getLogger().info( 
"----------------------------------------------------------------------------" 
);
+
+                getLogger().info( "Using following parameters for creating 
Archetype: " + archetypeArtifactId + ":" + archetypeVersion );
+
+                getLogger().info( 
"----------------------------------------------------------------------------" 
);
+
+                Set keys = parameters.keySet();
+
+                Iterator it = keys.iterator();
+
+                while ( it.hasNext() )
+                {
+
+                    String parameterName = (String) it.next();
+
+                    String parameterValue = (String) parameters.get( 
parameterName );
+
+                    getLogger().info( "Parameter: " + parameterName + ", 
Value: " + parameterValue );
+
+                }
+
+            }
+            else
+            {
+
+                getLogger().info( "No Parameters found for creating Archetype" 
);
+
+            }
+
+        }
+        
+        
         // 
----------------------------------------------------------------------
         // Load the descriptor
         // 
----------------------------------------------------------------------
@@ -118,8 +155,7 @@
 
             if ( is == null )
             {
-                throw new ArchetypeDescriptorException( "The " + 
ARCHETYPE_DESCRIPTOR +
-                                                        " descriptor cannot be 
found." );
+                throw new ArchetypeDescriptorException( "The " + 
ARCHETYPE_DESCRIPTOR + " descriptor cannot be found." );
             }
 
             descriptor = (ArchetypeDescriptor) builder.build( new 
InputStreamReader( is ) );
@@ -212,6 +248,15 @@
         {
             Thread.currentThread().setContextClassLoader( old );
         }
+        
+        // 
----------------------------------------------------------------------
+        // Log message on Archetype creation
+        // 
----------------------------------------------------------------------
+        if ( getLogger().isInfoEnabled() )
+        {
+            getLogger().info( "Archetype created in dir: " + outputDirectory );
+        }
+
     }
 
     // ----------------------------------------------------------------------
@@ -240,11 +285,8 @@
         }
     }
 
-    protected void processTemplate( String outputDirectory,
-                                    Context context,
-                                    String template,
-                                    boolean packageInFileName,
-                                    String packageName )
+    protected void processTemplate( String outputDirectory, Context context, 
String template,
+                                    boolean packageInFileName, String 
packageName )
         throws Exception
     {
         File f;



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to