maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jvan...@apache.org
Subject svn commit: r582578 - in /maven/sandbox/trunk/archetypeng: ./ archetypeng-common/src/main/java/org/apache/maven/archetype/ archetypeng-common/src/main/java/org/apache/maven/archetype/common/ archetypeng-common/src/main/java/org/apache/maven/archetype/c...
Date Sun, 07 Oct 2007 05:24:46 GMT
Author: jvanzyl
Date: Sat Oct  6 22:24:45 2007
New Revision: 582578

URL: http://svn.apache.org/viewvc?rev=582578&view=rev
Log:
o refactoring of the creator to use request/response, another step in the round trip test
works
o pushed many default values to the archetype creation request to make things work in a fully
embedded mode

Modified:
    maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/ArchetypeCreationRequest.java
    maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/common/DefaultPomManager.java
    maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/common/PomManager.java
    maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/creator/ArchetypeCreator.java
    maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/creator/FilesetArchetypeCreator.java
    maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/generator/DefaultFilesetArchetypeGenerator.java
    maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/java/org/apache/maven/archetype/creator/DefaultArchetypeCreatorTest.java
    maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/java/org/apache/maven/archetype/test/ArchetyperRoundtripTest.java
    maven/sandbox/trunk/archetypeng/pom.xml

Modified: maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/ArchetypeCreationRequest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/ArchetypeCreationRequest.java?rev=582578&r1=582577&r2=582578&view=diff
==============================================================================
--- maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/ArchetypeCreationRequest.java
(original)
+++ maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/ArchetypeCreationRequest.java
Sat Oct  6 22:24:45 2007
@@ -4,7 +4,9 @@
 import org.apache.maven.project.MavenProject;
 
 import java.io.File;
+import java.util.ArrayList;
 import java.util.List;
+import java.util.Properties;
 
 /** @author Jason van Zyl */
 public class ArchetypeCreationRequest
@@ -17,9 +19,9 @@
 
     private File propertyFile;
 
-    private List languages;
+    private List languages = new ArrayList();
 
-    private List filtereds;
+    private List filtereds = new ArrayList();
 
     private String defaultEncoding = "UTF-8";
 
@@ -33,6 +35,10 @@
 
     private File archetypeRegistryFile;
 
+    private String packageName;
+
+    private Properties properties;
+
     public ArtifactRepository getLocalRepository()
     {
         return localRepository;
@@ -173,6 +179,30 @@
     public ArchetypeCreationRequest setArchetypeRegistryFile( File archetypeRegistryFile
)
     {
         this.archetypeRegistryFile = archetypeRegistryFile;
+
+        return this;
+    }
+
+    public Properties getProperties()
+    {
+        return properties;
+    }
+
+    public ArchetypeCreationRequest setProperties( Properties properties )
+    {
+        this.properties = properties;
+
+        return this;
+    }
+
+    public String getPackageName()
+    {
+        return packageName;
+    }
+
+    public ArchetypeCreationRequest setPackageName( String packageName )
+    {
+        this.packageName = packageName;
 
         return this;
     }

Modified: maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/common/DefaultPomManager.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/common/DefaultPomManager.java?rev=582578&r1=582577&r2=582578&view=diff
==============================================================================
--- maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/common/DefaultPomManager.java
(original)
+++ maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/common/DefaultPomManager.java
Sat Oct  6 22:24:45 2007
@@ -70,7 +70,6 @@
     public void addModule( File pom,
                            String artifactId )
         throws
-        FileNotFoundException,
         IOException,
         XmlPullParserException,
         DocumentException,
@@ -158,7 +157,6 @@
     public void addParent( File pom,
                            File parentPom )
         throws
-        FileNotFoundException,
         IOException,
         XmlPullParserException
     {
@@ -186,7 +184,6 @@
     public void mergePoms( File pom,
                            File temporaryPom )
         throws
-        FileNotFoundException,
         IOException,
         XmlPullParserException
     {
@@ -262,7 +259,6 @@
 
     public Model readPom( final File pomFile )
         throws
-        FileNotFoundException,
         IOException,
         XmlPullParserException
     { // TODO ensure correct encoding by using default one from method argument !!!

Modified: maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/common/PomManager.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/common/PomManager.java?rev=582578&r1=582577&r2=582578&view=diff
==============================================================================
--- maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/common/PomManager.java
(original)
+++ maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/common/PomManager.java
Sat Oct  6 22:24:45 2007
@@ -35,7 +35,6 @@
     void addModule( File basedirPom,
                     String artifactId )
         throws
-        FileNotFoundException,
         IOException,
         XmlPullParserException,
         DocumentException,
@@ -44,20 +43,17 @@
     void addParent( File pom,
                     File basedirPom )
         throws
-        FileNotFoundException,
         IOException,
         XmlPullParserException;
 
     void mergePoms( File pom,
                     File temporaryPom )
         throws
-        FileNotFoundException,
         IOException,
         XmlPullParserException;
 
     Model readPom( File pomFile )
         throws
-        FileNotFoundException,
         IOException,
         XmlPullParserException;
 

Modified: maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/creator/ArchetypeCreator.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/creator/ArchetypeCreator.java?rev=582578&r1=582577&r2=582578&view=diff
==============================================================================
--- maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/creator/ArchetypeCreator.java
(original)
+++ maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/creator/ArchetypeCreator.java
Sat Oct  6 22:24:45 2007
@@ -38,18 +38,4 @@
 
     void createArchetype( ArchetypeCreationRequest request,
                           ArchetypeCreationResult result );
-
-    void createArchetype( MavenProject project,
-                          File propertyFile,
-                          List languages,
-                          List filtereds,
-                          String defaultEncoding,
-                          boolean ignoreReplica,
-                          boolean preserveCData,
-                          boolean keepParent,
-                          boolean partialArchetype,
-                          File archetypeRegistryFile,
-                          ArtifactRepository localRepository
-    )
-        throws IOException, ArchetypeNotDefined, ArchetypeNotConfigured, TemplateCreationException,
XmlPullParserException;
 }

Modified: maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/creator/FilesetArchetypeCreator.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/creator/FilesetArchetypeCreator.java?rev=582578&r1=582577&r2=582578&view=diff
==============================================================================
--- maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/creator/FilesetArchetypeCreator.java
(original)
+++ maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/creator/FilesetArchetypeCreator.java
Sat Oct  6 22:24:45 2007
@@ -103,78 +103,78 @@
     public void createArchetype( ArchetypeCreationRequest request,
                                  ArchetypeCreationResult result )
     {
-        try
-        {
-            createArchetype( request.getProject(),
-                request.getPropertyFile(),
-                request.getLanguages(),
-                request.getFiltereds(),
-                request.getDefaultEncoding(),
-                request.isIgnoreReplica(),
-                request.isPreserveCData(),
-                request.isKeepParent(),
-                request.isPartialArchetype(),
-                request.getArchetypeRegistryFile(),
-                request.getLocalRepository() );
-        }
-        catch ( IOException e )
-        {
-            result.setCause( e );
-        }
-        catch ( ArchetypeNotDefined e )
-        {
-            result.setCause( e );
-        }
-        catch ( ArchetypeNotConfigured e )
-        {
-            result.setCause( e );
-        }
-        catch ( TemplateCreationException e )
-        {
-            result.setCause( e );
-        }
-        catch ( XmlPullParserException e )
+        MavenProject project = request.getProject();
+
+        File propertyFile = request.getPropertyFile();
+
+        List languages = request.getLanguages();
+
+        List filtereds = request.getFiltereds();
+
+        String defaultEncoding = request.getDefaultEncoding();
+
+        boolean ignoreReplica = request.isIgnoreReplica();
+
+        boolean preserveCData = request.isPreserveCData();
+
+        boolean keepParent = request.isKeepParent();
+
+        boolean partialArchetype = request.isPartialArchetype();
+
+        ArtifactRepository localRepository = request.getLocalRepository();
+
+        ArchetypeDefinition ad = new ArchetypeDefinition();
+
+        ad.setGroupId( project.getGroupId() );
+
+        ad.setArtifactId( project.getArtifactId() );
+
+        ad.setVersion( project.getVersion() );
+
+        if ( !ad.isDefined() )
         {
-            result.setCause( e );
+            result.setCause( new ArchetypeNotDefined( "The archetype is not defined" ) );
+
+            return;
         }
-    }
 
-    public void createArchetype(
-        MavenProject project,
-        File propertyFile,
-        List languages,
-        List filtereds,
-        String defaultEncoding,
-        boolean ignoreReplica,
-        boolean preserveCData,
-        boolean keepParent,
-        boolean partialArchetype,
-        File archetypeRegistryFile,
-        ArtifactRepository localRepository
-    )
-        throws
-        IOException,
-        ArchetypeNotDefined,
-        ArchetypeNotConfigured,
-        TemplateCreationException,
-        XmlPullParserException
-    {
-        Properties properties = initialiseArchetypeProperties( propertyFile );
+        ArchetypeConfiguration ac = new ArchetypeConfiguration();
 
-        ArchetypeDefinition archetypeDefinition =
-            archetypeFactory.createArchetypeDefinition( properties );
+        ac.setGroupId( ad.getGroupId() );
 
-        if ( !archetypeDefinition.isDefined() )
+        ac.setArtifactId( ad.getArtifactId() );
+
+        ac.setVersion( ad.getVersion() );
+
+        ac.setGoals( ad.getGoals() );                
+
+        if ( !ac.isConfigured() )
         {
-            throw new ArchetypeNotDefined( "The archetype is not defined" );
+            result.setCause( new ArchetypeNotConfigured( "The archetype is not configured"
) );
+
+            return;
         }
 
-        ArchetypeConfiguration archetypeConfiguration =
-            archetypeFactory.createArchetypeConfiguration( archetypeDefinition, properties
);
+        Properties properties = new Properties();
 
-        if ( !archetypeConfiguration.isConfigured() )
+        properties.setProperty( Constants.GROUP_ID, ad.getGroupId() );
+        ac.setProperty( Constants.GROUP_ID, ad.getGroupId() );
+
+        properties.setProperty( Constants.ARTIFACT_ID, ad.getArtifactId() );
+        ac.setProperty( Constants.ARTIFACT_ID, ad.getArtifactId() );
+
+        properties.setProperty( Constants.VERSION, ad.getVersion() );
+        ac.setProperty( Constants.VERSION, ad.getVersion() );
+
+        if ( request.getPackageName() != null )
         {
-            throw new ArchetypeNotConfigured( "The archetype is not configured" );
+            properties.setProperty( Constants.PACKAGE, request.getPackageName() );
+            ac.setProperty( Constants.PACKAGE, request.getPackageName() );
+        }
+        else
+        {
+            properties.setProperty( Constants.PACKAGE, ad.getGroupId() );
+            ac.setProperty( Constants.PACKAGE, ad.getGroupId() );
         }
 
         File basedir = project.getBasedir();
@@ -185,11 +185,11 @@
 
         Model model = new Model();
         model.setModelVersion( "4.0.0" );
-        model.setGroupId( archetypeDefinition.getGroupId() );
-        model.setArtifactId( archetypeDefinition.getArtifactId() );
-        model.setVersion( archetypeDefinition.getVersion() );
+        model.setGroupId( ad.getGroupId() );
+        model.setArtifactId( ad.getArtifactId() );
+        model.setVersion( ad.getVersion() );
         model.setPackaging( "maven-archetype" );
-        model.setName( archetypeDefinition.getArtifactId() );
+        model.setName( ad.getArtifactId() );
 
         Build build = new Build();
         model.setBuild( build );
@@ -227,8 +227,10 @@
             }
             catch ( ProjectBuildingException e )
             {
-                throw new TemplateCreationException(
-                    "Error reading parent POM of project: " + pa.getGroupId() + ":" + pa.getArtifactId()
+ ":" + pa.getVersion() );
+                result.setCause( new TemplateCreationException(
+                    "Error reading parent POM of project: " + pa.getGroupId() + ":" + pa.getArtifactId()
+ ":" + pa.getVersion() ) );
+
+                return;
             }
         }
 
@@ -247,44 +249,57 @@
         getLogger().debug( "Creating archetype's pom" );
 
         File archetypePomFile = FileUtils.resolveFile( basedir, getArchetypePom() );
+
         archetypePomFile.getParentFile().mkdirs();
-        pomManager.writePom( model, archetypePomFile, archetypePomFile );
 
-        File archetypeResourcesDirectory =
-            FileUtils.resolveFile( generatedSourcesDirectory, getTemplateOutputDirectory()
);
+        try
+        {
+            pomManager.writePom( model, archetypePomFile, archetypePomFile );
+        }
+        catch ( IOException e )
+        {
+            result.setCause( e );
+        }
+
+        File archetypeResourcesDirectory = FileUtils.resolveFile( generatedSourcesDirectory,
getTemplateOutputDirectory() );
+
         archetypeResourcesDirectory.mkdirs();
 
-        File archetypeFilesDirectory =
-            FileUtils.resolveFile( archetypeResourcesDirectory, Constants.ARCHETYPE_RESOURCES
);
+        File archetypeFilesDirectory = FileUtils.resolveFile( archetypeResourcesDirectory,
Constants.ARCHETYPE_RESOURCES );
+
         archetypeFilesDirectory.mkdirs();
+
         getLogger().debug( "Archetype's files output directory " + archetypeFilesDirectory
);
 
         File replicaMainDirectory =
             FileUtils.resolveFile(
                 generatedSourcesDirectory,
                 getReplicaOutputDirectory() + File.separator
-                    + archetypeDefinition.getArtifactId()
+                    + ad.getArtifactId()
             );
+
         if ( !ignoreReplica )
         {
             replicaMainDirectory.mkdirs();
         }
 
         File replicaFilesDirectory = FileUtils.resolveFile( replicaMainDirectory, "reference"
);
+
         if ( !ignoreReplica )
         {
             replicaFilesDirectory.mkdirs();
         }
 
-        File archetypeDescriptorFile =
-            FileUtils.resolveFile( archetypeResourcesDirectory, Constants.ARCHETYPE_DESCRIPTOR
);
+        File archetypeDescriptorFile = FileUtils.resolveFile( archetypeResourcesDirectory,
Constants.ARCHETYPE_DESCRIPTOR );
+
         archetypeDescriptorFile.getParentFile().mkdirs();
 
         ArchetypeDescriptor archetypeDescriptor = new ArchetypeDescriptor();
-        archetypeDescriptor.setName( archetypeDefinition.getArtifactId() );
-        getLogger().debug(
-            "Starting archetype's descriptor " + archetypeDefinition.getArtifactId()
-        );
+
+        archetypeDescriptor.setName( ad.getArtifactId() );
+
+        getLogger().debug( "Starting archetype's descriptor " + ad.getArtifactId() );
+
         archetypeDescriptor.setPartial( partialArchetype );
 
         addRequiredProperties( archetypeDescriptor, properties );
@@ -294,118 +309,119 @@
         reverseProperties.remove( Constants.GROUP_ID );
 
         // TODO ensure pomReversedProperties contains NO dotted properties
-        Properties pomReversedProperties =
-            getRequiredProperties( archetypeDescriptor, properties );
+        Properties pomReversedProperties = getRequiredProperties( archetypeDescriptor, properties
);
+
         pomReversedProperties.remove( Constants.PACKAGE );
 
-        String packageName = archetypeConfiguration.getProperty( Constants.PACKAGE );
+        String packageName = ac.getProperty( Constants.PACKAGE );
 
-        Model pom =
-            pomManager.readPom( FileUtils.resolveFile( basedir, Constants.ARCHETYPE_POM )
);
+        try
+        {
+            Model pom = pomManager.readPom( FileUtils.resolveFile( basedir, Constants.ARCHETYPE_POM
) );
 
-        registerProject( pom );
+            registerProject( pom );
 
-        List fileNames = resolveFileNames( pom, basedir );
-        getLogger().debug( "Scanned for files " + fileNames.size() );
+            List fileNames = resolveFileNames( pom, basedir );
 
-        Iterator names = fileNames.iterator();
-        while ( names.hasNext() )
-        {
-            getLogger().debug( "- " + names.next().toString() );
-        }
+            getLogger().debug( "Scanned for files " + fileNames.size() );
 
-        List filesets =
-            resolveFileSets( packageName, fileNames, languages, filtereds, defaultEncoding
);
-        getLogger().debug( "Resolved filesets for " + archetypeDescriptor.getName() );
+            Iterator names = fileNames.iterator();
 
-        archetypeDescriptor.setFileSets( filesets );
+            while ( names.hasNext() )
+            {
+                getLogger().debug( "- " + names.next().toString() );
+            }
 
-        createArchetypeFiles(
-            reverseProperties,
-            filesets,
-            packageName,
-            basedir,
-            archetypeFilesDirectory,
-            defaultEncoding
-        );
-        getLogger().debug( "Created files for " + archetypeDescriptor.getName() );
+            List filesets = resolveFileSets( packageName, fileNames, languages, filtereds,
defaultEncoding );
 
-        if ( !ignoreReplica )
-        {
-            createReplicaFiles( filesets, basedir, replicaFilesDirectory );
-            getLogger().debug( "Created replica files for " + archetypeDescriptor.getName()
);
+            getLogger().debug( "Resolved filesets for " + archetypeDescriptor.getName() );
+
+            archetypeDescriptor.setFileSets( filesets );
+
+            createArchetypeFiles( reverseProperties, filesets, packageName, basedir, archetypeFilesDirectory,
defaultEncoding );
 
-            FileUtils.copyFile(
-                propertyFile,
-                new File( replicaMainDirectory, "archetype.properties" )
+            getLogger().debug( "Created files for " + archetypeDescriptor.getName() );
+
+            if ( !ignoreReplica )
+            {
+                createReplicaFiles( filesets, basedir, replicaFilesDirectory );
+
+                getLogger().debug( "Created replica files for " + archetypeDescriptor.getName()
);
+
+                FileUtils.copyFile( propertyFile, new File( replicaMainDirectory, "archetype.properties"
) );
+
+                new File( replicaMainDirectory, "goal.txt" ).createNewFile();
+            }
+
+            setParentArtifactId(
+                reverseProperties,
+                ac.getProperty( Constants.ARTIFACT_ID )
             );
-            new File( replicaMainDirectory, "goal.txt" ).createNewFile();
-        }
 
-        setParentArtifactId(
-            reverseProperties,
-            archetypeConfiguration.getProperty( Constants.ARTIFACT_ID )
-        );
+            Iterator modules = pom.getModules().iterator();
+            while ( modules.hasNext() )
+            {
+                String moduleId = (String) modules.next();
 
-        Iterator modules = pom.getModules().iterator();
-        while ( modules.hasNext() )
-        {
-            String moduleId = (String) modules.next();
+                getLogger().debug( "Creating module " + moduleId );
 
-            getLogger().debug( "Creating module " + moduleId );
+                ModuleDescriptor moduleDescriptor =
+                    createModule(
+                        reverseProperties,
+                        ac.getProperty( Constants.ARTIFACT_ID ),
+                        moduleId,
+                        packageName,
+                        FileUtils.resolveFile( basedir, moduleId ),
+                        FileUtils.resolveFile( archetypeFilesDirectory, moduleId ),
+                        FileUtils.resolveFile( replicaFilesDirectory, moduleId ),
+                        languages,
+                        filtereds,
+                        defaultEncoding,
+                        ignoreReplica,
+                        preserveCData,
+                        keepParent
+                    );
 
-            ModuleDescriptor moduleDescriptor =
-                createModule(
-                    reverseProperties,
-                    archetypeConfiguration.getProperty( Constants.ARTIFACT_ID ),
-                    moduleId,
-                    packageName,
-                    FileUtils.resolveFile( basedir, moduleId ),
-                    FileUtils.resolveFile( archetypeFilesDirectory, moduleId ),
-                    FileUtils.resolveFile( replicaFilesDirectory, moduleId ),
-                    languages,
-                    filtereds,
-                    defaultEncoding,
-                    ignoreReplica,
-                    preserveCData,
-                    keepParent
+                archetypeDescriptor.addModule( moduleDescriptor );
+                getLogger().debug(
+                    "Added module " + moduleDescriptor.getName() + " in "
+                        + archetypeDescriptor.getName()
                 );
+            }
+            restoreParentArtifactId( reverseProperties, null );
+            restoreArtifactId(
+                reverseProperties,
+                ac.getProperty( Constants.ARTIFACT_ID )
+            );
 
-            archetypeDescriptor.addModule( moduleDescriptor );
+            createPoms( pom, ac.getProperty( Constants.ARTIFACT_ID ),
+                ac.getProperty( Constants.ARTIFACT_ID ),
+                archetypeFilesDirectory, basedir,
+                pomReversedProperties, preserveCData, keepParent );
+
+            getLogger().debug( "Created Archetype " + archetypeDescriptor.getName() + " pom"
);
+
+            ArchetypeDescriptorXpp3Writer writer = new ArchetypeDescriptorXpp3Writer();
+            writer.write( new FileWriter( archetypeDescriptorFile ), archetypeDescriptor
);
+            getLogger().debug( "Archetype " + archetypeDescriptor.getName() + " descriptor
written" );
+
+            OldArchetypeDescriptor oldDescriptor =
+                convertToOldDescriptor( archetypeDescriptor.getName(), packageName, basedir
);
+            File oldDescriptorFile =
+                FileUtils.resolveFile(
+                    archetypeResourcesDirectory,
+                    Constants.OLD_ARCHETYPE_DESCRIPTOR
+                );
+            archetypeDescriptorFile.getParentFile().mkdirs();
+            writeOldDescriptor( oldDescriptor, oldDescriptorFile );
             getLogger().debug(
-                "Added module " + moduleDescriptor.getName() + " in "
-                    + archetypeDescriptor.getName()
+                "Archetype " + archetypeDescriptor.getName() + " old descriptor written"
             );
         }
-        restoreParentArtifactId( reverseProperties, null );
-        restoreArtifactId(
-            reverseProperties,
-            archetypeConfiguration.getProperty( Constants.ARTIFACT_ID )
-        );
-
-        createPoms( pom, archetypeConfiguration.getProperty( Constants.ARTIFACT_ID ),
-            archetypeConfiguration.getProperty( Constants.ARTIFACT_ID ),
-            archetypeFilesDirectory, basedir,
-            pomReversedProperties, preserveCData, keepParent );
-
-        getLogger().debug( "Created Archetype " + archetypeDescriptor.getName() + " pom"
);
-
-        ArchetypeDescriptorXpp3Writer writer = new ArchetypeDescriptorXpp3Writer();
-        writer.write( new FileWriter( archetypeDescriptorFile ), archetypeDescriptor );
-        getLogger().debug( "Archetype " + archetypeDescriptor.getName() + " descriptor written"
);
-
-        OldArchetypeDescriptor oldDescriptor =
-            convertToOldDescriptor( archetypeDescriptor.getName(), packageName, basedir );
-        File oldDescriptorFile =
-            FileUtils.resolveFile(
-                archetypeResourcesDirectory,
-                Constants.OLD_ARCHETYPE_DESCRIPTOR
-            );
-        archetypeDescriptorFile.getParentFile().mkdirs();
-        writeOldDescriptor( oldDescriptor, oldDescriptorFile );
-        getLogger().debug(
-            "Archetype " + archetypeDescriptor.getName() + " old descriptor written"
-        );
+        catch ( Exception e )
+        {
+            result.setCause( e );
+        }
     }
 
     private void addRequiredProperties(
@@ -1508,7 +1524,7 @@
         {
             archetypePropertiesManager.readProperties( properties, propertyFile );
         }
-        
+
         return properties;
     }
 
@@ -1761,7 +1777,9 @@
         List files = new ArrayList( fileNames );
 
         String languageIncludes = "";
+
         Iterator languagesIterator = languages.iterator();
+
         while ( languagesIterator.hasNext() )
         {
             String language = (String) languagesIterator.next();

Modified: maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/generator/DefaultFilesetArchetypeGenerator.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/generator/DefaultFilesetArchetypeGenerator.java?rev=582578&r1=582577&r2=582578&view=diff
==============================================================================
--- maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/generator/DefaultFilesetArchetypeGenerator.java
(original)
+++ maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/generator/DefaultFilesetArchetypeGenerator.java
Sat Oct  6 22:24:45 2007
@@ -637,7 +637,6 @@
     )
         throws
         OutputFileExists,
-        FileNotFoundException,
         XmlPullParserException,
         DocumentException,
         IOException,

Modified: maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/java/org/apache/maven/archetype/creator/DefaultArchetypeCreatorTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/java/org/apache/maven/archetype/creator/DefaultArchetypeCreatorTest.java?rev=582578&r1=582577&r2=582578&view=diff
==============================================================================
--- maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/java/org/apache/maven/archetype/creator/DefaultArchetypeCreatorTest.java
(original)
+++ maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/java/org/apache/maven/archetype/creator/DefaultArchetypeCreatorTest.java
Sat Oct  6 22:24:45 2007
@@ -19,6 +19,9 @@
 
 package org.apache.maven.archetype.creator;
 
+import org.apache.maven.archetype.ArchetypeCreationRequest;
+import org.apache.maven.archetype.ArchetypeCreationResult;
+import org.apache.maven.archetype.common.Constants;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.artifact.repository.DefaultArtifactRepository;
 import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
@@ -27,6 +30,7 @@
 import org.apache.maven.project.MavenProjectBuilder;
 import org.codehaus.plexus.util.FileUtils;
 import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.PropertyUtils;
 import org.codehaus.plexus.util.StringUtils;
 
 import java.io.File;
@@ -37,6 +41,7 @@
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
+import java.util.Properties;
 
 public class DefaultArchetypeCreatorTest
     extends AbstractMojoTestCase
@@ -59,19 +64,24 @@
         String project = "create-3";
 
         File projectFile = getProjectFile( project );
+
         File projectFileSample = getProjectSampleFile( project );
+
         copy( projectFileSample, projectFile );
 
         FileUtils.deleteDirectory( new File( projectFile.getParentFile(), "target" ) );
 
         File propertyFile = getPropertiesFile( project );
+
         File propertyFileSample = getPropertiesSampleFile( project );
+
         copy( propertyFileSample, propertyFile );
 
-        MavenProject mavenProject =
-            builder.buildWithDependencies( projectFile, localRepository, null );
-        FilesetArchetypeCreator instance =
-            (FilesetArchetypeCreator) lookup( ArchetypeCreator.class.getName(), "fileset"
);
+        Properties p = PropertyUtils.loadProperties( propertyFile );
+
+        MavenProject mavenProject = builder.buildWithDependencies( projectFile, localRepository,
null );
+
+        FilesetArchetypeCreator instance = (FilesetArchetypeCreator) lookup( ArchetypeCreator.class.getName(),
"fileset" );
 
         languages = new ArrayList();
         languages.add( "java" );
@@ -97,20 +107,23 @@
         filtereds.add( "properties" );
         filtereds.add( ".classpath" );
         filtereds.add( ".project" );
-        instance.createArchetype(
-            mavenProject,
-            propertyFile,
-            languages,
-            filtereds,
-            "UTF-8",
-            true,
-            false,
-            false,
-            false,
-            getFile( project, "archetype-registry.xml" ),
-            null
-        );
-        
+
+        ArchetypeCreationRequest request = new ArchetypeCreationRequest()
+            .setProject( mavenProject )
+            .setPackageName( p.getProperty( Constants.PACKAGE ) )
+            .setPropertyFile( propertyFile )
+            .setLanguages( languages )
+            .setFiltereds( filtereds )
+            .setDefaultEncoding( "UTF-8" )
+            .setIgnoreReplica( true )
+            .setPartialArchetype( false )
+            .setPreserveCData( false )
+            .setKeepParent( false );
+
+        ArchetypeCreationResult result = new ArchetypeCreationResult();
+
+        instance.createArchetype( request, result );
+
         File template;
 
         template = getTemplateFile( project, "pom.xml" );
@@ -211,11 +224,7 @@
         assertExists( template );
         assertNotContent( template, "${someProperty}" );
 
-        template =
-            getTemplateFile(
-                project,
-                "application/src/main/java/test/application/images/Application.png"
-            );
+        template = getTemplateFile( project, "application/src/main/java/test/application/images/Application.png"
);
         assertExists( template );
         assertNotContent( template, "${someProperty}" );
 
@@ -223,13 +232,11 @@
         assertExists( template );
         assertContent( template, "${someProperty}" );
 
-        template =
-            getTemplateFile( project, "application/src/main/resources/META-INF/MANIFEST.MF"
);
+        template = getTemplateFile( project, "application/src/main/resources/META-INF/MANIFEST.MF"
);
         assertExists( template );
         assertContent( template, "${someProperty}" );
 
-        template =
-            getTemplateFile( project, "application/src/main/resources/test/application/some/Gro.groovy"
);
+        template = getTemplateFile( project, "application/src/main/resources/test/application/some/Gro.groovy"
);
         assertExists( template );
         assertContent( template, "${someProperty}" );
 

Modified: maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/java/org/apache/maven/archetype/test/ArchetyperRoundtripTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/java/org/apache/maven/archetype/test/ArchetyperRoundtripTest.java?rev=582578&r1=582577&r2=582578&view=diff
==============================================================================
--- maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/java/org/apache/maven/archetype/test/ArchetyperRoundtripTest.java
(original)
+++ maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/java/org/apache/maven/archetype/test/ArchetyperRoundtripTest.java
Sat Oct  6 22:24:45 2007
@@ -1,10 +1,14 @@
 package org.apache.maven.archetype.test;
 
+import org.apache.maven.archetype.ArchetypeCreationRequest;
+import org.apache.maven.archetype.ArchetypeCreationResult;
 import org.apache.maven.archetype.Archetyper;
 import org.apache.maven.archetype.common.ArchetypeRegistryManager;
 import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.project.MavenProject;
 import org.apache.maven.project.MavenProjectBuilder;
 import org.codehaus.plexus.PlexusTestCase;
+import org.codehaus.plexus.util.FileUtils;
 
 import java.io.File;
 
@@ -35,8 +39,6 @@
         //
         // ------------------------------------------------------------------------
 
-        /*
-
         // (1) create a project from scratch
 
         File sourceProject = new File( getBasedir(), "src/test/projects/test-project" );
@@ -54,9 +56,6 @@
 
         File pom = new File( workingProject, "pom.xml" );
 
-        ArtifactRepository localRepository = registryManager.createRepository(
-            new File( getBasedir(), "target/local-repo" ).toURI().toURL().toExternalForm(),
"local-repo" );
-
         MavenProject project = projectBuilder.build( pom, localRepository, null );
 
         ArchetypeCreationRequest acr = new ArchetypeCreationRequest()
@@ -68,11 +67,7 @@
         if ( result.getCause() != null )
         {
             fail( result.getCause().getMessage() );
-
-            result.getCause().printStackTrace();
         }
-
-        */
 
         // (3) create our own archetype catalog properties in memory
         // (4) create our own archetype catalog describing the archetype we just created

Modified: maven/sandbox/trunk/archetypeng/pom.xml
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/archetypeng/pom.xml?rev=582578&r1=582577&r2=582578&view=diff
==============================================================================
--- maven/sandbox/trunk/archetypeng/pom.xml (original)
+++ maven/sandbox/trunk/archetypeng/pom.xml Sat Oct  6 22:24:45 2007
@@ -298,32 +298,10 @@
     <plugins>
       <plugin>
         <artifactId>maven-compiler-plugin</artifactId>
-        <!--
-            You will need to install the runtime jar to compile
-            mvn install:install-file
-                -DgroupId=com.sun -DartifactId=rt -Dversion=1.4.2
-                -Dpackaging=jar -Dfile=/usr/local/j2sdk1.4.2_12/jre/lib/rt.jar
-        -->
         <configuration>
           <source>1.4</source>
           <target>1.4</target>
-          <!--
-              <compilerArguments>
-                  <bootclasspath>
-                      ${settings.localRepository}/com/sun/rt/1.4.2/rt-1.4.2.jar
-                  </bootclasspath>
-              </compilerArguments>
-          -->
         </configuration>
-        <!--
-        <dependencies>
-            <dependency>
-                <groupId>com.sun</groupId>
-                <artifactId>rt</artifactId>
-                <version>1.4.2</version>
-            </dependency>
-        </dependencies>
-        -->
       </plugin>
       <plugin>
         <groupId>org.codehaus.plexus</groupId>



Mime
View raw message