maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From raf...@apache.org
Subject svn commit: r584247 [1/2] - in /maven/sandbox/trunk/archetypeng: ./ archetype-old/ archetype-old/src/ archetype-old/src/main/ archetype-old/src/main/java/ archetype-old/src/main/java/org/ archetype-old/src/main/java/org/apache/ archetype-old/src/main/j...
Date Fri, 12 Oct 2007 19:52:32 GMT
Author: rafale
Date: Fri Oct 12 12:52:09 2007
New Revision: 584247

URL: http://svn.apache.org/viewvc?rev=584247&view=rev
Log:
Added old stuff code internally

Added:
    maven/sandbox/trunk/archetypeng/archetype-old/
    maven/sandbox/trunk/archetypeng/archetype-old/pom.xml   (with props)
    maven/sandbox/trunk/archetypeng/archetype-old/src/
    maven/sandbox/trunk/archetypeng/archetype-old/src/main/
    maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/
    maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/
    maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/
    maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/
    maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/archetype/
    maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/archetype/old/
    maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/archetype/old/Archetype.java   (with props)
    maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/archetype/old/ArchetypeDescriptorException.java   (with props)
    maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/archetype/old/ArchetypeNotFoundException.java   (with props)
    maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/archetype/old/ArchetypeTemplateProcessingException.java   (with props)
    maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/archetype/old/DefaultArchetype.java   (with props)
    maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/archetype/old/descriptor/
    maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/archetype/old/descriptor/ArchetypeDescriptor.java   (with props)
    maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/archetype/old/descriptor/ArchetypeDescriptorBuilder.java   (with props)
    maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/archetype/old/descriptor/ArchetypeDescriptorGenerator.java   (with props)
    maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/archetype/old/descriptor/TemplateDescriptor.java   (with props)
    maven/sandbox/trunk/archetypeng/archetype-old/src/main/mdo/
    maven/sandbox/trunk/archetypeng/archetype-old/src/main/mdo/archetype.mdo   (with props)
    maven/sandbox/trunk/archetypeng/archetype-old/src/test/
    maven/sandbox/trunk/archetypeng/archetype-old/src/test/java/
    maven/sandbox/trunk/archetypeng/archetype-old/src/test/java/org/
    maven/sandbox/trunk/archetypeng/archetype-old/src/test/java/org/apache/
    maven/sandbox/trunk/archetypeng/archetype-old/src/test/java/org/apache/maven/
    maven/sandbox/trunk/archetypeng/archetype-old/src/test/java/org/apache/maven/archetype/
    maven/sandbox/trunk/archetypeng/archetype-old/src/test/java/org/apache/maven/archetype/old/
    maven/sandbox/trunk/archetypeng/archetype-old/src/test/java/org/apache/maven/archetype/old/ArchetypeTest.java   (with props)
    maven/sandbox/trunk/archetypeng/archetype-old/src/test/java/org/apache/maven/archetype/old/descriptor/
    maven/sandbox/trunk/archetypeng/archetype-old/src/test/java/org/apache/maven/archetype/old/descriptor/ArchetypeDescriptorBuilderTest.java   (with props)
    maven/sandbox/trunk/archetypeng/archetype-old/src/test/repository/
    maven/sandbox/trunk/archetypeng/archetype-old/src/test/repository/org.apache.maven.archetypes/
    maven/sandbox/trunk/archetypeng/archetype-old/src/test/repository/org.apache.maven.archetypes/jars/
    maven/sandbox/trunk/archetypeng/archetype-old/src/test/repository/org.apache.maven.archetypes/jars/maven-archetype-quickstart-1.0-alpha-1-SNAPSHOT.jar   (with props)
    maven/sandbox/trunk/archetypeng/archetype-old/src/test/repository/org.apache.maven.archetypes/poms/
    maven/sandbox/trunk/archetypeng/archetype-old/src/test/repository/org.apache.maven.archetypes/poms/maven-archetype-quickstart-1.0-alpha-1-SNAPSHOT.pom   (with props)
    maven/sandbox/trunk/archetypeng/archetype-old/src/test/repository/org.apache.maven.archetypes/poms/maven-archetype-quickstart-1.0-alpha-1-SNAPSHOT.version.txt   (with props)
    maven/sandbox/trunk/archetypeng/archetype-old/src/test/repository/org.apache.maven.archetypes/poms/maven-archetypes-1.0-alpha-1-SNAPSHOT.pom   (with props)
    maven/sandbox/trunk/archetypeng/archetype-old/src/test/repository/org.apache.maven.archetypes/poms/maven-archetypes-1.0-alpha-1-SNAPSHOT.version.txt   (with props)
    maven/sandbox/trunk/archetypeng/archetype-old/src/test/resources/
    maven/sandbox/trunk/archetypeng/archetype-old/src/test/resources/xdocs/
    maven/sandbox/trunk/archetypeng/archetype-old/src/test/resources/xdocs/index.xml   (with props)
    maven/sandbox/trunk/archetypeng/archetype-old/src/test/resources/xdocs/navigation.xml   (with props)
Modified:
    maven/sandbox/trunk/archetypeng/archetypeng-common/pom.xml
    maven/sandbox/trunk/archetypeng/pom.xml

Added: maven/sandbox/trunk/archetypeng/archetype-old/pom.xml
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/archetypeng/archetype-old/pom.xml?rev=584247&view=auto
==============================================================================
--- maven/sandbox/trunk/archetypeng/archetype-old/pom.xml (added)
+++ maven/sandbox/trunk/archetypeng/archetype-old/pom.xml Fri Oct 12 12:52:09 2007
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <parent> 
+  <groupId>org.apache.maven.archetype</groupId>
+  <artifactId>maven-archetypeng</artifactId>
+  <version>2.0-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>archetype-old</artifactId>
+  <name>Maven Archetype old</name>
+  <dependencies>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-utils</artifactId>
+      <version>1.1</version>
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-velocity</artifactId>
+      <version>1.1.2</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven.wagon</groupId>
+      <artifactId>wagon-file</artifactId>
+      <version>1.0-alpha-6</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-model</artifactId>
+      <version>2.0</version>
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-container-default</artifactId>
+      <version>1.0-alpha-9</version>
+    </dependency>
+    <dependency>
+      <groupId>dom4j</groupId>
+      <artifactId>dom4j</artifactId>
+      <version>1.6.1</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven.shared</groupId>
+      <artifactId>maven-downloader</artifactId>
+      <version>1.0</version>
+    </dependency>
+  </dependencies>
+</project>
\ No newline at end of file

Propchange: maven/sandbox/trunk/archetypeng/archetype-old/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/archetype/old/Archetype.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/archetype/old/Archetype.java?rev=584247&view=auto
==============================================================================
--- maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/archetype/old/Archetype.java (added)
+++ maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/archetype/old/Archetype.java Fri Oct 12 12:52:09 2007
@@ -0,0 +1,44 @@
+package org.apache.maven.archetype;
+
+/*
+ * Copyright 2004-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.artifact.repository.ArtifactRepository;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
+ * @version $Id: Archetype.java 390965 2006-04-03 06:55:06Z brett $
+ */
+public interface Archetype
+{
+    String ROLE = Archetype.class.getName();
+
+    String ARCHETYPE_DESCRIPTOR = "META-INF/maven/archetype.xml";
+
+    String ARCHETYPE_OLD_DESCRIPTOR = "META-INF/archetype.xml";
+
+    String ARCHETYPE_RESOURCES = "archetype-resources";
+
+    // TODO: delete this, it probably should be project.getFile instead
+    String ARCHETYPE_POM = "pom.xml";
+
+    void createArchetype( String archetypeGroupId, String archetypeArtifactId, String archetypeVersion,
+                          ArtifactRepository localRepository, List remoteRepositories, Map parameters )
+        throws ArchetypeNotFoundException, ArchetypeDescriptorException, ArchetypeTemplateProcessingException;
+}

Propchange: maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/archetype/old/Archetype.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/archetype/old/ArchetypeDescriptorException.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/archetype/old/ArchetypeDescriptorException.java?rev=584247&view=auto
==============================================================================
--- maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/archetype/old/ArchetypeDescriptorException.java (added)
+++ maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/archetype/old/ArchetypeDescriptorException.java Fri Oct 12 12:52:09 2007
@@ -0,0 +1,40 @@
+package org.apache.maven.archetype;
+
+/*
+ * Copyright 2004-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
+ * @version $Id: ArchetypeDescriptorException.java 390965 2006-04-03 06:55:06Z brett $
+ */
+public class ArchetypeDescriptorException
+    extends Exception
+{
+    public ArchetypeDescriptorException( String message )
+    {
+        super( message );
+    }
+
+    public ArchetypeDescriptorException( Throwable cause )
+    {
+        super( cause );
+    }
+
+    public ArchetypeDescriptorException( String message, Throwable cause )
+    {
+        super( message, cause );
+    }
+}

Propchange: maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/archetype/old/ArchetypeDescriptorException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/archetype/old/ArchetypeNotFoundException.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/archetype/old/ArchetypeNotFoundException.java?rev=584247&view=auto
==============================================================================
--- maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/archetype/old/ArchetypeNotFoundException.java (added)
+++ maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/archetype/old/ArchetypeNotFoundException.java Fri Oct 12 12:52:09 2007
@@ -0,0 +1,40 @@
+package org.apache.maven.archetype;
+
+/*
+ * Copyright 2004-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
+ * @version $Id: ArchetypeNotFoundException.java 390965 2006-04-03 06:55:06Z brett $
+ */
+public class ArchetypeNotFoundException
+    extends Exception
+{
+    public ArchetypeNotFoundException( String message )
+    {
+        super( message );
+    }
+
+    public ArchetypeNotFoundException( Throwable cause )
+    {
+        super( cause );
+    }
+
+    public ArchetypeNotFoundException( String message, Throwable cause )
+    {
+        super( message, cause );
+    }
+}

Propchange: maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/archetype/old/ArchetypeNotFoundException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/archetype/old/ArchetypeTemplateProcessingException.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/archetype/old/ArchetypeTemplateProcessingException.java?rev=584247&view=auto
==============================================================================
--- maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/archetype/old/ArchetypeTemplateProcessingException.java (added)
+++ maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/archetype/old/ArchetypeTemplateProcessingException.java Fri Oct 12 12:52:09 2007
@@ -0,0 +1,40 @@
+package org.apache.maven.archetype;
+
+/*
+ * Copyright 2004-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
+ * @version $Id: ArchetypeTemplateProcessingException.java 390965 2006-04-03 06:55:06Z brett $
+ */
+public class ArchetypeTemplateProcessingException
+    extends Exception
+{
+    public ArchetypeTemplateProcessingException( String message )
+    {
+        super( message );
+    }
+
+    public ArchetypeTemplateProcessingException( Throwable cause )
+    {
+        super( cause );
+    }
+
+    public ArchetypeTemplateProcessingException( String message, Throwable cause )
+    {
+        super( message, cause );
+    }
+}

Propchange: maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/archetype/old/ArchetypeTemplateProcessingException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/archetype/old/DefaultArchetype.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/archetype/old/DefaultArchetype.java?rev=584247&view=auto
==============================================================================
--- maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/archetype/old/DefaultArchetype.java (added)
+++ maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/archetype/old/DefaultArchetype.java Fri Oct 12 12:52:09 2007
@@ -0,0 +1,955 @@
+package org.apache.maven.archetype;
+
+/*
+ * Copyright 2004-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.archetype.descriptor.ArchetypeDescriptor;
+import org.apache.maven.archetype.descriptor.ArchetypeDescriptorBuilder;
+import org.apache.maven.archetype.descriptor.TemplateDescriptor;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.model.Build;
+import org.apache.maven.model.Model;
+import org.apache.maven.model.Parent;
+import org.apache.maven.model.Resource;
+import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
+import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
+import org.apache.maven.shared.downloader.DownloadException;
+import org.apache.maven.shared.downloader.DownloadNotFoundException;
+import org.apache.maven.shared.downloader.Downloader;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.context.Context;
+import org.codehaus.plexus.logging.AbstractLogEnabled;
+import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.StringUtils;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+import org.codehaus.plexus.velocity.VelocityComponent;
+import org.dom4j.Document;
+import org.dom4j.DocumentException;
+import org.dom4j.Element;
+import org.dom4j.Node;
+import org.dom4j.io.SAXReader;
+import org.dom4j.io.XMLWriter;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Reader;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @plexus.component
+ * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
+ * @version $Id: DefaultArchetype.java 475957 2006-11-16 22:46:52Z jvanzyl $
+ */
+public class DefaultArchetype
+    extends AbstractLogEnabled
+    implements Archetype
+{
+    private static final String DEFAULT_TEST_RESOURCE_DIR = "/src/test/resources";
+
+    private static final String DEFAULT_TEST_SOURCE_DIR = "/src/test/java";
+
+    private static final String DEFAULT_RESOURCE_DIR = "/src/main/resources";
+
+    private static final String DEFAULT_SOURCE_DIR = "/src/main/java";
+
+    // ----------------------------------------------------------------------
+    // Components
+    // ----------------------------------------------------------------------
+
+    /**
+     * @plexus.requirement
+     */
+    private VelocityComponent velocity;
+
+    /**
+     * @plexus.requirement
+     */
+    private Downloader downloader;
+
+    // ----------------------------------------------------------------------
+    // Implementation
+    // ----------------------------------------------------------------------
+
+    // groupId = maven
+    // artifactId = maven-foo-archetype
+    // version = latest
+
+    public void createArchetype( String archetypeGroupId,
+                                 String archetypeArtifactId,
+                                 String archetypeVersion,
+                                 ArtifactRepository localRepository,
+                                 List remoteRepositories,
+                                 Map parameters )
+        throws ArchetypeNotFoundException, ArchetypeDescriptorException, ArchetypeTemplateProcessingException
+    {
+        // ----------------------------------------------------------------------
+        // Download the archetype
+        // ----------------------------------------------------------------------
+
+        File archetype;
+
+        try
+        {
+            archetype = downloader.download( archetypeGroupId, archetypeArtifactId, archetypeVersion, localRepository,
+                                             remoteRepositories );
+        }
+        catch ( DownloadException e )
+        {
+            throw new ArchetypeDescriptorException( "Error attempting to download archetype.", e );
+        }
+        catch ( DownloadNotFoundException e )
+        {
+            throw new ArchetypeNotFoundException( "Archetype does not exist.", e );
+        }
+
+        // ---------------------------------------------------------------------
+        // Get Logger and display all parameters used
+        // ---------------------------------------------------------------------
+        if ( getLogger().isInfoEnabled() )
+        {
+            if ( !parameters.isEmpty() )
+            {
+                getLogger().info( "----------------------------------------------------------------------------" );
+
+                getLogger().info( "Using following parameters for creating Archetype: " + archetypeArtifactId + ":" +
+                    archetypeVersion );
+
+                getLogger().info( "----------------------------------------------------------------------------" );
+
+                Set keys = parameters.keySet();
+
+                Iterator it = keys.iterator();
+
+                while ( it.hasNext() )
+                {
+                    String parameterName = (String) it.next();
+
+                    String parameterValue = (String) parameters.get( parameterName );
+
+                    getLogger().info( "Parameter: " + parameterName + ", Value: " + parameterValue );
+                }
+            }
+            else
+            {
+                getLogger().info( "No Parameters found for creating Archetype" );
+            }
+        }
+
+        // ----------------------------------------------------------------------
+        // Load the descriptor
+        // ----------------------------------------------------------------------
+
+        ArchetypeDescriptorBuilder builder = new ArchetypeDescriptorBuilder();
+
+        ArchetypeDescriptor descriptor;
+
+        URLClassLoader archetypeJarLoader;
+
+        try
+        {
+            URL[] urls = new URL[1];
+
+            urls[0] = archetype.toURL();
+
+            archetypeJarLoader = new URLClassLoader( urls );
+
+            InputStream is = getStream( ARCHETYPE_DESCRIPTOR, archetypeJarLoader );
+
+            if ( is == null )
+            {
+                is = getStream( ARCHETYPE_OLD_DESCRIPTOR, archetypeJarLoader );
+
+                if ( is == null )
+                {
+                    throw new ArchetypeDescriptorException(
+                        "The " + ARCHETYPE_DESCRIPTOR + " descriptor cannot be found." );
+                }
+            }
+
+            descriptor = builder.build( new InputStreamReader( is ) );
+        }
+        catch ( IOException e )
+        {
+            throw new ArchetypeDescriptorException( "Error reading the " + ARCHETYPE_DESCRIPTOR + " descriptor.", e );
+        }
+        catch ( XmlPullParserException e )
+        {
+            throw new ArchetypeDescriptorException( "Error reading the " + ARCHETYPE_DESCRIPTOR + " descriptor.", e );
+        }
+
+        // ----------------------------------------------------------------------
+        //
+        // ----------------------------------------------------------------------
+
+        String basedir = (String) parameters.get( "basedir" );
+
+        String artifactId = (String) parameters.get( "artifactId" );
+
+        File parentPomFile = new File( basedir, ARCHETYPE_POM );
+
+        File outputDirectoryFile;
+
+        boolean creating;
+        File pomFile;
+        if ( parentPomFile.exists() && descriptor.isAllowPartial() && artifactId == null )
+        {
+            outputDirectoryFile = new File( basedir );
+            creating = false;
+            pomFile = parentPomFile;
+        }
+        else
+        {
+            if ( artifactId == null )
+            {
+                throw new ArchetypeTemplateProcessingException(
+                    "Artifact ID must be specified when creating a new project from an archetype." );
+            }
+
+            outputDirectoryFile = new File( basedir, artifactId );
+            creating = true;
+
+            if ( outputDirectoryFile.exists() )
+            {
+                if ( descriptor.isAllowPartial() )
+                {
+                    creating = false;
+                }
+                else
+                {
+                    throw new ArchetypeTemplateProcessingException(
+                        outputDirectoryFile.getName() + " already exists - please run from a clean directory" );
+                }
+            }
+
+            pomFile = new File( outputDirectoryFile, ARCHETYPE_POM );
+        }
+
+        if ( creating )
+        {
+            if ( parameters.get( "groupId" ) == null )
+            {
+                throw new ArchetypeTemplateProcessingException(
+                    "Group ID must be specified when creating a new project from an archetype." );
+            }
+
+            if ( parameters.get( "version" ) == null )
+            {
+                throw new ArchetypeTemplateProcessingException(
+                    "Version must be specified when creating a new project from an archetype." );
+            }
+        }
+
+        String outputDirectory = outputDirectoryFile.getAbsolutePath();
+
+        String packageName = (String) parameters.get( "package" );
+
+        // ----------------------------------------------------------------------
+        // Set up the Velocity context
+        // ----------------------------------------------------------------------
+
+        Context context = new VelocityContext();
+
+        context.put( "package", packageName );
+
+        for ( Iterator iterator = parameters.keySet().iterator(); iterator.hasNext(); )
+        {
+            String key = (String) iterator.next();
+
+            Object value = parameters.get( key );
+
+            context.put( key, value );
+        }
+
+        // ----------------------------------------------------------------------
+        // Process the templates
+        // ----------------------------------------------------------------------
+
+        ClassLoader old = Thread.currentThread().getContextClassLoader();
+
+        Thread.currentThread().setContextClassLoader( archetypeJarLoader );
+
+        Model parentModel = null;
+        if ( creating )
+        {
+            if ( parentPomFile.exists() )
+            {
+                FileReader fileReader = null;
+
+                try
+                {
+                    fileReader = new FileReader( parentPomFile );
+                    MavenXpp3Reader reader = new MavenXpp3Reader();
+                    parentModel = reader.read( fileReader );
+                    if ( !"pom".equals( parentModel.getPackaging() ) )
+                    {
+                        throw new ArchetypeTemplateProcessingException(
+                            "Unable to add module to the current project as it is not of packaging type 'pom'" );
+                    }
+                }
+                catch ( IOException e )
+                {
+                    throw new ArchetypeTemplateProcessingException( "Unable to read parent POM", e );
+                }
+                catch ( XmlPullParserException e )
+                {
+                    throw new ArchetypeTemplateProcessingException( "Unable to read parent POM", e );
+                }
+                finally
+                {
+                    IOUtil.close( fileReader );
+                }
+
+                parentModel.getModules().add( artifactId );
+            }
+        }
+
+        try
+        {
+            processTemplates( pomFile, outputDirectory, context, descriptor, packageName, parentModel );
+        }
+        finally
+        {
+            Thread.currentThread().setContextClassLoader( old );
+        }
+
+        if ( parentModel != null )
+        {
+/*
+        // TODO: would be nice to just write out with the xpp3 writer again, except that it loses a bunch of info and
+        // reformats, so the module is just baked in as a string instead.
+            FileWriter fileWriter = null;
+
+            try
+            {
+                fileWriter = new FileWriter( parentPomFile );
+
+                MavenXpp3Writer writer = new MavenXpp3Writer();
+                writer.write( fileWriter, parentModel );
+            }
+            catch ( IOException e )
+            {
+                throw new ArchetypeTemplateProcessingException( "Unable to rewrite parent POM", e );
+            }
+            finally
+            {
+                IOUtil.close( fileWriter );
+            }
+*/
+            FileReader fileReader = null;
+            boolean added;
+            StringWriter w = new StringWriter();
+            try
+            {
+                fileReader = new FileReader( parentPomFile );
+                added = addModuleToParentPom( artifactId, fileReader, w );
+            }
+            catch ( IOException e )
+            {
+                throw new ArchetypeTemplateProcessingException( "Unable to rewrite parent POM", e );
+            }
+            catch ( DocumentException e )
+            {
+                throw new ArchetypeTemplateProcessingException( "Unable to rewrite parent POM", e );
+            }
+            finally
+            {
+                IOUtil.close( fileReader );
+            }
+
+            if ( added )
+            {
+                try
+                {
+                    FileUtils.fileWrite( parentPomFile.getAbsolutePath(), w.toString() );
+                }
+                catch ( IOException e )
+                {
+                    throw new ArchetypeTemplateProcessingException( "Unable to rewrite parent POM", e );
+                }
+            }
+        }
+
+        // ----------------------------------------------------------------------
+        // Log message on Archetype creation
+        // ----------------------------------------------------------------------
+        if ( getLogger().isInfoEnabled() )
+        {
+            getLogger().info( "Archetype created in dir: " + outputDirectory );
+        }
+
+    }
+
+    static boolean addModuleToParentPom( String artifactId,
+                                         Reader fileReader,
+                                         Writer fileWriter )
+        throws DocumentException, IOException, ArchetypeTemplateProcessingException
+    {
+        SAXReader reader = new SAXReader();
+        Document document = reader.read( fileReader );
+        Element project = document.getRootElement();
+
+        String packaging = null;
+        Element packagingElement = project.element( "packaging" );
+        if ( packagingElement != null )
+        {
+            packaging = packagingElement.getStringValue();
+        }
+        if ( !"pom".equals( packaging ) )
+        {
+            throw new ArchetypeTemplateProcessingException(
+                "Unable to add module to the current project as it is not of packaging type 'pom'" );
+        }
+
+        Element modules = project.element( "modules" );
+        if ( modules == null )
+        {
+            modules = project.addText( "  " ).addElement( "modules" );
+            modules.setText( "\n  " );
+            project.addText( "\n" );
+        }
+        boolean found = false;
+        for ( Iterator i = modules.elementIterator( "module" ); i.hasNext() && !found; )
+        {
+            Element module = (Element) i.next();
+            if ( module.getText().equals( artifactId ) )
+            {
+                found = true;
+            }
+        }
+        if ( !found )
+        {
+            Node lastTextNode = null;
+            for ( Iterator i = modules.nodeIterator(); i.hasNext(); )
+            {
+                Node node = (Node) i.next();
+                if ( node.getNodeType() == Node.ELEMENT_NODE )
+                {
+                    lastTextNode = null;
+                }
+                else if ( node.getNodeType() == Node.TEXT_NODE )
+                {
+                    lastTextNode = node;
+                }
+            }
+
+            if ( lastTextNode != null )
+            {
+                modules.remove( lastTextNode );
+            }
+
+            modules.addText( "\n    " );
+            modules.addElement( "module" ).setText( artifactId );
+            modules.addText( "\n  " );
+
+            XMLWriter writer = new XMLWriter( fileWriter );
+            writer.write( document );
+        }
+        return !found;
+    }
+
+    private void processTemplates( File pomFile,
+                                   String outputDirectory,
+                                   Context context,
+                                   ArchetypeDescriptor descriptor,
+                                   String packageName,
+                                   Model parentModel )
+        throws ArchetypeTemplateProcessingException
+    {
+        if ( !pomFile.exists() )
+        {
+            processTemplate( outputDirectory, context, ARCHETYPE_POM, new TemplateDescriptor(), false, null );
+        }
+
+        // ---------------------------------------------------------------------
+        // Model generated for the new archetype, so process it now
+        // ---------------------------------------------------------------------
+
+        Model generatedModel;
+        FileReader pomReader = null;
+        try
+        {
+            pomReader = new FileReader( pomFile );
+
+            MavenXpp3Reader reader = new MavenXpp3Reader();
+
+            generatedModel = reader.read( pomReader );
+        }
+        catch ( IOException e )
+        {
+            throw new ArchetypeTemplateProcessingException( "Error reading POM", e );
+        }
+        catch ( XmlPullParserException e )
+        {
+            throw new ArchetypeTemplateProcessingException( "Error reading POM", e );
+        }
+        finally
+        {
+            IOUtil.close( pomReader );
+        }
+
+        if ( parentModel != null )
+        {
+            Parent parent = new Parent();
+            parent.setGroupId( parentModel.getGroupId() );
+            if ( parent.getGroupId() == null )
+            {
+                parent.setGroupId( parentModel.getParent().getGroupId() );
+            }
+            parent.setArtifactId( parentModel.getArtifactId() );
+            parent.setVersion( parentModel.getVersion() );
+            if ( parent.getVersion() == null )
+            {
+                parent.setVersion( parentModel.getParent().getVersion() );
+            }
+            generatedModel.setParent( parent );
+
+            FileWriter pomWriter = null;
+            try
+            {
+                pomWriter = new FileWriter( pomFile );
+
+                MavenXpp3Writer writer = new MavenXpp3Writer();
+                writer.write( pomWriter, generatedModel );
+            }
+            catch ( IOException e )
+            {
+                throw new ArchetypeTemplateProcessingException( "Error rewriting POM", e );
+            }
+            finally
+            {
+                IOUtil.close( pomWriter );
+            }
+        }
+
+        // XXX: Following POM processing block may be a candidate for
+        // refactoring out into service methods or moving to
+        // createProjectDirectoryStructure(outputDirectory)
+        Build build = generatedModel.getBuild();
+
+        boolean overrideSrcDir = false;
+
+        boolean overrideResourceDir = false;
+
+        boolean overrideTestSrcDir = false;
+
+        boolean overrideTestResourceDir = false;
+
+        boolean foundBuildElement = build != null;
+
+        if ( getLogger().isDebugEnabled() )
+        {
+            getLogger().debug(
+                "********************* Debug info for resources created from generated Model ***********************" );
+        }
+
+        if ( getLogger().isDebugEnabled() )
+        {
+            getLogger().debug( "Was build element found in generated POM?: " + foundBuildElement );
+        }
+
+        // create source directory if specified in POM
+        if ( foundBuildElement && null != build.getSourceDirectory() )
+        {
+            if ( getLogger().isDebugEnabled() )
+            {
+                getLogger().debug( "Overriding default source directory " );
+            }
+
+            overrideSrcDir = true;
+
+            String srcDirectory = build.getSourceDirectory();
+
+            srcDirectory = StringUtils.replace( srcDirectory, "\\", "/" );
+
+            FileUtils.mkdir( getOutputDirectory( outputDirectory, srcDirectory ) );
+        }
+
+        // create script source directory if specified in POM
+        if ( foundBuildElement && null != build.getScriptSourceDirectory() )
+        {
+            if ( getLogger().isDebugEnabled() )
+            {
+                getLogger().debug( "Overriding default script source directory " );
+            }
+
+            String scriptSourceDirectory = build.getScriptSourceDirectory();
+
+            scriptSourceDirectory = StringUtils.replace( scriptSourceDirectory, "\\", "/" );
+
+            FileUtils.mkdir( getOutputDirectory( outputDirectory, scriptSourceDirectory ) );
+        }
+
+        // create resource director(y/ies) if specified in POM
+        if ( foundBuildElement && build.getResources().size() > 0 )
+        {
+            if ( getLogger().isDebugEnabled() )
+            {
+                getLogger().info( "Overriding default resource directory " );
+            }
+
+            overrideResourceDir = true;
+
+            Iterator resourceItr = build.getResources().iterator();
+
+            while ( resourceItr.hasNext() )
+            {
+                Resource resource = (Resource) resourceItr.next();
+
+                String resourceDirectory = resource.getDirectory();
+
+                resourceDirectory = StringUtils.replace( resourceDirectory, "\\", "/" );
+
+                FileUtils.mkdir( getOutputDirectory( outputDirectory, resourceDirectory ) );
+            }
+        }
+        // create test source directory if specified in POM
+        if ( foundBuildElement && null != build.getTestSourceDirectory() )
+        {
+            if ( getLogger().isDebugEnabled() )
+            {
+                getLogger().debug( "Overriding default test directory " );
+            }
+
+            overrideTestSrcDir = true;
+
+            String testDirectory = build.getTestSourceDirectory();
+
+            testDirectory = StringUtils.replace( testDirectory, "\\", "/" );
+
+            FileUtils.mkdir( getOutputDirectory( outputDirectory, testDirectory ) );
+        }
+
+        // create test resource directory if specified in POM
+        if ( foundBuildElement && build.getTestResources().size() > 0 )
+        {
+            if ( getLogger().isDebugEnabled() )
+            {
+                getLogger().debug( "Overriding default test resource directory " );
+            }
+
+            overrideTestResourceDir = true;
+
+            Iterator testResourceItr = build.getTestResources().iterator();
+
+            while ( testResourceItr.hasNext() )
+            {
+                Resource resource = (Resource) testResourceItr.next();
+
+                String testResourceDirectory = resource.getDirectory();
+
+                testResourceDirectory = StringUtils.replace( testResourceDirectory, "\\", "/" );
+
+                FileUtils.mkdir( getOutputDirectory( outputDirectory, testResourceDirectory ) );
+            }
+        }
+
+        getLogger().info(
+            "********************* End of debug info from resources from generated POM ***********************" );
+
+        // ----------------------------------------------------------------------
+        // Main
+        // ----------------------------------------------------------------------
+
+        if ( descriptor.getSources().size() > 0 )
+        {
+            if ( !overrideSrcDir )
+            {
+                FileUtils.mkdir( outputDirectory + DEFAULT_SOURCE_DIR );
+                processSources( outputDirectory, context, descriptor, packageName, DEFAULT_SOURCE_DIR );
+            }
+            else
+            {
+                processSources( outputDirectory, context, descriptor, packageName, build.getSourceDirectory() );
+            }
+        }
+
+        if ( descriptor.getResources().size() > 0 )
+        {
+            if ( !overrideResourceDir )
+            {
+                FileUtils.mkdir( outputDirectory + DEFAULT_RESOURCE_DIR );
+            }
+            processResources( outputDirectory, context, descriptor, packageName );
+        }
+
+        // ----------------------------------------------------------------------
+        // Test
+        // ----------------------------------------------------------------------
+
+        if ( descriptor.getTestSources().size() > 0 )
+        {
+            if ( !overrideTestSrcDir )
+            {
+                FileUtils.mkdir( outputDirectory + DEFAULT_TEST_SOURCE_DIR );
+                processTestSources( outputDirectory, context, descriptor, packageName, DEFAULT_TEST_SOURCE_DIR );
+            }
+            else
+            {
+                processTestSources( outputDirectory, context, descriptor, packageName, build.getTestSourceDirectory() );
+            }
+        }
+
+        if ( descriptor.getTestResources().size() > 0 )
+        {
+            if ( !overrideTestResourceDir )
+            {
+                FileUtils.mkdir( outputDirectory + DEFAULT_TEST_RESOURCE_DIR );
+            }
+            processTestResources( outputDirectory, context, descriptor, packageName );
+        }
+
+        // ----------------------------------------------------------------------
+        // Site
+        // ----------------------------------------------------------------------
+
+        if ( descriptor.getSiteResources().size() > 0 )
+        {
+            processSiteResources( outputDirectory, context, descriptor, packageName );
+        }
+    }
+
+    private void processTemplate( String outputDirectory,
+                                  Context context,
+                                  String template,
+                                  TemplateDescriptor descriptor,
+                                  boolean packageInFileName,
+                                  String packageName )
+        throws ArchetypeTemplateProcessingException
+    {
+        processTemplate( outputDirectory, context, template, descriptor, packageInFileName, packageName, null );
+    }
+
+    private String getOutputDirectory( String outputDirectory,
+                                       String testResourceDirectory )
+    {
+        return outputDirectory +
+            ( testResourceDirectory.startsWith( "/" ) ? testResourceDirectory : "/" + testResourceDirectory );
+    }
+
+    // ----------------------------------------------------------------------
+    //
+    // ----------------------------------------------------------------------
+
+    protected void processSources( String outputDirectory,
+                                   Context context,
+                                   ArchetypeDescriptor descriptor,
+                                   String packageName,
+                                   String sourceDirectory )
+        throws ArchetypeTemplateProcessingException
+    {
+        for ( Iterator i = descriptor.getSources().iterator(); i.hasNext(); )
+        {
+            String template = (String) i.next();
+
+            processTemplate( outputDirectory, context, template, descriptor.getSourceDescriptor( template ), true,
+                             packageName, sourceDirectory );
+        }
+    }
+
+    protected void processTestSources( String outputDirectory,
+                                       Context context,
+                                       ArchetypeDescriptor descriptor,
+                                       String packageName,
+                                       String testSourceDirectory )
+        throws ArchetypeTemplateProcessingException
+    {
+        for ( Iterator i = descriptor.getTestSources().iterator(); i.hasNext(); )
+        {
+            String template = (String) i.next();
+
+            processTemplate( outputDirectory, context, template, descriptor.getTestSourceDescriptor( template ), true,
+                             packageName, testSourceDirectory );
+        }
+    }
+
+    protected void processResources( String outputDirectory,
+                                     Context context,
+                                     ArchetypeDescriptor descriptor,
+                                     String packageName )
+        throws ArchetypeTemplateProcessingException
+    {
+        for ( Iterator i = descriptor.getResources().iterator(); i.hasNext(); )
+        {
+            String template = (String) i.next();
+
+            processTemplate( outputDirectory, context, template, descriptor.getResourceDescriptor( template ), false,
+                             packageName );
+        }
+    }
+
+    protected void processTestResources( String outputDirectory,
+                                         Context context,
+                                         ArchetypeDescriptor descriptor,
+                                         String packageName )
+        throws ArchetypeTemplateProcessingException
+    {
+        for ( Iterator i = descriptor.getTestResources().iterator(); i.hasNext(); )
+        {
+            String template = (String) i.next();
+
+            processTemplate( outputDirectory, context, template, descriptor.getTestResourceDescriptor( template ),
+                             false, packageName );
+        }
+    }
+
+    protected void processSiteResources( String outputDirectory,
+                                         Context context,
+                                         ArchetypeDescriptor descriptor,
+                                         String packageName )
+        throws ArchetypeTemplateProcessingException
+    {
+        for ( Iterator i = descriptor.getSiteResources().iterator(); i.hasNext(); )
+        {
+            String template = (String) i.next();
+
+            processTemplate( outputDirectory, context, template, descriptor.getSiteResourceDescriptor( template ),
+                             false, packageName );
+        }
+    }
+
+    protected void processTemplate( String outputDirectory,
+                                    Context context,
+                                    String template,
+                                    TemplateDescriptor descriptor,
+                                    boolean packageInFileName,
+                                    String packageName,
+                                    String sourceDirectory )
+        throws ArchetypeTemplateProcessingException
+    {
+        File f;
+
+        template = StringUtils.replace( template, "\\", "/" );
+
+        if ( packageInFileName && packageName != null )
+        {
+            String templateFileName = StringUtils.replace( template, "/", File.separator );
+
+            String path = packageName.replace( '.', '/' );
+
+            String filename = FileUtils.filename( templateFileName );
+
+            String dirname = FileUtils.dirname( templateFileName ).replace( '\\', '/' );
+
+            sourceDirectory = sourceDirectory.replace( '\\', '/' );
+            if ( sourceDirectory.startsWith( "/" ) )
+            {
+                sourceDirectory = sourceDirectory.substring( 1 );
+            }
+
+            if ( !dirname.startsWith( sourceDirectory ) )
+            {
+                throw new ArchetypeTemplateProcessingException(
+                    "Template '" + template + "' not in directory '" + sourceDirectory + "'" );
+            }
+
+            String extraPackages = dirname.substring( sourceDirectory.length() );
+            if ( extraPackages.startsWith( "/" ) )
+            {
+                extraPackages = extraPackages.substring( 1 );
+            }
+            if ( extraPackages.length() > 0 )
+            {
+                path += "/" + extraPackages;
+            }
+
+            f = new File( new File( new File( outputDirectory, sourceDirectory ), path ), filename );
+        }
+        else
+        {
+            f = new File( outputDirectory, template );
+        }
+
+        if ( !f.getParentFile().exists() )
+        {
+            f.getParentFile().mkdirs();
+        }
+
+        if ( descriptor.isFiltered() )
+        {
+            Writer writer = null;
+            try
+            {
+                writer = new OutputStreamWriter( new FileOutputStream( f ), descriptor.getEncoding() );
+
+                template = ARCHETYPE_RESOURCES + "/" + template;
+
+                velocity.getEngine().mergeTemplate( template, descriptor.getEncoding(), context, writer );
+
+                writer.flush();
+            }
+            catch ( Exception e )
+            {
+                throw new ArchetypeTemplateProcessingException( "Error merging velocity templates", e );
+            }
+            finally
+            {
+                IOUtil.close( writer );
+            }
+        }
+        else
+        {
+            InputStream is = getStream( ARCHETYPE_RESOURCES + "/" + template, null );
+
+            OutputStream fos = null;
+
+            try
+            {
+                fos = new FileOutputStream( f );
+
+                IOUtil.copy( is, fos );
+            }
+            catch ( Exception e )
+            {
+                throw new ArchetypeTemplateProcessingException( "Error copying file", e );
+            }
+            finally
+            {
+                IOUtil.close( fos );
+
+                IOUtil.close( is );
+            }
+        }
+    }
+
+    protected void createProjectDirectoryStructure( String outputDirectory )
+    {
+    }
+
+    private InputStream getStream( String name,
+                                   ClassLoader loader )
+    {
+        if ( loader == null )
+        {
+            return Thread.currentThread().getContextClassLoader().getResourceAsStream( name );
+        }
+        return loader.getResourceAsStream( name );
+    }
+}

Propchange: maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/archetype/old/DefaultArchetype.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/archetype/old/descriptor/ArchetypeDescriptor.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/archetype/old/descriptor/ArchetypeDescriptor.java?rev=584247&view=auto
==============================================================================
--- maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/archetype/old/descriptor/ArchetypeDescriptor.java (added)
+++ maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/archetype/old/descriptor/ArchetypeDescriptor.java Fri Oct 12 12:52:09 2007
@@ -0,0 +1,261 @@
+package org.apache.maven.archetype.descriptor;
+
+/*
+ * Copyright 2004-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class ArchetypeDescriptor
+{
+    private String id;
+
+    private List sources;
+
+    private List testSources;
+
+    private List resources;
+
+    private List testResources;
+
+    private List siteResources;
+
+    /**
+     * <code>Map</code> that associates the items in the <code>List</code>
+     * <code>sources</code> with their attributes (instances of
+     * <code>TemplateDescriptor</code>.
+     */
+    private Map sourcesDescriptors;
+
+    /**
+     * <code>Map</code> that associates the items in the <code>List</code>
+     * <code>testSources</code> with their attributes (instances of
+     * <code>TemplateDescriptor</code>.
+     */
+    private Map testSourcesDescriptors;
+
+    /**
+     * <code>Map</code> that associates the items in the <code>List</code>
+     * <code>resources</code> with their attributes (instances of
+     * <code>TemplateDescriptor</code>.
+     */
+    private Map resourcesDescriptors;
+
+    /**
+     * <code>Map</code> that associates the items in the <code>List</code>
+     * <code>testResources</code> with their attributes (instances of
+     * <code>TemplateDescriptor</code>.
+     */
+    private Map testResourcesDescriptors;
+
+    /**
+     * <code>Map</code> that associates the items in the <code>List</code>
+     * <code>siteResources</code> with their attributes (instances of
+     * <code>TemplateDescriptor</code>.
+     */
+    private Map siteResourcesDescriptors;
+
+    /**
+     * This indicates the archetype can be a whole project or can be part
+     * of another project. An example is a site archetype where the POM and
+     * directory structure may already exist and you simply want to generate
+     * the site directory structure.
+     */
+    private boolean allowPartial;
+
+    public ArchetypeDescriptor()
+    {
+        sources = new ArrayList();
+
+        resources = new ArrayList();
+
+        testSources = new ArrayList();
+
+        testResources = new ArrayList();
+
+        siteResources = new ArrayList();
+
+        sourcesDescriptors = new HashMap();
+
+        testSourcesDescriptors = new HashMap();
+
+        resourcesDescriptors = new HashMap();
+
+        testResourcesDescriptors = new HashMap();
+
+        siteResourcesDescriptors = new HashMap();
+    }
+
+    // ----------------------------------------------------------------------
+    //
+    // ----------------------------------------------------------------------
+
+    public String getId()
+    {
+        return id;
+    }
+
+    public void setId( String id )
+    {
+        this.id = id;
+    }
+
+    public void addSource( String source )
+    {
+        sources.add( source );
+
+        putSourceDescriptor( source, new TemplateDescriptor() );
+    }
+
+    public List getSources()
+    {
+        return sources;
+    }
+
+    public void putSourceDescriptor( String source, TemplateDescriptor descriptor )
+    {
+        sourcesDescriptors.put( source, descriptor );
+    }
+
+    public TemplateDescriptor getSourceDescriptor( String source )
+    {
+        return (TemplateDescriptor) sourcesDescriptors.get( source );
+    }
+
+    public Map getSourcesDescriptors()
+    {
+        return sourcesDescriptors;
+    }
+
+    public void addTestSource( String testSource )
+    {
+        testSources.add( testSource );
+
+        putTestSourceDescriptor( testSource, new TemplateDescriptor() );
+    }
+
+    public List getTestSources()
+    {
+        return testSources;
+    }
+
+    public void putTestSourceDescriptor( String testSource, TemplateDescriptor descriptor )
+    {
+        testSourcesDescriptors.put( testSource, descriptor );
+    }
+
+    public TemplateDescriptor getTestSourceDescriptor( String testSource )
+    {
+        return (TemplateDescriptor) testSourcesDescriptors.get( testSource );
+    }
+
+    public Map getTestSourcesDescriptors()
+    {
+        return testSourcesDescriptors;
+    }
+
+    public void addResource( String resource )
+    {
+        resources.add( resource );
+
+        putResourceDescriptor( resource, new TemplateDescriptor() );
+    }
+
+    public List getResources()
+    {
+        return resources;
+    }
+
+    public void putResourceDescriptor( String resource, TemplateDescriptor descriptor )
+    {
+        resourcesDescriptors.put( resource, descriptor );
+    }
+
+    public TemplateDescriptor getResourceDescriptor( String resource )
+    {
+        return (TemplateDescriptor) resourcesDescriptors.get( resource );
+    }
+
+    public Map getReourcesDescriptors()
+    {
+        return resourcesDescriptors;
+    }
+
+    public void addTestResource( String testResource )
+    {
+        testResources.add( testResource );
+        putTestResourceDescriptor( testResource, new TemplateDescriptor() );
+    }
+
+    public List getTestResources()
+    {
+        return testResources;
+    }
+
+    public void putTestResourceDescriptor( String testResource, TemplateDescriptor descriptor )
+    {
+        testResourcesDescriptors.put( testResource, descriptor );
+    }
+
+    public TemplateDescriptor getTestResourceDescriptor( String testResource )
+    {
+        return (TemplateDescriptor) testResourcesDescriptors.get( testResource );
+    }
+
+    public Map getTestReourcesDescriptors()
+    {
+        return testResourcesDescriptors;
+    }
+
+    public void addSiteResource( String siteResource )
+    {
+        siteResources.add( siteResource );
+
+        putSiteResourceDescriptor( siteResource, new TemplateDescriptor() );
+    }
+
+    public List getSiteResources()
+    {
+        return siteResources;
+    }
+
+    public void putSiteResourceDescriptor( String siteResource, TemplateDescriptor descriptor )
+    {
+        siteResourcesDescriptors.put( siteResource, descriptor );
+    }
+
+    public TemplateDescriptor getSiteResourceDescriptor( String siteResource )
+    {
+        return (TemplateDescriptor) siteResourcesDescriptors.get( siteResource );
+    }
+
+    public Map getSiteReourcesDescriptors()
+    {
+        return siteResourcesDescriptors;
+    }
+
+    public boolean isAllowPartial()
+    {
+        return allowPartial;
+    }
+
+    public void setAllowPartial( boolean allowPartial )
+    {
+        this.allowPartial = allowPartial;
+    }
+}

Propchange: maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/archetype/old/descriptor/ArchetypeDescriptor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/archetype/old/descriptor/ArchetypeDescriptorBuilder.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/archetype/old/descriptor/ArchetypeDescriptorBuilder.java?rev=584247&view=auto
==============================================================================
--- maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/archetype/old/descriptor/ArchetypeDescriptorBuilder.java (added)
+++ maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/archetype/old/descriptor/ArchetypeDescriptorBuilder.java Fri Oct 12 12:52:09 2007
@@ -0,0 +1,406 @@
+package org.apache.maven.archetype.descriptor;
+
+/*
+ * Copyright 2004-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.codehaus.plexus.util.xml.Xpp3Dom;
+import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.nio.charset.IllegalCharsetNameException;
+import java.nio.charset.UnsupportedCharsetException;
+
+/**
+ * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
+ * @version $Id: ArchetypeDescriptorBuilder.java 390965 2006-04-03 06:55:06Z brett $
+ */
+public class ArchetypeDescriptorBuilder
+{
+    public ArchetypeDescriptor build( Reader reader )
+        throws IOException, XmlPullParserException
+    {
+        ArchetypeDescriptor descriptor = new ArchetypeDescriptor();
+
+        Xpp3Dom dom = Xpp3DomBuilder.build( reader );
+
+        descriptor.setId( dom.getChild( "id" ).getValue() );
+
+        Xpp3Dom allowPartialDom = dom.getChild( "allowPartial" );
+
+        if ( allowPartialDom != null )
+        {
+            String allowPartial = allowPartialDom.getValue();
+
+            if ( "true".equals( allowPartial ) || "1".equals( allowPartial ) || "on".equals( allowPartial ) )
+            {
+                descriptor.setAllowPartial( true );
+            }
+        }
+
+        // ----------------------------------------------------------------------
+        // Main
+        // ----------------------------------------------------------------------
+
+        Xpp3Dom sources = dom.getChild( "sources" );
+
+        if ( sources != null )
+        {
+            Xpp3Dom[] sourceList = sources.getChildren( "source" );
+
+            for ( int i = 0; i < sourceList.length; i++ )
+            {
+                addSourceToDescriptor( sourceList[i], descriptor );
+            }
+        }
+
+        Xpp3Dom resources = dom.getChild( "resources" );
+
+        if ( resources != null )
+        {
+            Xpp3Dom[] resourceList = resources.getChildren( "resource" );
+
+            for ( int i = 0; i < resourceList.length; i++ )
+            {
+                addResourceToDescriptor( resourceList[i], descriptor );
+            }
+        }
+
+        // ----------------------------------------------------------------------
+        // Test
+        // ----------------------------------------------------------------------
+
+        Xpp3Dom testSources = dom.getChild( "testSources" );
+
+        if ( testSources != null )
+        {
+            Xpp3Dom[] testSourceList = testSources.getChildren( "source" );
+
+            for ( int i = 0; i < testSourceList.length; i++ )
+            {
+                addTestSourceToDescriptor( testSourceList[i], descriptor );
+            }
+        }
+
+        Xpp3Dom testResources = dom.getChild( "testResources" );
+
+        if ( testResources != null )
+        {
+            Xpp3Dom[] testResourceList = testResources.getChildren( "resource" );
+
+            for ( int i = 0; i < testResourceList.length; i++ )
+            {
+                addTestResourceToDescriptor( testResourceList[i], descriptor );
+            }
+        }
+
+        // ----------------------------------------------------------------------
+        // Site
+        // ----------------------------------------------------------------------
+
+        Xpp3Dom siteResources = dom.getChild( "siteResources" );
+
+        if ( siteResources != null )
+        {
+            Xpp3Dom[] siteResourceList = siteResources.getChildren( "resource" );
+
+            for ( int i = 0; i < siteResourceList.length; i++ )
+            {
+                addSiteResourceToDescriptor( siteResourceList[i], descriptor );
+            }
+        }
+
+        return descriptor;
+    }
+
+    /**
+     * Adds the source element <code>source</code> to the list of sources in the
+     * <code>descriptor</code> and sets its <code>TemplateDescriptor</code> to
+     * <i>filtered</i> and with the encoding specified in the <code>encoding</code>
+     * attribute or the Java virtual machine's default if it is not defined.
+     *
+     * @param source     a <code>&lt;source&gt;</code> element from the <code>&lt;sources&gt;</code>
+     * @param descriptor the <code>ArchetypeDescriptor</code> to add the source template to.
+     * @throws XmlPullParserException if the encoding specified is not valid or supported.
+     */
+    private static void addSourceToDescriptor( Xpp3Dom source, ArchetypeDescriptor descriptor )
+        throws XmlPullParserException
+    {
+        descriptor.addSource( source.getValue() );
+
+        TemplateDescriptor sourceDesc = descriptor.getSourceDescriptor( source.getValue() );
+
+        sourceDesc.setFiltered( true );
+
+        if ( source.getAttribute( "encoding" ) != null )
+        {
+            try
+            {
+                sourceDesc.setEncoding( source.getAttribute( "encoding" ) );
+            }
+            catch ( IllegalCharsetNameException icne )
+            {
+                throw new XmlPullParserException( source.getAttribute( "encoding" ) + " is not a valid encoding." );
+            }
+            catch ( UnsupportedCharsetException uce )
+            {
+                throw new XmlPullParserException( source.getAttribute( "encoding" ) + " is not a supported encoding." );
+            }
+        }
+    }
+
+    /**
+     * Adds the resource element <code>resource</code> to the list of resources in the
+     * <code>descriptor</code> and sets its <code>TemplateDescriptor</code> to
+     * <i>filtered</i> if the attribute <code>filtered</code> was not
+     * specified or its value is <code>&quot;true&quot;</code>, or <code>false</code>
+     * if its value is <code>&quot;false&quot;</code>, and the encoding specified
+     * in the <code>encoding</code> attribute or the Java virtual machine's default if
+     * it is not defined. If the <code>resource</code> is a property file (ends in
+     * <code>.properties</code>) its encoding will be set to <code>iso-8859-1</code>
+     * even if some other encoding is specified in the attribute.
+     *
+     * @param resource   a <code>&lt;resource&gt;</code> element from the <code>&lt;resources&gt;</code>
+     * @param descriptor the <code>ArchetypeDescriptor</code> to add the resource template to.
+     * @throws XmlPullParserException if the encoding specified is not valid or supported or if the
+     *                                value of the attribute <code>filtered</code> is no valid.
+     */
+    private static void addResourceToDescriptor( Xpp3Dom resource, ArchetypeDescriptor descriptor )
+        throws XmlPullParserException
+    {
+        descriptor.addResource( resource.getValue() );
+
+        if ( resource.getAttribute( "filtered" ) != null )
+        {
+            TemplateDescriptor resourceDesc = descriptor.getResourceDescriptor( resource.getValue() );
+
+            try
+            {
+                resourceDesc.setFiltered( getValueFilteredAttribute( resource.getAttribute( "filtered" ) ) );
+            }
+            catch ( IllegalArgumentException iae )
+            {
+                throw new XmlPullParserException( iae.getMessage() );
+            }
+        }
+
+        if ( resource.getAttribute( "encoding" ) != null )
+        {
+            TemplateDescriptor resourceDesc = descriptor.getResourceDescriptor( resource.getValue() );
+
+            try
+            {
+                resourceDesc.setEncoding( resource.getAttribute( "encoding" ) );
+            }
+            catch ( IllegalCharsetNameException icne )
+            {
+                throw new XmlPullParserException( resource.getAttribute( "encoding" ) + " is not a valid encoding." );
+            }
+            catch ( UnsupportedCharsetException uce )
+            {
+                throw new XmlPullParserException(
+                    resource.getAttribute( "encoding" ) + " is not a supported encoding." );
+            }
+        }
+
+        if ( resource.getValue().endsWith( ".properties" ) )
+        {
+            TemplateDescriptor resourceDesc = descriptor.getResourceDescriptor( resource.getValue() );
+
+            resourceDesc.setEncoding( "iso-8859-1" );
+        }
+    }
+
+    /**
+     * Adds the test-source element <code>source</code> to the list of sources in the
+     * <code>descriptor</code> and sets its <code>TemplateDescriptor</code> to
+     * <i>filtered</i> and with the encoding specified in the <code>encoding</code>
+     * attribute or the Java virtual machine's default if it is not defined.
+     *
+     * @param testSource a <code>&lt;source&gt;</code> element from the <code>&lt;testSources&gt;</code>
+     * @param descriptor the <code>ArchetypeDescriptor</code> to add the test-source template to.
+     * @throws XmlPullParserException if the encoding specified is not valid or supported.
+     */
+    private static void addTestSourceToDescriptor( Xpp3Dom testSource, ArchetypeDescriptor descriptor )
+        throws XmlPullParserException
+    {
+        descriptor.addTestSource( testSource.getValue() );
+        TemplateDescriptor testSourceDesc = descriptor.getTestSourceDescriptor( testSource.getValue() );
+        testSourceDesc.setFiltered( true );
+        if ( testSource.getAttribute( "encoding" ) != null )
+        {
+            try
+            {
+                testSourceDesc.setEncoding( testSource.getAttribute( "encoding" ) );
+            }
+            catch ( IllegalCharsetNameException icne )
+            {
+                throw new XmlPullParserException( testSource.getAttribute( "encoding" ) + " is not a valid encoding." );
+            }
+            catch ( UnsupportedCharsetException uce )
+            {
+                throw new XmlPullParserException(
+                    testSource.getAttribute( "encoding" ) + " is not a supported encoding." );
+            }
+        }
+    }
+
+    /**
+     * Adds the test-resource element <code>resource</code> to the list of test-resources in the
+     * <code>descriptor</code> and sets its <code>TemplateDescriptor</code> to
+     * <i>filtered</i> if the attribute <code>filtered</code> was not
+     * specified or its value is <code>&quot;true&quot;</code>, or <code>false</code>
+     * if its value is <code>&quot;false&quot;</code>, and the encoding specified
+     * in the <code>encoding</code> attribute or the Java virtual machine's default if
+     * it is not defined. If the <code>resource</code> is a property file (ends in
+     * <code>.properties</code>) its encoding will be set to <code>iso-8859-1</code>
+     * even if some other encoding is specified in the attribute.
+     *
+     * @param testResource a <code>&lt;resource&gt;</code> element from the <code>&lt;testResources&gt;</code>
+     * @param descriptor   the <code>ArchetypeDescriptor</code> to add the test-resource template to.
+     * @throws XmlPullParserException if the encoding specified is not valid or supported or if the
+     *                                value of the attribute <code>filtered</code> is no valid.
+     */
+    private static void addTestResourceToDescriptor( Xpp3Dom testResource, ArchetypeDescriptor descriptor )
+        throws XmlPullParserException
+    {
+        descriptor.addTestResource( testResource.getValue() );
+
+        if ( testResource.getAttribute( "filtered" ) != null )
+        {
+            TemplateDescriptor testResourceDesc = descriptor.getTestResourceDescriptor( testResource.getValue() );
+
+            try
+            {
+                testResourceDesc.setFiltered( getValueFilteredAttribute( testResource.getAttribute( "filtered" ) ) );
+            }
+            catch ( IllegalArgumentException iae )
+            {
+                throw new XmlPullParserException( iae.getMessage() );
+            }
+        }
+
+        if ( testResource.getAttribute( "encoding" ) != null )
+        {
+            TemplateDescriptor testResourceDesc = descriptor.getTestResourceDescriptor( testResource.getValue() );
+
+            try
+            {
+                testResourceDesc.setEncoding( testResource.getAttribute( "encoding" ) );
+
+            }
+            catch ( IllegalCharsetNameException icne )
+            {
+                throw new XmlPullParserException(
+                    testResource.getAttribute( "encoding" ) + " is not a valid encoding." );
+            }
+            catch ( UnsupportedCharsetException uce )
+            {
+                throw new XmlPullParserException(
+                    testResource.getAttribute( "encoding" ) + " is not a supported encoding." );
+            }
+        }
+
+        if ( testResource.getValue().endsWith( ".properties" ) )
+        {
+            TemplateDescriptor testResourceDesc = descriptor.getTestResourceDescriptor( testResource.getValue() );
+
+            testResourceDesc.setEncoding( "iso-8859-1" );
+        }
+    }
+
+    /**
+     * Adds the site-resource element <code>resource</code> to the list of site-resources in the
+     * <code>descriptor</code> and sets its <code>TemplateDescriptor</code> to
+     * <i>filtered</i> if the attribute <code>filtered</code> was not
+     * specified or its value is <code>&quot;true&quot;</code>, or <code>false</code>
+     * if its value is <code>&quot;false&quot;</code>, and the encoding specified
+     * in the <code>encoding</code> attribute or the Java virtual machine's default if
+     * it is not defined. If the <code>resource</code> is a property file (ends in
+     * <code>.properties</code>) its encoding will be set to <code>iso-8859-1</code>
+     * even if some other encoding is specified in the attribute.
+     *
+     * @param siteResource a <code>&lt;resource&gt;</code> element from the <code>&lt;siteResources&gt;</code>
+     * @param descriptor   the <code>ArchetypeDescriptor</code> to add the site-resource template to.
+     * @throws XmlPullParserException if the encoding specified is not valid or supported or if the
+     *                                value of the attribute <code>filtered</code> is no valid.
+     */
+    private static void addSiteResourceToDescriptor( Xpp3Dom siteResource, ArchetypeDescriptor descriptor )
+        throws XmlPullParserException
+    {
+        descriptor.addSiteResource( siteResource.getValue() );
+
+        if ( siteResource.getAttribute( "filtered" ) != null )
+        {
+            TemplateDescriptor siteResourceDesc = descriptor.getSiteResourceDescriptor( siteResource.getValue() );
+
+            try
+            {
+                siteResourceDesc.setFiltered( getValueFilteredAttribute( siteResource.getAttribute( "filtered" ) ) );
+            }
+            catch ( IllegalArgumentException iae )
+            {
+                throw new XmlPullParserException( iae.getMessage() );
+            }
+        }
+        if ( siteResource.getAttribute( "encoding" ) != null )
+        {
+            TemplateDescriptor siteResourceDesc = descriptor.getSiteResourceDescriptor( siteResource.getValue() );
+
+            try
+            {
+                siteResourceDesc.setEncoding( siteResource.getAttribute( "encoding" ) );
+            }
+            catch ( IllegalCharsetNameException icne )
+            {
+                throw new XmlPullParserException(
+                    siteResource.getAttribute( "encoding" ) + " is not a valid encoding." );
+            }
+            catch ( UnsupportedCharsetException uce )
+            {
+                throw new XmlPullParserException(
+                    siteResource.getAttribute( "encoding" ) + " is not a supported encoding." );
+            }
+        }
+        if ( siteResource.getValue().endsWith( ".properties" ) )
+        {
+            TemplateDescriptor siteResourceDesc = descriptor.getSiteResourceDescriptor( siteResource.getValue() );
+
+            siteResourceDesc.setEncoding( "iso-8859-1" );
+        }
+    }
+
+    private static boolean getValueFilteredAttribute( String str )
+        throws IllegalArgumentException
+    {
+        boolean ret = false;
+
+        if ( str.equals( "true" ) )
+        {
+            ret = true;
+        }
+        else if ( str.equals( "false" ) )
+        {
+            ret = false;
+        }
+        else
+        {
+            throw new IllegalArgumentException( str + " is not an accepted value for the attribute 'filtered'" );
+        }
+        return ret;
+    }
+}

Propchange: maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/archetype/old/descriptor/ArchetypeDescriptorBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/archetype/old/descriptor/ArchetypeDescriptorGenerator.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/archetype/old/descriptor/ArchetypeDescriptorGenerator.java?rev=584247&view=auto
==============================================================================
--- maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/archetype/old/descriptor/ArchetypeDescriptorGenerator.java (added)
+++ maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/archetype/old/descriptor/ArchetypeDescriptorGenerator.java Fri Oct 12 12:52:09 2007
@@ -0,0 +1,28 @@
+package org.apache.maven.archetype.descriptor;
+
+/*
+ * Copyright 2004-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Pass over the directory containing the sources of the archetype and create
+ * the appropriate descriptor.
+ *
+ * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
+ * @version $Id: ArchetypeDescriptorGenerator.java 390965 2006-04-03 06:55:06Z brett $
+ */
+public class ArchetypeDescriptorGenerator
+{
+}

Propchange: maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/archetype/old/descriptor/ArchetypeDescriptorGenerator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/archetype/old/descriptor/TemplateDescriptor.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/archetype/old/descriptor/TemplateDescriptor.java?rev=584247&view=auto
==============================================================================
--- maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/archetype/old/descriptor/TemplateDescriptor.java (added)
+++ maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/archetype/old/descriptor/TemplateDescriptor.java Fri Oct 12 12:52:09 2007
@@ -0,0 +1,125 @@
+package org.apache.maven.archetype.descriptor;
+
+/*
+ * Copyright 2004-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.OutputStreamWriter;
+import java.nio.charset.Charset;
+import java.nio.charset.IllegalCharsetNameException;
+import java.nio.charset.UnsupportedCharsetException;
+
+/**
+ * Contains the attributes of an archetype's template (either a source or resource file).
+ * The attributes indicate if the template should be filtered and it's encoding.
+ */
+public class TemplateDescriptor
+{
+
+    /**
+     * Determines if the template should be filtered or not.
+     */
+    private boolean filtered = true;
+
+    /**
+     * Determines the template's encoding.
+     */
+    private String encoding;
+
+    /**
+     * Creates a new instance of <code>TemplateDescriptor<code> that should be filtered
+     * and has the default encoding.
+     */
+    public TemplateDescriptor()
+    {
+        setFiltered( true );
+
+        setEncoding( getDefaultEncoding() );
+    }
+
+    /**
+     * Returns the canonical name of the default character encoding of this Java
+     * virtual machine.
+     *
+     * @return the name of the default character encoding.
+     */
+    private static String getDefaultEncoding()
+    {
+        String name = System.getProperty( "file.encoding" );
+
+        if ( name == null )
+        {
+            OutputStreamWriter out = new OutputStreamWriter( System.out );
+
+            name = out.getEncoding();
+        }
+
+        name = Charset.forName( name ).name();
+
+        return name;
+    }
+
+    /**
+     * Returns <code>true</code> if the template should be filtered and
+     * <code>false</code> otherwise.
+     *
+     * @return <code>true</code> if the template should be filtered and
+     *         <code>false</code> otherwise.
+     */
+    public boolean isFiltered()
+    {
+        return this.filtered;
+    }
+
+    /**
+     * Defines whether the template should be filtered (processed by Velocity)
+     * or not.
+     *
+     * @param filtered <code>true</code> if it should be processed by Velocity and
+     *                 <code>fales</code> otherwise.
+     */
+    public void setFiltered( boolean filtered )
+    {
+        this.filtered = filtered;
+    }
+
+    /**
+     * Returns the name of the  encoding of the template file (e.g.
+     * <code>us-ascci</code>, <code>utf-8</code>, <code>iso-8859-1</code>).
+     *
+     * @return the name of the  encoding of the template file.
+     */
+    public String getEncoding()
+    {
+        return this.encoding;
+    }
+
+    /**
+     * Sets the name of the encoding of the template file.
+     *
+     * @param encoding New value of property encoding.
+     * @throws IllegalCharsetNameException if the given charset name is illegal
+     * @throws UnsupportedCharsetException if no support for the named encoding
+     *                                     is available in this instance of the Java virtual machine
+     */
+    public void setEncoding( String encoding )
+        throws IllegalCharsetNameException, UnsupportedCharsetException
+    {
+        Charset.forName( encoding );
+
+        this.encoding = encoding;
+    }
+
+}

Propchange: maven/sandbox/trunk/archetypeng/archetype-old/src/main/java/org/apache/maven/archetype/old/descriptor/TemplateDescriptor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/sandbox/trunk/archetypeng/archetype-old/src/main/mdo/archetype.mdo
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/archetypeng/archetype-old/src/main/mdo/archetype.mdo?rev=584247&view=auto
==============================================================================
--- maven/sandbox/trunk/archetypeng/archetype-old/src/main/mdo/archetype.mdo (added)
+++ maven/sandbox/trunk/archetypeng/archetype-old/src/main/mdo/archetype.mdo Fri Oct 12 12:52:09 2007
@@ -0,0 +1,79 @@
+<?xml version="1.0"?>
+
+ <!-- START SNIPPET: modello-model -->
+
+<model>
+  <id>archetype</id>
+  <name>Archetype</name>
+  <description><![CDATA[Maven's model for the archetype descriptor.]]></description>
+  <defaults>
+    <default>
+      <key>package</key>
+      <value>org.apache.maven.archetype.model</value>
+    </default>
+  </defaults>
+  <classes>
+    <class rootElement="true" xml.tagName="archetype">
+      <name>ArchetypeModel</name>
+      <description>Describes the assembly layout and packaging.</description>
+      <version>1.0.0</version>
+      <fields>
+        <field>
+          <name>id</name>
+          <version>1.0.0</version>
+          <required>true</required>
+          <type>String</type>
+        </field>
+        <field>
+          <name>allowPartial</name>
+          <version>1.0.0</version>
+          <required>true</required>
+          <type>boolean</type>          
+        </field>
+        <field>
+          <name>sources</name>
+          <version>1.0.0</version>
+          <association>
+            <type>String</type>
+            <multiplicity>*</multiplicity>
+          </association>
+        </field>
+        <field>
+          <name>resources</name>
+          <version>1.0.0</version>
+          <association>
+            <type>String</type>
+            <multiplicity>*</multiplicity>
+          </association>
+        </field>        
+        <field>
+          <name>testSources</name>
+          <version>1.0.0</version>
+          <association>
+            <type>String</type>
+            <multiplicity>*</multiplicity>
+          </association>
+        </field>        
+        <field>
+          <name>testResources</name>
+          <version>1.0.0</version>
+          <association>
+            <type>String</type>
+            <multiplicity>*</multiplicity>
+          </association>
+        </field>                
+        <field>
+          <name>siteResources</name>
+          <version>1.0.0</version>
+          <association>
+            <type>String</type>
+            <multiplicity>*</multiplicity>
+          </association>
+        </field>                        
+      </fields>
+    </class>
+  </classes>
+</model>
+
+ <!-- END SNIPPET: modello-model -->
+

Propchange: maven/sandbox/trunk/archetypeng/archetype-old/src/main/mdo/archetype.mdo
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message