You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2010/03/21 11:46:13 UTC

svn commit: r925751 - in /maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/generator: ArchetypeGenerator.java DefaultArchetypeGenerator.java DefaultFilesetArchetypeGenerator.java FilesetArchetypeGenerator.java

Author: hboutemy
Date: Sun Mar 21 10:46:13 2010
New Revision: 925751

URL: http://svn.apache.org/viewvc?rev=925751&view=rev
Log:
minor code refactorings

Modified:
    maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/generator/ArchetypeGenerator.java
    maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/generator/DefaultArchetypeGenerator.java
    maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/generator/DefaultFilesetArchetypeGenerator.java
    maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/generator/FilesetArchetypeGenerator.java

Modified: maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/generator/ArchetypeGenerator.java
URL: http://svn.apache.org/viewvc/maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/generator/ArchetypeGenerator.java?rev=925751&r1=925750&r2=925751&view=diff
==============================================================================
--- maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/generator/ArchetypeGenerator.java (original)
+++ maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/generator/ArchetypeGenerator.java Sun Mar 21 10:46:13 2010
@@ -26,8 +26,7 @@ public interface ArchetypeGenerator
 {
     String ROLE = ArchetypeGenerator.class.getName();
 
-    void generateArchetype( ArchetypeGenerationRequest request,
-                            ArchetypeGenerationResult result );
+    void generateArchetype( ArchetypeGenerationRequest request, ArchetypeGenerationResult result );
 
 //    void generateArchetype(
 //        File propertyFile,

Modified: maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/generator/DefaultArchetypeGenerator.java
URL: http://svn.apache.org/viewvc/maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/generator/DefaultArchetypeGenerator.java?rev=925751&r1=925750&r2=925751&view=diff
==============================================================================
--- maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/generator/DefaultArchetypeGenerator.java (original)
+++ maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/generator/DefaultArchetypeGenerator.java Sun Mar 21 10:46:13 2010
@@ -62,22 +62,10 @@ public class DefaultArchetypeGenerator
     /** @plexus.requirement */
     private OldArchetype oldArchetype;
 
-    private void generateArchetype(
-        ArchetypeGenerationRequest request,
-        ArtifactRepository localRepository,
-        String basedir
-    )
-        throws
-        IOException,
-        ArchetypeNotDefined,
-        UnknownArchetype,
-        ArchetypeNotConfigured,
-        ProjectDirectoryExists,
-        PomFileExists,
-        OutputFileExists,
-        XmlPullParserException,
-        DocumentException,
-        InvalidPackaging,
+    private void generateArchetype( ArchetypeGenerationRequest request, ArtifactRepository localRepository,
+                                    String basedir )
+        throws IOException, ArchetypeNotDefined, UnknownArchetype, ArchetypeNotConfigured, ProjectDirectoryExists,
+        PomFileExists, OutputFileExists, XmlPullParserException, DocumentException, InvalidPackaging,
         ArchetypeGenerationFailure
     {
         if ( !isArchetypeDefined( request ) )
@@ -85,62 +73,38 @@ public class DefaultArchetypeGenerator
             throw new ArchetypeNotDefined( "The archetype is not defined" );
         }
 
-        List repos = new ArrayList( /*repositories*/ );
+        List repos = new ArrayList(/* repositories */);
 
         ArtifactRepository remoteRepo = null;
-        if ( request != null  && request.getArchetypeRepository() != null )
+        if ( request != null && request.getArchetypeRepository() != null )
         {
-            remoteRepo=archetypeRegistryManager.createRepository(
-                request.getArchetypeRepository(),
-                request.getArchetypeArtifactId() + "-repo" );
+            remoteRepo =
+                archetypeRegistryManager.createRepository( request.getArchetypeRepository(),
+                                                           request.getArchetypeArtifactId() + "-repo" );
 
             repos.add( remoteRepo );
         }
 
-        if ( !archetypeArtifactManager.exists(
-            request.getArchetypeGroupId(),
-            request.getArchetypeArtifactId(),
-            request.getArchetypeVersion(),remoteRepo,
-            localRepository,
-            repos ) )
-        {
-            throw new UnknownArchetype(
-                "The desired archetype does not exist (" + request.getArchetypeGroupId() + ":"
-                    + request.getArchetypeArtifactId() + ":" + request.getArchetypeVersion()
-                    + ")"
-            );
-        }
-
-        if ( archetypeArtifactManager.isFileSetArchetype(
-            request.getArchetypeGroupId(),
-            request.getArchetypeArtifactId(),
-            request.getArchetypeVersion(),remoteRepo,
-            localRepository,
-            repos
-        )
-            )
-        {
-            processFileSetArchetype(
-                request,remoteRepo,
-                localRepository,
-                basedir,
-                repos
-            );
-        }
-        else if (
-            archetypeArtifactManager.isOldArchetype(
-                request.getArchetypeGroupId(),
-                request.getArchetypeArtifactId(),
-                request.getArchetypeVersion(),remoteRepo,
-                localRepository,
-                repos ) )
-        {
-            processOldArchetype(
-                request,remoteRepo,
-                localRepository,
-                basedir,
-                repos
-            );
+        if ( !archetypeArtifactManager.exists( request.getArchetypeGroupId(), request.getArchetypeArtifactId(),
+                                               request.getArchetypeVersion(), remoteRepo, localRepository, repos ) )
+        {
+            throw new UnknownArchetype( "The desired archetype does not exist (" + request.getArchetypeGroupId() + ":"
+                + request.getArchetypeArtifactId() + ":" + request.getArchetypeVersion() + ")" );
+        }
+
+        if ( archetypeArtifactManager.isFileSetArchetype( request.getArchetypeGroupId(),
+                                                          request.getArchetypeArtifactId(),
+                                                          request.getArchetypeVersion(), remoteRepo, localRepository,
+                                                          repos ) )
+        {
+            processFileSetArchetype( request, remoteRepo, localRepository, basedir, repos );
+        }
+        else if ( archetypeArtifactManager.isOldArchetype( request.getArchetypeGroupId(),
+                                                           request.getArchetypeArtifactId(),
+                                                           request.getArchetypeVersion(), remoteRepo, localRepository,
+                                                           repos ) )
+        {
+            processOldArchetype( request, remoteRepo, localRepository, basedir, repos );
         }
         else
         {
@@ -156,25 +120,16 @@ public class DefaultArchetypeGenerator
 
     private boolean isArchetypeDefined( ArchetypeGenerationRequest request )
     {
-        return org.codehaus.plexus.util.StringUtils.isNotEmpty( request.getArchetypeGroupId() )
-        && org.codehaus.plexus.util.StringUtils.isNotEmpty( request.getArchetypeArtifactId() )
-        && org.codehaus.plexus.util.StringUtils.isNotEmpty( request.getArchetypeVersion() );
+        return StringUtils.isNotEmpty( request.getArchetypeGroupId() )
+            && StringUtils.isNotEmpty( request.getArchetypeArtifactId() )
+            && StringUtils.isNotEmpty( request.getArchetypeVersion() );
     }
 
     /** FileSetArchetype */
-    private void processFileSetArchetype(
-        final ArchetypeGenerationRequest request,
-        ArtifactRepository remoteRepo,
-        final ArtifactRepository localRepository,
-        final String basedir,
-        final List repositories
-    )
-        throws
-        UnknownArchetype,
-        ArchetypeNotConfigured,
-        ProjectDirectoryExists,
-        PomFileExists,
-        OutputFileExists,
+    private void processFileSetArchetype( final ArchetypeGenerationRequest request, ArtifactRepository remoteRepo,
+                                          final ArtifactRepository localRepository, final String basedir,
+                                          final List repositories )
+        throws UnknownArchetype, ArchetypeNotConfigured, ProjectDirectoryExists, PomFileExists, OutputFileExists,
         ArchetypeGenerationFailure
     {
         //TODO: get rid of the property file usage.
@@ -197,79 +152,39 @@ public class DefaultArchetypeGenerator
 //        properties.setProperty( Constants.ARCHETYPE_POST_GENERATION_GOALS, request.getArchetypeGoals() );
 
         File archetypeFile =
-            archetypeArtifactManager.getArchetypeFile(
-                request.getArchetypeGroupId(),
-                request.getArchetypeArtifactId(),
-                request.getArchetypeVersion(),remoteRepo,
-                localRepository,
-                repositories
-            );
+            archetypeArtifactManager.getArchetypeFile( request.getArchetypeGroupId(), request.getArchetypeArtifactId(),
+                                                       request.getArchetypeVersion(), remoteRepo, localRepository,
+                                                       repositories );
 
         filesetGenerator.generateArchetype( request, archetypeFile, basedir );
     }
 
-    private void processOldArchetype(
-        ArchetypeGenerationRequest request,
-        ArtifactRepository remoteRepo,
-        ArtifactRepository localRepository,
-        String basedir,
-        List repositories
-    )
-        throws
-        UnknownArchetype,
-        ArchetypeGenerationFailure
+    private void processOldArchetype( ArchetypeGenerationRequest request, ArtifactRepository remoteRepo,
+                                      ArtifactRepository localRepository, String basedir, List repositories )
+        throws UnknownArchetype, ArchetypeGenerationFailure
     {
         org.apache.maven.archetype.old.descriptor.ArchetypeDescriptor archetypeDescriptor =
-            archetypeArtifactManager.getOldArchetypeDescriptor(
-                request.getArchetypeGroupId(),
-                request.getArchetypeArtifactId(),
-                request.getArchetypeVersion(),remoteRepo,
-                localRepository,
-                repositories
-            );
-
-        Map map = new HashMap();
-
-        map.put( "basedir", basedir );
-
-        map.put( "package", request.getPackage() );
-
-        map.put( "packageName", request.getPackage() );
-
-        map.put( "groupId", request.getGroupId() );
-
-        map.put( "artifactId", request.getArtifactId() );
-
-        map.put( "version", request.getVersion() );
-//        try
-//        {
-            oldArchetype.createArchetype(
-                request.getArchetypeGroupId(),
-                request.getArchetypeArtifactId(),
-                request.getArchetypeVersion(),remoteRepo,
-                localRepository,
-                repositories,
-                map
-            );
-//        }
-//        catch ( ArchetypeDescriptorException ex )
-//        {
-//            throw new ArchetypeGenerationFailure(
-//                "Failed to generate project from the old archetype", ex
-//            );
-//        }
-//        catch ( ArchetypeTemplateProcessingException ex )
-//        {
-//            throw new ArchetypeGenerationFailure(
-//                "Failed to generate project from the old archetype", ex
-//            );
-//        }
-//        catch ( ArchetypeNotFoundException ex )
-//        {
-//            throw new ArchetypeGenerationFailure(
-//                "Failed to generate project from the old archetype", ex
-//            );
-//        }
+            archetypeArtifactManager.getOldArchetypeDescriptor( request.getArchetypeGroupId(),
+                                                                request.getArchetypeArtifactId(),
+                                                                request.getArchetypeVersion(), remoteRepo,
+                                                                localRepository, repositories );
+
+        Map parameters = new HashMap();
+
+        parameters.put( "basedir", basedir );
+
+        parameters.put( "package", request.getPackage() );
+
+        parameters.put( "packageName", request.getPackage() );
+
+        parameters.put( "groupId", request.getGroupId() );
+
+        parameters.put( "artifactId", request.getArtifactId() );
+
+        parameters.put( "version", request.getVersion() );
+
+        oldArchetype.createArchetype( request.getArchetypeGroupId(), request.getArchetypeArtifactId(),
+                                      request.getArchetypeVersion(), remoteRepo, localRepository, repositories, parameters );
     }
 
     public void generateArchetype( ArchetypeGenerationRequest request, ArchetypeGenerationResult result )
@@ -280,58 +195,58 @@ public class DefaultArchetypeGenerator
         }
         catch ( IOException ex )
         {
-            getLogger().error(ex.getMessage(), ex);
-            result.setCause(ex);
+            getLogger().error( ex.getMessage(), ex );
+            result.setCause( ex );
         }
         catch ( ArchetypeNotDefined ex )
         {
-            getLogger().error(ex.getMessage(), ex);
-            result.setCause(ex);
+            getLogger().error( ex.getMessage(), ex );
+            result.setCause( ex );
         }
         catch ( UnknownArchetype ex )
         {
-            getLogger().error(ex.getMessage(), ex);
-            result.setCause(ex);
+            getLogger().error( ex.getMessage(), ex );
+            result.setCause( ex );
         }
         catch ( ArchetypeNotConfigured ex )
         {
-            getLogger().error(ex.getMessage(), ex);
-            result.setCause(ex);
+            getLogger().error( ex.getMessage(), ex );
+            result.setCause( ex );
         }
         catch ( ProjectDirectoryExists ex )
         {
-            getLogger().error(ex.getMessage(), ex);
-            result.setCause(ex);
+            getLogger().error( ex.getMessage(), ex );
+            result.setCause( ex );
         }
         catch ( PomFileExists ex )
         {
-            getLogger().error(ex.getMessage(), ex);
-            result.setCause(ex);
+            getLogger().error( ex.getMessage(), ex );
+            result.setCause( ex );
         }
         catch ( OutputFileExists ex )
         {
-            getLogger().error(ex.getMessage(), ex);
-            result.setCause(ex);
+            getLogger().error( ex.getMessage(), ex );
+            result.setCause( ex );
         }
         catch ( XmlPullParserException ex )
         {
-            getLogger().error(ex.getMessage(), ex);
-            result.setCause(ex);
+            getLogger().error( ex.getMessage(), ex );
+            result.setCause( ex );
         }
         catch ( DocumentException ex )
         {
-            getLogger().error(ex.getMessage(), ex);
-            result.setCause(ex);
+            getLogger().error( ex.getMessage(), ex );
+            result.setCause( ex );
         }
         catch ( InvalidPackaging ex )
         {
-            getLogger().error(ex.getMessage(), ex);
-            result.setCause(ex);
+            getLogger().error( ex.getMessage(), ex );
+            result.setCause( ex );
         }
         catch ( ArchetypeGenerationFailure ex )
         {
-            getLogger().error(ex.getMessage(), ex);
-            result.setCause(ex);
+            getLogger().error( ex.getMessage(), ex );
+            result.setCause( ex );
         }
     }
 }

Modified: maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/generator/DefaultFilesetArchetypeGenerator.java
URL: http://svn.apache.org/viewvc/maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/generator/DefaultFilesetArchetypeGenerator.java?rev=925751&r1=925750&r2=925751&view=diff
==============================================================================
--- maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/generator/DefaultFilesetArchetypeGenerator.java (original)
+++ maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/generator/DefaultFilesetArchetypeGenerator.java Sun Mar 21 10:46:13 2010
@@ -78,25 +78,18 @@ public class DefaultFilesetArchetypeGene
     private VelocityComponent velocity;
 
     /**
-     * Token delimiter. 
+     * Token delimiter.
      */
     private static final String DELIMITER = "__";
 
     /**
      * Pattern used to detect tokens in a string. Tokens are any text surrounded
-     * by the delimiter. 
+     * by the delimiter.
      */
-    private static final Pattern TOKEN_PATTERN = Pattern.compile(".*" + DELIMITER + ".*" + DELIMITER + ".*");
+    private static final Pattern TOKEN_PATTERN = Pattern.compile( ".*" + DELIMITER + ".*" + DELIMITER + ".*" );
 
-    public void generateArchetype( ArchetypeGenerationRequest request,
-                                   File archetypeFile,
-                                   String basedir )
-        throws
-        UnknownArchetype,
-        ArchetypeNotConfigured,
-        ProjectDirectoryExists,
-        PomFileExists,
-        OutputFileExists,
+    public void generateArchetype( ArchetypeGenerationRequest request, File archetypeFile, String basedir )
+        throws UnknownArchetype, ArchetypeNotConfigured, ProjectDirectoryExists, PomFileExists, OutputFileExists,
         ArchetypeGenerationFailure
     {
         ClassLoader old = Thread.currentThread().getContextClassLoader();
@@ -110,35 +103,29 @@ public class DefaultFilesetArchetypeGene
             {
                 if ( request.isInteractiveMode () )
                 {
-                    throw new ArchetypeNotConfigured ( "No archetype was chosen", null );
+                    throw new ArchetypeNotConfigured ( "No archetype was chosen.", null );
                 }
                 else
                 {
                     StringBuffer exceptionMessage = new StringBuffer();
-                    exceptionMessage.append("Archetype " );
-                    exceptionMessage.append( request.getArchetypeGroupId() );
-                    exceptionMessage.append( ":" );
-                    exceptionMessage.append( request.getArchetypeArtifactId() );
-                    exceptionMessage.append( ":" );
-                    exceptionMessage.append( request.getArchetypeVersion() );
-                    exceptionMessage.append( " is not configured" );
-                    
+                    exceptionMessage.append( "Archetype " + request.getArchetypeGroupId() + ":"
+                        + request.getArchetypeArtifactId() + ":" + request.getArchetypeVersion()
+                        + " is not configured" );
+
                     List missingProperties = new ArrayList( 0 );
-                    java.util.Iterator requiredProperties = 
-                            archetypeDescriptor.getRequiredProperties().iterator();
-                    while( requiredProperties.hasNext() )
+                    for ( Iterator requiredProperties = archetypeDescriptor.getRequiredProperties().iterator();
+                        requiredProperties.hasNext(); )
                     {
-                        RequiredProperty requiredProperty = (RequiredProperty) requiredProperties.next ();
-                        if (org.codehaus.plexus.util.StringUtils.isEmpty(
-                            request.getProperties().getProperty ( requiredProperty.getKey() ) ) )
+                        RequiredProperty requiredProperty = (RequiredProperty) requiredProperties.next();
+
+                        if ( StringUtils.isEmpty( request.getProperties().getProperty( requiredProperty.getKey() ) ) )
                         {
-                            exceptionMessage.append( "\n\tProperty " );
-                            exceptionMessage.append( requiredProperty.getKey() );
+                            exceptionMessage.append( "\n\tProperty " + requiredProperty.getKey() + " is missing." );
+
                             missingProperties.add( requiredProperty.getKey() );
-                            exceptionMessage.append( " is missing." );
                         }
                     }
-                    
+
                     throw new ArchetypeNotConfigured( exceptionMessage.toString(), missingProperties );
                 }
             }
@@ -164,29 +151,20 @@ public class DefaultFilesetArchetypeGene
 
             if ( archetypeDescriptor.isPartial() )
             {
-                getLogger().debug(
-                    "Procesing partial archetype " + archetypeDescriptor.getName()
-                );
+                getLogger().debug( "Processing partial archetype " + archetypeDescriptor.getName() );
                 if ( outputDirectoryFile.exists() )
                 {
                     if ( !pom.exists() )
                     {
-                        throw new PomFileExists(
-                            "This is a partial archetype and the pom.xml file doesn't exist."
-                        );
+                        throw new PomFileExists( "This is a partial archetype and the pom.xml file doesn't exist." );
                     }
                     else
                     {
                         processPomWithMerge( context, pom, "" );
-                        processArchetypeTemplatesWithWarning(
-                            archetypeDescriptor,
-                            archetypeResources,
-                            archetypeZipFile,
-                            "",
-                            context,
-                            packageName,
-                            outputDirectoryFile
-                        );
+
+                        processArchetypeTemplatesWithWarning( archetypeDescriptor, archetypeResources,
+                                                              archetypeZipFile, "", context, packageName,
+                                                              outputDirectoryFile );
                     }
                 }
                 else
@@ -194,28 +172,17 @@ public class DefaultFilesetArchetypeGene
                     if ( basedirPom.exists() )
                     {
                         processPomWithMerge( context, basedirPom, "" );
-                        processArchetypeTemplatesWithWarning(
-                            archetypeDescriptor,
-                            archetypeResources,
-                            archetypeZipFile,
-                            "",
-                            context,
-                            packageName,
-                            new File( basedir )
-                        );
+
+                        processArchetypeTemplatesWithWarning( archetypeDescriptor, archetypeResources,
+                                                              archetypeZipFile, "", context, packageName,
+                                                              new File( basedir ) );
                     }
                     else
                     {
                         processPom( context, pom, "" );
-                        processArchetypeTemplates(
-                            archetypeDescriptor,
-                            archetypeResources,
-                            archetypeZipFile,
-                            "",
-                            context,
-                            packageName,
-                            outputDirectoryFile
-                        );
+
+                        processArchetypeTemplates( archetypeDescriptor, archetypeResources, archetypeZipFile, "",
+                                                   context, packageName, outputDirectoryFile );
                     }
                 }
 
@@ -226,12 +193,11 @@ public class DefaultFilesetArchetypeGene
             }
             else
             {
-                getLogger().debug(
-                    "Processing complete archetype " + archetypeDescriptor.getName()
-                );
+                getLogger().debug( "Processing complete archetype " + archetypeDescriptor.getName() );
                 if ( outputDirectoryFile.exists() && pom.exists() )
                 {
-                    throw new ProjectDirectoryExists( "A Maven 2 project already exists in the directory " + outputDirectoryFile.getPath() );
+                    throw new ProjectDirectoryExists( "A Maven 2 project already exists in the directory "
+                        + outputDirectoryFile.getPath() );
                 }
                 else
                 {
@@ -239,21 +205,11 @@ public class DefaultFilesetArchetypeGene
                     {
                         getLogger().warn( "The directory " + outputDirectoryFile.getPath() + " already exists." );
                     }
+
                     context.put( "rootArtifactId", artifactId );
 
-                    processFilesetModule(
-                        artifactId,
-                        artifactId,
-                        archetypeResources,
-                        pom,
-                        archetypeZipFile,
-                        "",
-                        basedirPom,
-                        outputDirectoryFile,
-                        packageName,
-                        archetypeDescriptor,
-                        context
-                    );
+                    processFilesetModule( artifactId, artifactId, archetypeResources, pom, archetypeZipFile, "",
+                                          basedirPom, outputDirectoryFile, packageName, archetypeDescriptor, context );
                 }
             }
         }
@@ -292,16 +248,9 @@ public class DefaultFilesetArchetypeGene
         return StringUtils.replace( packageName, ".", "/" );
     }
 
-    private void copyFile(
-        final File outFile,
-        final String template,
-        final boolean failIfExists,
-        final ZipFile archetypeZipFile
-    )
-        throws
-        FileNotFoundException,
-        OutputFileExists,
-        IOException
+    private void copyFile( final File outFile, final String template, final boolean failIfExists,
+                           final ZipFile archetypeZipFile )
+        throws FileNotFoundException, OutputFileExists, IOException
     {
         getLogger().debug( "Copying file " + template );
 
@@ -326,30 +275,19 @@ public class DefaultFilesetArchetypeGene
         }
     }
 
-    private void copyFiles(
-        String directory,
-        List fileSetResources,
-        boolean packaged,
-        String packageName,
-        File outputDirectoryFile,
-        ZipFile archetypeZipFile,
-        String moduleOffset,
-        boolean failIfExists,
-        Context context
-    )
-        throws
-        OutputFileExists,
-        FileNotFoundException,
-        IOException
+    private void copyFiles( String directory, List fileSetResources, boolean packaged, String packageName,
+                            File outputDirectoryFile, ZipFile archetypeZipFile, String moduleOffset,
+                            boolean failIfExists, Context context )
+        throws OutputFileExists, FileNotFoundException, IOException
     {
         Iterator iterator = fileSetResources.iterator();
 
         while ( iterator.hasNext() )
         {
             String template = (String) iterator.next();
-            File outputFile = getOutputFile( 
-                    template, directory, outputDirectoryFile, 
-                    packaged, packageName, moduleOffset, context);
+
+            File outputFile =
+                getOutputFile( template, directory, outputDirectoryFile, packaged, packageName, moduleOffset, context );
 
             copyFile( outputFile, template, failIfExists, archetypeZipFile );
         }
@@ -357,32 +295,24 @@ public class DefaultFilesetArchetypeGene
 
     private String getEncoding( String archetypeEncoding )
     {
-        return
-            ( ( null == archetypeEncoding ) || "".equals( archetypeEncoding ) )
-                ? "UTF-8"
-                : archetypeEncoding;
+        return StringUtils.isEmpty( archetypeEncoding ) ? "UTF-8" : archetypeEncoding;
     }
 
     private String getOffsetSeparator( String moduleOffset )
     {
-        return ( StringUtils.isEmpty( moduleOffset ) ? "/" : ( "/" + moduleOffset + "/" ) );
+        return StringUtils.isEmpty( moduleOffset ) ? "/" : ( "/" + moduleOffset + "/" );
     }
 
-    private File getOutputFile( 
-        String template, 
-        String directory, 
-        File outputDirectoryFile, 
-        boolean packaged, 
-        String packageName, 
-        String moduleOffset,
-        Context context )
+    private File getOutputFile( String template, String directory, File outputDirectoryFile, boolean packaged,
+                                String packageName, String moduleOffset, Context context )
     {
         String templateName = StringUtils.replaceOnce( template, directory, "" );
-        String outputFileName = directory + "/" + 
-                (packaged ? getPackageAsDirectory(packageName) : "") + 
-                "/" + templateName.substring(moduleOffset.length() );
 
-        if ( TOKEN_PATTERN.matcher(outputFileName).matches() ) 
+        String outputFileName =
+            directory + "/" + ( packaged ? getPackageAsDirectory( packageName ) : "" ) + "/"
+                + templateName.substring( moduleOffset.length() );
+
+        if ( TOKEN_PATTERN.matcher(outputFileName).matches() )
         {
             outputFileName = replaceFilenameTokens( outputFileName, context );
         }
@@ -393,15 +323,15 @@ public class DefaultFilesetArchetypeGene
     }
 
     /**
-     * Replaces all tokens (text surrounded by the {@link #DELIMITER}) within 
-     * the given string, using properties contained within the context. If a 
-     * property does not exist in the context, the token is left unmodified 
+     * Replaces all tokens (text surrounded by the {@link #DELIMITER}) within
+     * the given string, using properties contained within the context. If a
+     * property does not exist in the context, the token is left unmodified
      * and a warning is logged.
      *
-     * @param filePath the file name and path to be interpolated  
-     * @param context contains the available properties 
-     */  
-    private String replaceFilenameTokens( String filePath, Context context ) 
+     * @param filePath the file name and path to be interpolated
+     * @param context contains the available properties
+     */
+    private String replaceFilenameTokens( String filePath, Context context )
     {
         String interpolatedResult = filePath;
         String propertyToken = null;
@@ -411,60 +341,55 @@ public class DefaultFilesetArchetypeGene
         int end = 0;
         int skipUndefinedPropertyIndex = 0;
 
-        int maxAttempts = StringUtils.countMatches( interpolatedResult, 
-                DELIMITER ) / 2;
+        int maxAttempts = StringUtils.countMatches( interpolatedResult, DELIMITER ) / 2;
 
-        for ( int x = 0; x < maxAttempts && start != -1; x++ ) 
+        for ( int x = 0; x < maxAttempts && start != -1; x++ )
         {
             start = interpolatedResult.indexOf( DELIMITER, skipUndefinedPropertyIndex );
 
-            if ( start != -1 ) 
+            if ( start != -1 )
             {
-                end = interpolatedResult.indexOf( DELIMITER, 
-                        start + DELIMITER.length() );
+                end = interpolatedResult.indexOf( DELIMITER, start + DELIMITER.length() );
 
-                if ( end != -1 ) 
+                if ( end != -1 )
                 {
-                   propertyToken = interpolatedResult.substring( 
-                           start + DELIMITER.length(), end );
+                    propertyToken = interpolatedResult.substring( start + DELIMITER.length(), end );
                 }
 
                 contextPropertyValue = (String) context.get( propertyToken );
-    
-                if ( contextPropertyValue != null && 
-                            contextPropertyValue.trim().length() > 0 ) 
+
+                if ( contextPropertyValue != null && contextPropertyValue.trim().length() > 0 )
                 {
-                    if (getLogger().isDebugEnabled())
+                    if ( getLogger().isDebugEnabled() )
                     {
-                        getLogger().debug( "Replacing '" + DELIMITER + propertyToken
-                                + DELIMITER + "' in file path '" + 
-                                interpolatedResult + "' with value '" + 
-                                contextPropertyValue + "'."); 
+                        getLogger().debug(
+                                           "Replacing '" + DELIMITER + propertyToken + DELIMITER + "' in file path '"
+                                               + interpolatedResult + "' with value '" + contextPropertyValue + "'." );
                     }
-                  
-                    interpolatedResult = StringUtils.replace( 
-                            interpolatedResult, 
-                            DELIMITER + propertyToken + DELIMITER, 
-                            contextPropertyValue );
-    
-                } else 
+
+                    interpolatedResult =
+                        StringUtils.replace( interpolatedResult, DELIMITER + propertyToken + DELIMITER,
+                                             contextPropertyValue );
+
+                }
+                else
                 {
                     // Need to skip the undefined property
                     skipUndefinedPropertyIndex = end + DELIMITER.length() + 1;
-                   
-                    getLogger().warn( "Property '" + propertyToken + 
-                            "' was not specified, so the token in '" + 
-                            interpolatedResult + "' is not being replaced." );
+
+                    getLogger().warn(
+                                      "Property '" + propertyToken + "' was not specified, so the token in '"
+                                          + interpolatedResult + "' is not being replaced." );
                 }
             }
         }
 
-        if (getLogger().isDebugEnabled())
+        if ( getLogger().isDebugEnabled() )
         {
-            getLogger().debug( "Final interpolated file path: '" + interpolatedResult + "'" ); 
+            getLogger().debug( "Final interpolated file path: '" + interpolatedResult + "'" );
         }
 
-        return interpolatedResult; 
+        return interpolatedResult;
     }
 
     private String getPackageInPathFormat( String aPackage )
@@ -476,22 +401,20 @@ public class DefaultFilesetArchetypeGene
     {
         boolean configured = true;
 
-        java.util.Iterator requiredProperties = archetypeDescriptor.getRequiredProperties().iterator();
-        while ( configured && requiredProperties.hasNext () )
+        Iterator requiredProperties = archetypeDescriptor.getRequiredProperties().iterator();
+
+        while ( configured && requiredProperties.hasNext() )
         {
-            RequiredProperty requiredProperty = (RequiredProperty) requiredProperties.next ();
+            RequiredProperty requiredProperty = (RequiredProperty) requiredProperties.next();
 
-            configured = configured &&
-                org.codehaus.plexus.util.StringUtils.isNotEmpty(
-                    request.getProperties().getProperty ( requiredProperty.getKey() )
-                );
+            configured =
+                configured && StringUtils.isNotEmpty( request.getProperties().getProperty( requiredProperty.getKey() ) );
         }
 
         return configured;
     }
 
-    private void setParentArtifactId( Context context,
-                                      String artifactId )
+    private void setParentArtifactId( Context context, String artifactId )
     {
         context.put( Constants.PARENT_ARTIFACT_ID, artifactId );
     }
@@ -499,14 +422,13 @@ public class DefaultFilesetArchetypeGene
     private Context prepareVelocityContext( ArchetypeGenerationRequest request )
     {
         Context context = new VelocityContext();
-        context.put(Constants.GROUP_ID, request.getGroupId());
-        context.put(Constants.ARTIFACT_ID, request.getArtifactId());
-        context.put(Constants.VERSION, request.getVersion());
-        context.put(Constants.PACKAGE, request.getPackage());
-        context.put(Constants.PACKAGE_IN_PATH_FORMAT, getPackageInPathFormat(request.getPackage()));
+        context.put( Constants.GROUP_ID, request.getGroupId() );
+        context.put( Constants.ARTIFACT_ID, request.getArtifactId() );
+        context.put( Constants.VERSION, request.getVersion() );
+        context.put( Constants.PACKAGE, request.getPackage() );
+        context.put( Constants.PACKAGE_IN_PATH_FORMAT, getPackageInPathFormat( request.getPackage() ) );
 
-        Iterator iterator = request.getProperties().keySet().iterator();
-        while ( iterator.hasNext() )
+        for ( Iterator iterator = request.getProperties().keySet().iterator(); iterator.hasNext(); )
         {
             String key = (String) iterator.next();
 
@@ -517,114 +439,48 @@ public class DefaultFilesetArchetypeGene
         return context;
     }
 
-    private void processArchetypeTemplates(
-        AbstractArchetypeDescriptor archetypeDescriptor,
-        List archetypeResources,
-        ZipFile archetypeZipFile,
-        String moduleOffset,
-        Context context,
-        String packageName,
-        File outputDirectoryFile
-    )
-        throws
-        OutputFileExists,
-        ArchetypeGenerationFailure,
-        FileNotFoundException,
-        IOException
-    {
-        processTemplates(
-            packageName,
-            outputDirectoryFile,
-            context,
-            archetypeDescriptor,
-            archetypeResources,
-            archetypeZipFile,
-            moduleOffset,
-            false
-        );
+    private void processArchetypeTemplates( AbstractArchetypeDescriptor archetypeDescriptor, List archetypeResources,
+                                            ZipFile archetypeZipFile, String moduleOffset, Context context,
+                                            String packageName, File outputDirectoryFile )
+        throws OutputFileExists, ArchetypeGenerationFailure, FileNotFoundException, IOException
+    {
+        processTemplates( packageName, outputDirectoryFile, context, archetypeDescriptor, archetypeResources,
+                          archetypeZipFile, moduleOffset, false );
     }
 
     private void processArchetypeTemplatesWithWarning(
-        org.apache.maven.archetype.metadata.ArchetypeDescriptor archetypeDescriptor,
-        List archetypeResources,
-        ZipFile archetypeZipFile,
-        String moduleOffset,
-        Context context,
-        String packageName,
-        File outputDirectoryFile
-    )
-        throws
-        OutputFileExists,
-        ArchetypeGenerationFailure,
-        FileNotFoundException,
-        IOException
-    {
-        processTemplates(
-            packageName,
-            outputDirectoryFile,
-            context,
-            archetypeDescriptor,
-            archetypeResources,
-            archetypeZipFile,
-            moduleOffset,
-            true
-        );
-    }
-
-    private void processFileSet(
-        String directory,
-        List fileSetResources,
-        boolean packaged,
-        String packageName,
-        Context context,
-        File outputDirectoryFile,
-        String moduleOffset,
-        String archetypeEncoding,
-        boolean failIfExists
-    )
-        throws
-        OutputFileExists,
-        ArchetypeGenerationFailure
+                                                       org.apache.maven.archetype.metadata.ArchetypeDescriptor archetypeDescriptor,
+                                                       List archetypeResources, ZipFile archetypeZipFile,
+                                                       String moduleOffset, Context context, String packageName,
+                                                       File outputDirectoryFile )
+        throws OutputFileExists, ArchetypeGenerationFailure, FileNotFoundException, IOException
+    {
+        processTemplates( packageName, outputDirectoryFile, context, archetypeDescriptor, archetypeResources,
+                          archetypeZipFile, moduleOffset, true );
+    }
+
+    private void processFileSet( String directory, List fileSetResources, boolean packaged, String packageName,
+                                 Context context, File outputDirectoryFile, String moduleOffset,
+                                 String archetypeEncoding, boolean failIfExists )
+        throws OutputFileExists, ArchetypeGenerationFailure
     {
-        Iterator iterator = fileSetResources.iterator();
-
-        while ( iterator.hasNext() )
+        for ( Iterator iterator = fileSetResources.iterator(); iterator.hasNext(); )
         {
             String template = (String) iterator.next();
 
-            String templateName = StringUtils.replaceOnce( template, directory, "" );
-            File outputFile = getOutputFile( 
-                    template, directory, outputDirectoryFile, 
-                    packaged, packageName, moduleOffset, context);
-
-            processTemplate(outputFile,
-                context,
-                Constants.ARCHETYPE_RESOURCES + "/" + template,
-                archetypeEncoding,
-                failIfExists
-            );
+            File outputFile =
+                getOutputFile( template, directory, outputDirectoryFile, packaged, packageName, moduleOffset, context );
+
+            processTemplate( outputFile, context, Constants.ARCHETYPE_RESOURCES + "/" + template, archetypeEncoding,
+                             failIfExists );
         }
     }
 
-    private void processFilesetModule(
-        String rootArtifactId,
-        String artifactId,
-        final List archetypeResources,
-        File pom,
-        final ZipFile archetypeZipFile,
-        String moduleOffset,
-        File basedirPom,
-        File outputDirectoryFile,
-        final String packageName,
-        final AbstractArchetypeDescriptor archetypeDescriptor,
-        final Context context
-    )
-        throws
-        DocumentException,
-        XmlPullParserException,
-        ArchetypeGenerationFailure,
-        InvalidPackaging,
-        IOException,
+    private void processFilesetModule( String rootArtifactId, String artifactId, final List archetypeResources,
+                                       File pom, final ZipFile archetypeZipFile, String moduleOffset, File basedirPom,
+                                       File outputDirectoryFile, final String packageName,
+                                       final AbstractArchetypeDescriptor archetypeDescriptor, final Context context )
+        throws DocumentException, XmlPullParserException, ArchetypeGenerationFailure, InvalidPackaging, IOException,
         OutputFileExists
     {
         outputDirectoryFile.mkdirs();
@@ -634,148 +490,93 @@ public class DefaultFilesetArchetypeGene
         getLogger().debug( "Processing module moduleOffset " + moduleOffset );
         getLogger().debug( "Processing module outputDirectoryFile " + outputDirectoryFile );
 
-        processFilesetProject(
-            archetypeDescriptor,
-            StringUtils.replace( artifactId, "${rootArtifactId}", rootArtifactId ),
-            archetypeResources,
-            pom,
-            archetypeZipFile,
-            moduleOffset,
-            context,
-            packageName,
-            outputDirectoryFile,
-            basedirPom
-        );
+        processFilesetProject( archetypeDescriptor,
+                               StringUtils.replace( artifactId, "${rootArtifactId}", rootArtifactId ),
+                               archetypeResources, pom, archetypeZipFile, moduleOffset, context, packageName,
+                               outputDirectoryFile, basedirPom );
 
         String parentArtifactId = (String) context.get( Constants.PARENT_ARTIFACT_ID );
+
         Iterator subprojects = archetypeDescriptor.getModules().iterator();
+
         if ( subprojects.hasNext() )
         {
-            getLogger().debug(
-                artifactId + " has modules (" + archetypeDescriptor.getModules() + ")"
-            );
+            getLogger().debug( artifactId + " has modules (" + archetypeDescriptor.getModules() + ")" );
+
             setParentArtifactId( context, StringUtils.replace( artifactId, "${rootArtifactId}", rootArtifactId ) );
         }
+
         while ( subprojects.hasNext() )
         {
             ModuleDescriptor project = (ModuleDescriptor) subprojects.next();
 
             artifactId = project.getId();
 
-            File moduleOutputDirectoryFile = new File( outputDirectoryFile,
-                StringUtils.replace( project.getDir(), "__rootArtifactId__", rootArtifactId ) );
-            context.put( Constants.ARTIFACT_ID, StringUtils.replace( project.getId(), "${rootArtifactId}", rootArtifactId ) );
-            processFilesetModule(
-                rootArtifactId,
-                StringUtils.replace( project.getDir(), "__rootArtifactId__", rootArtifactId ),
-                archetypeResources,
-                new File( moduleOutputDirectoryFile, Constants.ARCHETYPE_POM ),
-                archetypeZipFile,
-                ( StringUtils.isEmpty( moduleOffset ) ? "" : ( moduleOffset + "/" ) ) + StringUtils.replace( project.getDir(), "${rootArtifactId}",
-                    rootArtifactId ),
-                pom,
-                moduleOutputDirectoryFile,
-                packageName,
-                project,
-                context
-            );
+            File moduleOutputDirectoryFile =
+                new File( outputDirectoryFile,
+                          StringUtils.replace( project.getDir(), "__rootArtifactId__", rootArtifactId ) );
+
+            context.put( Constants.ARTIFACT_ID,
+                         StringUtils.replace( project.getId(), "${rootArtifactId}", rootArtifactId ) );
+
+            processFilesetModule( rootArtifactId,
+                                  StringUtils.replace( project.getDir(), "__rootArtifactId__", rootArtifactId ),
+                                  archetypeResources,
+                                  new File( moduleOutputDirectoryFile, Constants.ARCHETYPE_POM ), archetypeZipFile,
+                                  ( StringUtils.isEmpty( moduleOffset ) ? "" : ( moduleOffset + "/" ) )
+                                      + StringUtils.replace( project.getDir(), "${rootArtifactId}", rootArtifactId ),
+                                  pom, moduleOutputDirectoryFile, packageName, project, context );
         }
+
         restoreParentArtifactId( context, parentArtifactId );
+
         getLogger().debug( "Processed " + artifactId );
     }
 
-    private void processFilesetProject(
-        final AbstractArchetypeDescriptor archetypeDescriptor,
-        final String moduleId,
-        final List archetypeResources,
-        final File pom,
-        final ZipFile archetypeZipFile,
-        String moduleOffset,
-        final Context context,
-        final String packageName,
-        final File outputDirectoryFile,
-        final File basedirPom
-    )
-        throws
-        DocumentException,
-        XmlPullParserException,
-        ArchetypeGenerationFailure,
-        InvalidPackaging,
-        IOException,
-        FileNotFoundException,
-        OutputFileExists
+    private void processFilesetProject( final AbstractArchetypeDescriptor archetypeDescriptor, final String moduleId,
+                                        final List archetypeResources, final File pom, final ZipFile archetypeZipFile,
+                                        String moduleOffset, final Context context, final String packageName,
+                                        final File outputDirectoryFile, final File basedirPom )
+        throws DocumentException, XmlPullParserException, ArchetypeGenerationFailure, InvalidPackaging, IOException,
+        FileNotFoundException, OutputFileExists
     {
         getLogger().debug( "Processing fileset project moduleId " + moduleId );
         getLogger().debug( "Processing fileset project pom " + pom );
         getLogger().debug( "Processing fileset project moduleOffset " + moduleOffset );
         getLogger().debug( "Processing fileset project outputDirectoryFile " + outputDirectoryFile );
         getLogger().debug( "Processing fileset project basedirPom " + basedirPom );
-        
+
         if ( basedirPom.exists() )
         {
-            processPomWithParent(
-                context,
-                pom,
-                moduleOffset,
-                basedirPom,
-                moduleId
-            );
+            processPomWithParent( context, pom, moduleOffset, basedirPom, moduleId );
         }
         else
         {
             processPom( context, pom, moduleOffset );
         }
 
-        processArchetypeTemplates(
-            archetypeDescriptor,
-            archetypeResources,
-            archetypeZipFile,
-            moduleOffset,
-            context,
-            packageName,
-            outputDirectoryFile
-        );
-    }
-
-    private void processPom( Context context,
-                             File pom,
-                             String moduleOffset )
-        throws
-        OutputFileExists,
-        ArchetypeGenerationFailure
+        processArchetypeTemplates( archetypeDescriptor, archetypeResources, archetypeZipFile, moduleOffset, context,
+                                   packageName, outputDirectoryFile );
+    }
+
+    private void processPom( Context context, File pom, String moduleOffset )
+        throws OutputFileExists, ArchetypeGenerationFailure
     {
         getLogger().debug( "Processing pom " + pom );
-        processTemplate(
-            pom,
-            context,
-            Constants.ARCHETYPE_RESOURCES + getOffsetSeparator( moduleOffset )
-                + Constants.ARCHETYPE_POM,
-            getEncoding( null ),
-            true
-        );
-    }
-
-    private void processPomWithMerge( Context context,
-                                      File pom,
-                                      String moduleOffset )
-        throws
-        OutputFileExists,
-        IOException,
-        XmlPullParserException,
-        ArchetypeGenerationFailure
+
+        processTemplate( pom, context, Constants.ARCHETYPE_RESOURCES + getOffsetSeparator( moduleOffset )
+            + Constants.ARCHETYPE_POM, getEncoding( null ), true );
+    }
+
+    private void processPomWithMerge( Context context, File pom, String moduleOffset )
+        throws OutputFileExists, IOException, XmlPullParserException, ArchetypeGenerationFailure
     {
         getLogger().debug( "Processing pom " + pom + " with merge" );
 
         File temporaryPom = getTemporaryFile( pom );
 
-        processTemplate(
-            temporaryPom,
-            context,
-            Constants.ARCHETYPE_RESOURCES + getOffsetSeparator( moduleOffset )
-                + Constants.ARCHETYPE_POM,
-            getEncoding( null ),
-            true
-        );
+        processTemplate( temporaryPom, context, Constants.ARCHETYPE_RESOURCES + getOffsetSeparator( moduleOffset )
+            + Constants.ARCHETYPE_POM, getEncoding( null ), true );
 
         pomManager.mergePoms( pom, temporaryPom );
 
@@ -791,67 +592,48 @@ public class DefaultFilesetArchetypeGene
         }
     }
 
-    private void processPomWithParent(
-        Context context,
-        File pom,
-        String moduleOffset,
-        File basedirPom,
-        String moduleId
-    )
-        throws
-        OutputFileExists,
-        XmlPullParserException,
-        DocumentException,
-        IOException,
-        InvalidPackaging,
+    private void processPomWithParent( Context context, File pom, String moduleOffset, File basedirPom, String moduleId )
+        throws OutputFileExists, XmlPullParserException, DocumentException, IOException, InvalidPackaging,
         ArchetypeGenerationFailure
     {
         getLogger().debug( "Processing pom " + pom + " with parent " + basedirPom );
-        processTemplate(
-            pom,
-            context,
-            Constants.ARCHETYPE_RESOURCES + getOffsetSeparator( moduleOffset )
-                + Constants.ARCHETYPE_POM,
-            getEncoding( null ),
-            true
-        );
+
+        processTemplate( pom, context, Constants.ARCHETYPE_RESOURCES + getOffsetSeparator( moduleOffset )
+            + Constants.ARCHETYPE_POM, getEncoding( null ), true );
 
         getLogger().debug( "Adding module " + moduleId );
+
         pomManager.addModule( basedirPom, moduleId );
+
         pomManager.addParent( pom, basedirPom );
     }
 
-    private void processTemplate(
-        File outFile,
-        Context context,
-        String templateFileName,
-        String encoding,
-        boolean failIfExists
-    )
-        throws
-        OutputFileExists,
-        ArchetypeGenerationFailure
+    private void processTemplate( File outFile, Context context, String templateFileName, String encoding,
+                                  boolean failIfExists )
+        throws OutputFileExists, ArchetypeGenerationFailure
     {
         templateFileName = templateFileName.replace( File.separatorChar, '/' );
-        
-        if ( !velocity.getEngine ().templateExists( templateFileName )
-            && velocity.getEngine ().templateExists(
-                templateFileName.replace ( '/', File.separatorChar )
-            )
-        )
+
+        String localTemplateFileName = templateFileName.replace( '/', File.separatorChar );
+        if ( !templateFileName.equals( localTemplateFileName )
+            && !velocity.getEngine().templateExists( templateFileName )
+            && velocity.getEngine().templateExists( localTemplateFileName ) )
         {
-            templateFileName = templateFileName.replace ( '/', File.separatorChar );
+            templateFileName = localTemplateFileName;
         }
-        
+
         getLogger().debug( "Prosessing template " + templateFileName );
 
-        if ( failIfExists && outFile.exists() )
+        if ( outFile.exists() )
         {
-            throw new OutputFileExists( "Don't rewrite file " + outFile.getAbsolutePath() );
-        }
-        else if ( outFile.exists() )
-        {
-            getLogger().warn( "PT Don't override file " + outFile );
+            if ( failIfExists )
+            {
+                throw new OutputFileExists( "Don't override file " + outFile.getAbsolutePath() );
+            }
+            else
+            {
+                getLogger().warn( "Don't override file " + outFile );
+            }
         }
         else
         {
@@ -874,94 +656,61 @@ public class DefaultFilesetArchetypeGene
             }
             catch ( Exception e )
             {
-                throw new ArchetypeGenerationFailure(
-                    "Error merging velocity templates: " + e.getMessage(),
-                    e
-                );
+                throw new ArchetypeGenerationFailure( "Error merging velocity templates: " + e.getMessage(), e );
             }
             finally
             {
                 IOUtil.close( writer );
-                writer = null;
             }
         }
     }
 
-    private void processTemplates(
-        String packageName,
-        File outputDirectoryFile,
-        Context context,
-        AbstractArchetypeDescriptor archetypeDescriptor,
-        List archetypeResources,
-        ZipFile archetypeZipFile,
-        String moduleOffset,
-        boolean failIfExists
-    )
-        throws
-        OutputFileExists,
-        ArchetypeGenerationFailure,
-        FileNotFoundException,
-        IOException
+    private void processTemplates( String packageName, File outputDirectoryFile, Context context,
+                                   AbstractArchetypeDescriptor archetypeDescriptor, List archetypeResources,
+                                   ZipFile archetypeZipFile, String moduleOffset, boolean failIfExists )
+        throws OutputFileExists, ArchetypeGenerationFailure, FileNotFoundException, IOException
     {
         Iterator iterator = archetypeDescriptor.getFileSets().iterator();
         if ( iterator.hasNext() )
         {
             getLogger().debug( "Processing filesets" );
         }
+
         while ( iterator.hasNext() )
         {
             FileSet fileSet = (FileSet) iterator.next();
 
-            List fileSetResources =
-                archetypeFilesResolver.filterFiles( moduleOffset, fileSet, archetypeResources );
-
-            //This creates an empty directory, even if there is no file to process
-            //Fix for ARCHETYPE-57
-            getOutputFile(
-                moduleOffset, fileSet.getDirectory(), outputDirectoryFile,
-                fileSet.isPackaged(), packageName, moduleOffset, context ).mkdirs();
+            List fileSetResources = archetypeFilesResolver.filterFiles( moduleOffset, fileSet, archetypeResources );
 
+            // This creates an empty directory, even if there is no file to process
+            // Fix for ARCHETYPE-57
+            getOutputFile( moduleOffset, fileSet.getDirectory(), outputDirectoryFile, fileSet.isPackaged(),
+                           packageName, moduleOffset, context ).mkdirs();
 
             if ( fileSet.isFiltered() )
             {
                 getLogger().debug(
-                    "Processing fileset " + fileSet + "\n\n\n\n" + fileSetResources + "\n\n"
-                        + archetypeResources + "\n\n"
-                );
-                processFileSet(
-                    fileSet.getDirectory(),
-                    fileSetResources,
-                    fileSet.isPackaged(),
-                    packageName,
-                    context,
-                    outputDirectoryFile,
-                    moduleOffset,
-                    getEncoding( fileSet.getEncoding() ),
-                    failIfExists
-                );
-                getLogger().debug( "Processed " + fileSetResources.size() + " files" );
+                                   "Processing fileset " + fileSet + "\n\n\n\n" + fileSetResources + "\n\n"
+                                       + archetypeResources + "\n\n" );
+
+                processFileSet( fileSet.getDirectory(), fileSetResources, fileSet.isPackaged(), packageName, context,
+                                outputDirectoryFile, moduleOffset, getEncoding( fileSet.getEncoding() ), failIfExists );
+
+                getLogger().debug( "Processed " + fileSetResources.size() + " files." );
             }
             else
             {
                 getLogger().debug( "Copying fileset " + fileSet );
-                copyFiles(
-                    fileSet.getDirectory(),
-                    fileSetResources,
-                    fileSet.isPackaged(),
-                    packageName,
-                    outputDirectoryFile,
-                    archetypeZipFile,
-                    moduleOffset,
-                    failIfExists,
-                    context
-                );
-                getLogger().debug( "Copied " + fileSetResources.size() + " files" );
+
+                copyFiles( fileSet.getDirectory(), fileSetResources, fileSet.isPackaged(), packageName,
+                           outputDirectoryFile, archetypeZipFile, moduleOffset, failIfExists, context );
+
+                getLogger().debug( "Copied " + fileSetResources.size() + " files." );
             }
         }
     }
 
-    private void restoreParentArtifactId( Context context,
-                                          String parentArtifactId )
+    private void restoreParentArtifactId( Context context, String parentArtifactId )
     {
         if ( StringUtils.isEmpty( parentArtifactId ) )
         {
@@ -975,9 +724,10 @@ public class DefaultFilesetArchetypeGene
 
     private File getTemporaryFile( File file )
     {
-        File tmp =
-            FileUtils.createTempFile( file.getName(), Constants.TMP, file.getParentFile() );
+        File tmp = FileUtils.createTempFile( file.getName(), Constants.TMP, file.getParentFile() );
+
         tmp.deleteOnExit();
+
         return tmp;
     }
 }

Modified: maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/generator/FilesetArchetypeGenerator.java
URL: http://svn.apache.org/viewvc/maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/generator/FilesetArchetypeGenerator.java?rev=925751&r1=925750&r2=925751&view=diff
==============================================================================
--- maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/generator/FilesetArchetypeGenerator.java (original)
+++ maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/generator/FilesetArchetypeGenerator.java Sun Mar 21 10:46:13 2010
@@ -34,15 +34,8 @@ public interface FilesetArchetypeGenerat
 {
     String ROLE = FilesetArchetypeGenerator.class.getName();
 
-    void generateArchetype( ArchetypeGenerationRequest request,
-                            File archetypeFile,
-                            String basedir )
-        throws
-        UnknownArchetype,
-        ArchetypeNotConfigured,
-        ProjectDirectoryExists,
-        PomFileExists,
-        OutputFileExists,
+    void generateArchetype( ArchetypeGenerationRequest request, File archetypeFile, String basedir )
+        throws UnknownArchetype, ArchetypeNotConfigured, ProjectDirectoryExists, PomFileExists, OutputFileExists,
         ArchetypeGenerationFailure;
 
 //    Compile time deprecation ;-)