You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jv...@apache.org on 2007/11/18 04:19:31 UTC
svn commit: r596042 [2/3] - in /maven/sandbox/trunk/archetypeng: ./
archetype-old/
archetype-testing/archetype-proxy/src/main/java/org/apache/maven/archetype/download/
archetypeng-common/
archetypeng-common/src/main/java/org/apache/maven/archetype/ arc...
Added: maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/old/descriptor/ArchetypeDescriptor.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/old/descriptor/ArchetypeDescriptor.java?rev=596042&view=auto
==============================================================================
--- maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/old/descriptor/ArchetypeDescriptor.java (added)
+++ maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/old/descriptor/ArchetypeDescriptor.java Sat Nov 17 19:19:28 2007
@@ -0,0 +1,261 @@
+package org.apache.maven.archetype.old.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/archetypeng-common/src/main/java/org/apache/maven/archetype/old/descriptor/ArchetypeDescriptor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/old/descriptor/ArchetypeDescriptor.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/old/descriptor/ArchetypeDescriptorBuilder.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/old/descriptor/ArchetypeDescriptorBuilder.java?rev=596042&view=auto
==============================================================================
--- maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/old/descriptor/ArchetypeDescriptorBuilder.java (added)
+++ maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/old/descriptor/ArchetypeDescriptorBuilder.java Sat Nov 17 19:19:28 2007
@@ -0,0 +1,406 @@
+package org.apache.maven.archetype.old.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$
+ */
+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><source></code> element from the <code><sources></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>"true"</code>, or <code>false</code>
+ * if its value is <code>"false"</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><resource></code> element from the <code><resources></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><source></code> element from the <code><testSources></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>"true"</code>, or <code>false</code>
+ * if its value is <code>"false"</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><resource></code> element from the <code><testResources></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>"true"</code>, or <code>false</code>
+ * if its value is <code>"false"</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><resource></code> element from the <code><siteResources></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/archetypeng-common/src/main/java/org/apache/maven/archetype/old/descriptor/ArchetypeDescriptorBuilder.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/old/descriptor/ArchetypeDescriptorBuilder.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/old/descriptor/ArchetypeDescriptorGenerator.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/old/descriptor/ArchetypeDescriptorGenerator.java?rev=596042&view=auto
==============================================================================
--- maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/old/descriptor/ArchetypeDescriptorGenerator.java (added)
+++ maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/old/descriptor/ArchetypeDescriptorGenerator.java Sat Nov 17 19:19:28 2007
@@ -0,0 +1,28 @@
+package org.apache.maven.archetype.old.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$
+ */
+public class ArchetypeDescriptorGenerator
+{
+}
Propchange: maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/old/descriptor/ArchetypeDescriptorGenerator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/old/descriptor/ArchetypeDescriptorGenerator.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/old/descriptor/TemplateDescriptor.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/old/descriptor/TemplateDescriptor.java?rev=596042&view=auto
==============================================================================
--- maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/old/descriptor/TemplateDescriptor.java (added)
+++ maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/old/descriptor/TemplateDescriptor.java Sat Nov 17 19:19:28 2007
@@ -0,0 +1,125 @@
+package org.apache.maven.archetype.old.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/archetypeng-common/src/main/java/org/apache/maven/archetype/old/descriptor/TemplateDescriptor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/old/descriptor/TemplateDescriptor.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Modified: maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/source/WikiArchetypeDataSource.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/source/WikiArchetypeDataSource.java?rev=596042&r1=596041&r2=596042&view=diff
==============================================================================
--- maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/source/WikiArchetypeDataSource.java (original)
+++ maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/source/WikiArchetypeDataSource.java Sat Nov 17 19:19:28 2007
@@ -86,8 +86,6 @@
Pattern ptn = Pattern.compile(
"<br>\\|([-a-zA-Z0-9_. ]+)\\|([-a-zA-Z0-9_. ]+)\\|([-a-zA-Z0-9_. ]+)\\|([-a-zA-Z0-9_.:/ \\[\\],]+)\\|([^|]+)\\|" );
- System.out.println( "sb.toString() = " + sb.toString() );
-
Matcher m = ptn.matcher( sb.toString() );
while ( m.find() )
@@ -138,7 +136,7 @@
{
ArchetypeDataSourceDescriptor d = new ArchetypeDataSourceDescriptor();
- d.addParameter( URL, String.class, DEFAULT_ARCHETYPE_INVENTORY_PAGE, "The URL of the Wiki page which contains the Archetype information." );
+ d.addParameter( URL, String.class, DEFAULT_ARCHETYPE_INVENTORY_PAGE, "The URL of the Wiki page which contains the OldArchetype information." );
return d;
}
Added: maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/shared/downloader/DefaultDownloader.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/shared/downloader/DefaultDownloader.java?rev=596042&view=auto
==============================================================================
--- maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/shared/downloader/DefaultDownloader.java (added)
+++ maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/shared/downloader/DefaultDownloader.java Sat Nov 17 19:19:28 2007
@@ -0,0 +1,65 @@
+package org.apache.maven.shared.downloader;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.factory.ArtifactFactory;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
+import org.apache.maven.artifact.resolver.ArtifactResolutionException;
+import org.apache.maven.artifact.resolver.ArtifactResolver;
+
+import java.io.File;
+import java.util.List;
+
+/**
+ * @author Jason van Zyl
+ * @plexus.component
+ */
+public class DefaultDownloader
+ implements Downloader
+{
+ /**
+ * @plexus.requirement
+ */
+ private ArtifactResolver artifactResolver;
+
+ /**
+ * @plexus.requirement
+ */
+ private ArtifactFactory artifactFactory;
+
+ public File download( String groupId,
+ String artifactId,
+ String version,
+ File localRepository,
+ String[] remoteRepositories )
+ throws DownloadException, DownloadNotFoundException
+
+ {
+ return download( groupId, artifactId, version, localRepository, remoteRepositories );
+ }
+
+ public File download( String groupId,
+ String artifactId,
+ String version,
+ ArtifactRepository localRepository,
+ List remoteRepositories )
+ throws DownloadException, DownloadNotFoundException
+ {
+ Artifact artifact = artifactFactory.createArtifact( groupId, artifactId, version, Artifact.SCOPE_RUNTIME, "jar" );
+
+ try
+ {
+ artifactResolver.resolveAlways( artifact, remoteRepositories, localRepository );
+ }
+ catch ( ArtifactResolutionException e )
+ {
+ throw new DownloadException( "Error downloading.", e );
+ }
+ catch ( ArtifactNotFoundException e )
+ {
+ throw new DownloadNotFoundException( "Requested download does not exist.", e );
+ }
+
+ return artifact.getFile();
+ }
+}
Propchange: maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/shared/downloader/DefaultDownloader.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/shared/downloader/DefaultDownloader.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/shared/downloader/DownloadException.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/shared/downloader/DownloadException.java?rev=596042&view=auto
==============================================================================
--- maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/shared/downloader/DownloadException.java (added)
+++ maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/shared/downloader/DownloadException.java Sat Nov 17 19:19:28 2007
@@ -0,0 +1,24 @@
+package org.apache.maven.shared.downloader;
+
+/**
+ * @author Jason van Zyl
+ */
+public class DownloadException
+ extends Exception
+{
+ public DownloadException( String string )
+ {
+ super( string );
+ }
+
+ public DownloadException( String string,
+ Throwable throwable )
+ {
+ super( string, throwable );
+ }
+
+ public DownloadException( Throwable throwable )
+ {
+ super( throwable );
+ }
+}
Propchange: maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/shared/downloader/DownloadException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/shared/downloader/DownloadException.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/shared/downloader/DownloadNotFoundException.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/shared/downloader/DownloadNotFoundException.java?rev=596042&view=auto
==============================================================================
--- maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/shared/downloader/DownloadNotFoundException.java (added)
+++ maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/shared/downloader/DownloadNotFoundException.java Sat Nov 17 19:19:28 2007
@@ -0,0 +1,24 @@
+package org.apache.maven.shared.downloader;
+
+/**
+ * @author Jason van Zyl
+ */
+public class DownloadNotFoundException
+ extends Exception
+{
+ public DownloadNotFoundException( String string )
+ {
+ super( string );
+ }
+
+ public DownloadNotFoundException( String string,
+ Throwable throwable )
+ {
+ super( string, throwable );
+ }
+
+ public DownloadNotFoundException( Throwable throwable )
+ {
+ super( throwable );
+ }
+}
Propchange: maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/shared/downloader/DownloadNotFoundException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/shared/downloader/DownloadNotFoundException.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/shared/downloader/Downloader.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/shared/downloader/Downloader.java?rev=596042&view=auto
==============================================================================
--- maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/shared/downloader/Downloader.java (added)
+++ maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/shared/downloader/Downloader.java Sat Nov 17 19:19:28 2007
@@ -0,0 +1,28 @@
+package org.apache.maven.shared.downloader;
+
+import org.apache.maven.artifact.repository.ArtifactRepository;
+
+import java.io.File;
+import java.util.List;
+
+/**
+ * @author Jason van Zyl
+ */
+public interface Downloader
+{
+ String ROLE = Downloader.class.getName();
+
+ public File download( String groupId,
+ String artifactId,
+ String version,
+ File localRepository,
+ String[] remoteRepositories )
+ throws DownloadException, DownloadNotFoundException;
+
+ public File download( String groupId,
+ String artifactId,
+ String version,
+ ArtifactRepository localRepository,
+ List remoteRepositories )
+ throws DownloadException, DownloadNotFoundException;
+}
Propchange: maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/shared/downloader/Downloader.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/shared/downloader/Downloader.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
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=596042&r1=596041&r2=596042&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 Nov 17 19:19:28 2007
@@ -79,7 +79,16 @@
Properties p = PropertyUtils.loadProperties( propertyFile );
- MavenProject mavenProject = builder.buildWithDependencies( projectFile, localRepository, null );
+ MavenProject mavenProject = null;
+
+ try
+ {
+ mavenProject = builder.buildWithDependencies( projectFile, localRepository, null );
+ }
+ catch( Exception e )
+ {
+ e.printStackTrace();
+ }
FilesetArchetypeCreator instance = (FilesetArchetypeCreator) lookup( ArchetypeCreator.class.getName(), "fileset" );
Modified: maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/java/org/apache/maven/archetype/generator/DefaultArchetypeGeneratorTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/java/org/apache/maven/archetype/generator/DefaultArchetypeGeneratorTest.java?rev=596042&r1=596041&r2=596042&view=diff
==============================================================================
--- maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/java/org/apache/maven/archetype/generator/DefaultArchetypeGeneratorTest.java (original)
+++ maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/java/org/apache/maven/archetype/generator/DefaultArchetypeGeneratorTest.java Sat Nov 17 19:19:28 2007
@@ -139,10 +139,14 @@
request.setProperties( additionalProperties );
ArchetypeGenerationResult result=new ArchetypeGenerationResult();
+
instance.generateArchetype(request, result);
+
if ( result.getCause() != null )
{
- fail( "No exception may be thrown" );
+ fail( "No exception may be thrown: " + result.getCause().getMessage() );
+
+ result.getCause().printStackTrace();
}
String template;
Added: maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/java/org/apache/maven/archetype/old/ArchetypeTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/java/org/apache/maven/archetype/old/ArchetypeTest.java?rev=596042&view=auto
==============================================================================
--- maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/java/org/apache/maven/archetype/old/ArchetypeTest.java (added)
+++ maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/java/org/apache/maven/archetype/old/ArchetypeTest.java Sat Nov 17 19:19:28 2007
@@ -0,0 +1,320 @@
+package org.apache.maven.archetype.old;
+
+/*
+ * 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.Artifact;
+import org.apache.maven.artifact.factory.ArtifactFactory;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.DefaultArtifactRepository;
+import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
+import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
+import org.apache.maven.artifact.resolver.ArtifactResolutionException;
+import org.apache.maven.artifact.resolver.ArtifactResolver;
+import org.apache.maven.model.Model;
+import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.context.Context;
+import org.codehaus.plexus.PlexusTestCase;
+import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+import org.codehaus.plexus.velocity.VelocityComponent;
+import org.dom4j.DocumentException;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
+ * @version $Id$
+ */
+public class ArchetypeTest
+ extends PlexusTestCase
+{
+ private OldArchetype archetype;
+
+ public void testArchetype()
+ throws Exception
+ {
+ FileUtils.deleteDirectory( getTestFile( "target/quickstart" ) );
+
+ Map parameters = new HashMap();
+
+ parameters.put( "name", "jason" );
+
+ parameters.put( "groupId", "maven" );
+
+ parameters.put( "artifactId", "quickstart" );
+
+ parameters.put( "version", "1.0-alpha-1-SNAPSHOT" );
+
+ parameters.put( "package", "org.apache.maven.quickstart" );
+
+ parameters.put( "basedir", getTestFile( "target" ).getAbsolutePath() );
+
+ // ----------------------------------------------------------------------
+ // This needs to be encapsulated in a maven test case.
+ // ----------------------------------------------------------------------
+
+ ArtifactRepositoryLayout layout =
+ (ArtifactRepositoryLayout) container.lookup( ArtifactRepositoryLayout.ROLE, "legacy" );
+
+ String mavenRepoLocal = getTestFile( "target/local-repository" ).toURL().toString();
+
+ ArtifactRepository localRepository = new DefaultArtifactRepository( "local", mavenRepoLocal, layout );
+
+ List remoteRepositories = new ArrayList();
+
+ String mavenRepoRemote = getTestFile( "src/test/repository" ).toURL().toString();
+
+ ArtifactRepository remoteRepository = new DefaultArtifactRepository( "remote", mavenRepoRemote, layout );
+
+ remoteRepositories.add( remoteRepository );
+
+ String archetypeGroupId = "org.apache.maven.archetypes";
+ String archetypeArtifactId = "maven-archetype-quickstart";
+ String archetypeVersion = "1.0-alpha-1-SNAPSHOT";
+ archetype.createArchetype( archetypeGroupId, archetypeArtifactId, archetypeVersion, localRepository,
+ remoteRepositories, parameters );
+
+ // ----------------------------------------------------------------------
+ // Set up the Velocity context
+ // ----------------------------------------------------------------------
+
+ Context context = new VelocityContext();
+
+ for ( Iterator iterator = parameters.keySet().iterator(); iterator.hasNext(); )
+ {
+ String key = (String) iterator.next();
+
+ Object value = parameters.get( key );
+
+ context.put( key, value );
+ }
+
+ // ----------------------------------------------------------------------
+ // Validate POM generation
+ // ----------------------------------------------------------------------
+
+ ArtifactFactory artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.class.getName() );
+ Artifact archetypeArtifact = artifactFactory.createArtifact( archetypeGroupId, archetypeArtifactId,
+ archetypeVersion, Artifact.SCOPE_RUNTIME, "jar" );
+
+ StringWriter writer = new StringWriter();
+
+ ClassLoader old = Thread.currentThread().getContextClassLoader();
+
+ Thread.currentThread().setContextClassLoader(
+ getContextClassloader( archetypeArtifact, localRepository, remoteRepositories ) );
+
+ try
+ {
+ VelocityComponent velocity = (VelocityComponent) lookup( VelocityComponent.class.getName() );
+
+ velocity.getEngine().mergeTemplate( OldArchetype.ARCHETYPE_RESOURCES + "/" + OldArchetype.ARCHETYPE_POM, context,
+ writer );
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader( old );
+ }
+
+ Model generatedModel, templateModel;
+ try
+ {
+ StringReader strReader = new StringReader( writer.toString() );
+
+ MavenXpp3Reader reader = new MavenXpp3Reader();
+
+ templateModel = reader.read( strReader );
+ }
+ catch ( IOException e )
+ {
+ throw new ArchetypeTemplateProcessingException( "Error reading template POM", e );
+ }
+
+ File artifactDir = getTestFile( "target", (String) parameters.get( "artifactId" ) );
+ File pomFile = getTestFile( artifactDir.getAbsolutePath(), OldArchetype.ARCHETYPE_POM );
+
+ try
+ {
+ FileReader pomReader = new FileReader( pomFile );
+
+ MavenXpp3Reader reader = new MavenXpp3Reader();
+
+ generatedModel = reader.read( pomReader );
+ }
+ catch ( IOException e )
+ {
+ throw new ArchetypeTemplateProcessingException( "Error reading generated POM", e );
+ }
+ catch ( XmlPullParserException e )
+ {
+ throw new ArchetypeTemplateProcessingException( "Error reading generated POM", e );
+ }
+ assertEquals( "Generated POM ArtifactId is not equivalent to expected result.", generatedModel.getArtifactId(),
+ templateModel.getArtifactId() );
+ assertEquals( "Generated POM GroupId is not equivalent to expected result.", generatedModel.getGroupId(),
+ templateModel.getGroupId() );
+ assertEquals( "Generated POM Id is not equivalent to expected result.", generatedModel.getId(),
+ templateModel.getId() );
+ assertEquals( "Generated POM Version is not equivalent to expected result.", generatedModel.getVersion(),
+ templateModel.getVersion() );
+ assertEquals( "Generated POM Packaging is not equivalent to expected result.", generatedModel.getPackaging(),
+ templateModel.getPackaging() );
+ assertEquals( "Generated POM Developers is not equivalent to expected result.", generatedModel.getDevelopers(),
+ templateModel.getDevelopers() );
+ assertEquals( "Generated POM Scm is not equivalent to expected result.", generatedModel.getScm(),
+ templateModel.getScm() );
+ }
+
+ // Gets the classloader for this artifact's file.
+ private ClassLoader getContextClassloader( Artifact archetypeArtifact, ArtifactRepository localRepository,
+ List remoteRepositories )
+ throws Exception
+ {
+ ArtifactResolver artifactResolver = (ArtifactResolver) lookup( ArtifactResolver.class.getName() );
+ try
+ {
+ artifactResolver.resolve( archetypeArtifact, remoteRepositories, localRepository );
+ }
+ catch ( ArtifactResolutionException e )
+ {
+ throw new ArchetypeDescriptorException( "Error attempting to download archetype: " + e.getMessage(), e );
+ }
+ catch ( ArtifactNotFoundException e )
+ {
+ throw new ArchetypeNotFoundException( "OldArchetype does not exist: " + e.getMessage(), e );
+ }
+
+ URLClassLoader archetypeJarLoader;
+ try
+ {
+ URL[] urls = new URL[1];
+
+ urls[0] = archetypeArtifact.getFile().toURL();
+
+ archetypeJarLoader = new URLClassLoader( urls );
+ }
+ catch ( IOException e )
+ {
+ throw new ArchetypeDescriptorException(
+ "Error reading the " + OldArchetype.ARCHETYPE_DESCRIPTOR + " descriptor.", e );
+ }
+
+ return archetypeJarLoader;
+ }
+
+ public void testAddModuleToParentPOM()
+ throws DocumentException, IOException, ArchetypeTemplateProcessingException
+ {
+ String pom = "<project>\n <packaging>pom</packaging>\n</project>";
+
+ StringWriter out = new StringWriter();
+ assertTrue( DefaultOldArchetype.addModuleToParentPom( "myArtifactId1", new StringReader( pom ), out ) );
+
+ assertEquals( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<project>\n" +
+ " <packaging>pom</packaging>\n" + " <modules>\n" + " <module>myArtifactId1</module>\n" +
+ " </modules>\n" + "</project>", out.toString() );
+
+ pom = "<project>\n <modelVersion>4.0.0</modelVersion>\n" + " <packaging>pom</packaging>\n" + "</project>";
+
+ out = new StringWriter();
+ assertTrue( DefaultOldArchetype.addModuleToParentPom( "myArtifactId2", new StringReader( pom ), out ) );
+
+ assertEquals( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<project>\n" +
+ " <modelVersion>4.0.0</modelVersion>\n" + " <packaging>pom</packaging>\n" + " <modules>\n" +
+ " <module>myArtifactId2</module>\n" + " </modules>\n" + "</project>", out.toString() );
+
+ pom = "<project><modelVersion>4.0.0</modelVersion>\n" + " <packaging>pom</packaging>\n" + " <modules>\n" +
+ " </modules>\n" + "</project>";
+
+ out = new StringWriter();
+ assertTrue( DefaultOldArchetype.addModuleToParentPom( "myArtifactId3", new StringReader( pom ), out ) );
+
+ assertEquals( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project><modelVersion>4.0.0</modelVersion>\n" +
+ " <packaging>pom</packaging>\n" + " <modules>\n" + " <module>myArtifactId3</module>\n" +
+ " </modules>\n" + "</project>", out.toString() );
+
+ pom = "<project><modelVersion>4.0.0</modelVersion>\n" + " <packaging>pom</packaging>\n" + " <modules>\n" +
+ " <module>myArtifactId3</module>\n" + " </modules>\n" + "</project>";
+
+ out = new StringWriter();
+ assertTrue( DefaultOldArchetype.addModuleToParentPom( "myArtifactId4", new StringReader( pom ), out ) );
+
+ assertEquals( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project><modelVersion>4.0.0</modelVersion>\n" +
+ " <packaging>pom</packaging>\n" + " <modules>\n" + " <module>myArtifactId3</module>\n" +
+ " <module>myArtifactId4</module>\n" + " </modules>\n" + "</project>", out.toString() );
+
+ pom = "<project><modelVersion>4.0.0</modelVersion>\n" + " <packaging>pom</packaging>\n" + " <modules>\n" +
+ " <module>myArtifactId3</module>\n" + " </modules>\n" + "</project>";
+
+ out = new StringWriter();
+ assertFalse( DefaultOldArchetype.addModuleToParentPom( "myArtifactId3", new StringReader( pom ), out ) );
+
+ // empty means unchanged
+ assertEquals( "", out.toString() );
+ }
+
+ public void testAddModuleToParentPOMNoPackaging()
+ throws DocumentException, IOException
+ {
+ try
+ {
+ String pom = "<project>\n</project>";
+ DefaultOldArchetype.addModuleToParentPom( "myArtifactId1", new StringReader( pom ), new StringWriter() );
+ fail( "Should fail to add a module to a JAR packaged project" );
+ }
+ catch ( ArchetypeTemplateProcessingException e )
+ {
+ // great!
+ assertTrue( true );
+ }
+ }
+
+ public void testAddModuleToParentPOMJarPackaging()
+ throws DocumentException, IOException
+ {
+ try
+ {
+ String pom = "<project>\n <packaging>jar</packaging>\n</project>";
+ DefaultOldArchetype.addModuleToParentPom( "myArtifactId1", new StringReader( pom ), new StringWriter() );
+ fail( "Should fail to add a module to a JAR packaged project" );
+ }
+ catch ( ArchetypeTemplateProcessingException e )
+ {
+ // great!
+ assertTrue( true );
+ }
+ }
+
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+ archetype = (OldArchetype) lookup( OldArchetype.ROLE );
+ }
+}
Propchange: maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/java/org/apache/maven/archetype/old/ArchetypeTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/java/org/apache/maven/archetype/old/ArchetypeTest.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/java/org/apache/maven/archetype/old/descriptor/ArchetypeDescriptorBuilderTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/java/org/apache/maven/archetype/old/descriptor/ArchetypeDescriptorBuilderTest.java?rev=596042&view=auto
==============================================================================
--- maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/java/org/apache/maven/archetype/old/descriptor/ArchetypeDescriptorBuilderTest.java (added)
+++ maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/java/org/apache/maven/archetype/old/descriptor/ArchetypeDescriptorBuilderTest.java Sat Nov 17 19:19:28 2007
@@ -0,0 +1,246 @@
+package org.apache.maven.archetype.old.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 junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+
+import java.io.IOException;
+import java.io.StringReader;
+
+/**
+ * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
+ * @version $Id$
+ */
+public class ArchetypeDescriptorBuilderTest
+ extends TestCase
+{
+ public ArchetypeDescriptorBuilderTest( String str )
+ {
+ super( str );
+ }
+
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite();
+ suite.addTest( new ArchetypeDescriptorBuilderTest( "testBuilder" ) );
+ suite.addTest( new ArchetypeDescriptorBuilderTest( "testBuild" ) );
+ return suite;
+ }
+
+ public void testBuilder()
+ throws Exception
+ {
+ String xml = "<archetype>" + " <id>standard</id>" + " <sources>" + " <source>source0</source>" +
+ " <source>source1</source>" + " </sources>" + " <resources>" + " <resource>resource0</resource>" +
+ " <resource>resource1</resource>" + " </resources>" + " <testSources>" +
+ " <source>testSource0</source>" + " <source>testSource1</source>" + " </testSources>" +
+ " <testResources>" + " <resource>testResource0</resource>" + " <resource>testResource1</resource>" +
+ " </testResources>" + "</archetype>";
+
+ ArchetypeDescriptorBuilder builder = new ArchetypeDescriptorBuilder();
+
+ ArchetypeDescriptor descriptor = builder.build( new StringReader( xml ) );
+
+ assertEquals( "standard", descriptor.getId() );
+
+ assertEquals( 2, descriptor.getSources().size() );
+
+ assertEquals( "source0", descriptor.getSources().get( 0 ) );
+
+ assertNotNull( descriptor.getSourceDescriptor( "source0" ) );
+
+ assertEquals( true, descriptor.getSourceDescriptor( "source0" ).isFiltered() );
+
+ assertNotNull( descriptor.getSourceDescriptor( "source0" ).getEncoding() );
+
+ assertEquals( "source1", descriptor.getSources().get( 1 ) );
+
+ assertNotNull( descriptor.getSourceDescriptor( "source1" ) );
+
+ assertEquals( true, descriptor.getSourceDescriptor( "source1" ).isFiltered() );
+
+ assertNotNull( descriptor.getSourceDescriptor( "source1" ).getEncoding() );
+
+ assertEquals( 2, descriptor.getResources().size() );
+
+ assertEquals( "resource0", descriptor.getResources().get( 0 ) );
+
+ assertNotNull( descriptor.getResourceDescriptor( "resource0" ) );
+
+ assertEquals( true, descriptor.getResourceDescriptor( "resource0" ).isFiltered() );
+
+ assertNotNull( descriptor.getResourceDescriptor( "resource0" ).getEncoding() );
+
+ assertEquals( "resource1", descriptor.getResources().get( 1 ) );
+
+ assertNotNull( descriptor.getResourceDescriptor( "resource1" ) );
+
+ assertEquals( true, descriptor.getResourceDescriptor( "resource1" ).isFiltered() );
+
+ assertNotNull( descriptor.getResourceDescriptor( "resource1" ).getEncoding() );
+
+ assertEquals( 2, descriptor.getTestSources().size() );
+
+ assertEquals( "testSource0", descriptor.getTestSources().get( 0 ) );
+
+ assertNotNull( descriptor.getTestSourceDescriptor( "testSource0" ) );
+
+ assertEquals( true, descriptor.getTestSourceDescriptor( "testSource0" ).isFiltered() );
+
+ assertNotNull( descriptor.getTestSourceDescriptor( "testSource0" ).getEncoding() );
+
+ assertEquals( "testSource1", descriptor.getTestSources().get( 1 ) );
+
+ assertNotNull( descriptor.getTestSourceDescriptor( "testSource1" ) );
+
+ assertEquals( true, descriptor.getTestSourceDescriptor( "testSource1" ).isFiltered() );
+
+ assertNotNull( descriptor.getTestSourceDescriptor( "testSource1" ).getEncoding() );
+
+ assertEquals( 2, descriptor.getTestResources().size() );
+
+ assertEquals( "testResource0", descriptor.getTestResources().get( 0 ) );
+
+ assertNotNull( descriptor.getTestResourceDescriptor( "testResource0" ) );
+
+ assertEquals( true, descriptor.getTestResourceDescriptor( "testResource0" ).isFiltered() );
+
+ assertNotNull( descriptor.getTestResourceDescriptor( "testResource0" ).getEncoding() );
+
+ assertEquals( "testResource1", descriptor.getTestResources().get( 1 ) );
+
+ assertNotNull( descriptor.getTestResourceDescriptor( "testResource1" ) );
+
+ assertEquals( true, descriptor.getTestResourceDescriptor( "testResource1" ).isFiltered() );
+
+ assertNotNull( descriptor.getTestResourceDescriptor( "testResource1" ).getEncoding() );
+ }
+
+ public void testBuild()
+ throws IOException, XmlPullParserException
+ {
+ String xml = "<archetype>" + " <id>standard</id>" + " <sources>" +
+ " <source encoding=\"utf-8\">source0</source>" + " <source encoding=\"utf-8\">source1</source>" +
+ " </sources>" + " <resources>" + " <resource filtered=\"false\">resource0</resource>" +
+ " <resource encoding=\"iso-8859-1\">resource1</resource>" + " </resources>" + " <testSources>" +
+ " <source encoding=\"utf-8\">testSource0</source>" +
+ " <source encoding=\"utf-8\">testSource1</source>" + " </testSources>" + " <testResources>" +
+ " <resource encoding=\"us-ascii\">testResource0</resource>" +
+ " <resource filtered=\"false\">testResource1</resource>" + " </testResources>" + " <siteResources>" +
+ " <resource filtered=\"false\">siteResource0</resource>" +
+ " <resource encoding=\"utf-16\">siteResource1</resource>" + " </siteResources>" + "</archetype>";
+
+ ArchetypeDescriptorBuilder builder = new ArchetypeDescriptorBuilder();
+
+ ArchetypeDescriptor descriptor = builder.build( new StringReader( xml ) );
+
+ assertEquals( "standard", descriptor.getId() );
+
+ assertEquals( 2, descriptor.getSources().size() );
+
+ assertEquals( "source0", descriptor.getSources().get( 0 ) );
+
+ assertNotNull( descriptor.getSourceDescriptor( "source0" ) );
+
+ assertEquals( true, descriptor.getSourceDescriptor( "source0" ).isFiltered() );
+
+ assertEquals( "utf-8", descriptor.getSourceDescriptor( "source0" ).getEncoding() );
+
+ assertEquals( "source1", descriptor.getSources().get( 1 ) );
+
+ assertNotNull( descriptor.getSourceDescriptor( "source1" ) );
+
+ assertEquals( true, descriptor.getSourceDescriptor( "source1" ).isFiltered() );
+
+ assertEquals( "utf-8", descriptor.getSourceDescriptor( "source1" ).getEncoding() );
+
+ assertEquals( 2, descriptor.getResources().size() );
+
+ assertEquals( "resource0", descriptor.getResources().get( 0 ) );
+
+ assertNotNull( descriptor.getResourceDescriptor( "resource0" ) );
+
+ assertEquals( false, descriptor.getResourceDescriptor( "resource0" ).isFiltered() );
+
+ assertNotNull( descriptor.getResourceDescriptor( "resource0" ).getEncoding() );
+
+ assertEquals( "resource1", descriptor.getResources().get( 1 ) );
+
+ assertNotNull( descriptor.getResourceDescriptor( "resource1" ) );
+
+ assertEquals( true, descriptor.getResourceDescriptor( "resource1" ).isFiltered() );
+
+ assertEquals( "iso-8859-1", descriptor.getResourceDescriptor( "resource1" ).getEncoding() );
+
+ assertEquals( 2, descriptor.getTestSources().size() );
+
+ assertEquals( "testSource0", descriptor.getTestSources().get( 0 ) );
+
+ assertNotNull( descriptor.getTestSourceDescriptor( "testSource0" ) );
+
+ assertEquals( true, descriptor.getTestSourceDescriptor( "testSource0" ).isFiltered() );
+
+ assertEquals( "utf-8", descriptor.getTestSourceDescriptor( "testSource0" ).getEncoding() );
+
+ assertEquals( "testSource1", descriptor.getTestSources().get( 1 ) );
+
+ assertNotNull( descriptor.getTestSourceDescriptor( "testSource1" ) );
+
+ assertEquals( true, descriptor.getTestSourceDescriptor( "testSource1" ).isFiltered() );
+
+ assertEquals( "utf-8", descriptor.getTestSourceDescriptor( "testSource1" ).getEncoding() );
+
+ assertEquals( 2, descriptor.getTestResources().size() );
+
+ assertEquals( "testResource0", descriptor.getTestResources().get( 0 ) );
+
+ assertNotNull( descriptor.getTestResourceDescriptor( "testResource0" ) );
+
+ assertEquals( true, descriptor.getTestResourceDescriptor( "testResource0" ).isFiltered() );
+
+ assertEquals( "us-ascii", descriptor.getTestResourceDescriptor( "testResource0" ).getEncoding() );
+
+ assertEquals( "testResource1", descriptor.getTestResources().get( 1 ) );
+
+ assertNotNull( descriptor.getTestResourceDescriptor( "testResource1" ) );
+
+ assertEquals( false, descriptor.getTestResourceDescriptor( "testResource1" ).isFiltered() );
+
+ assertNotNull( descriptor.getTestResourceDescriptor( "testResource1" ).getEncoding() );
+
+ assertEquals( 2, descriptor.getSiteResources().size() );
+
+ assertEquals( "siteResource0", descriptor.getSiteResources().get( 0 ) );
+
+ assertNotNull( descriptor.getSiteResourceDescriptor( "siteResource0" ) );
+
+ assertEquals( false, descriptor.getSiteResourceDescriptor( "siteResource0" ).isFiltered() );
+
+ assertNotNull( descriptor.getSiteResourceDescriptor( "siteResource0" ).getEncoding() );
+
+ assertEquals( "siteResource1", descriptor.getSiteResources().get( 1 ) );
+
+ assertNotNull( descriptor.getSiteResourceDescriptor( "siteResource1" ) );
+
+ assertEquals( true, descriptor.getSiteResourceDescriptor( "siteResource1" ).isFiltered() );
+
+ assertEquals( "utf-16", descriptor.getSiteResourceDescriptor( "siteResource1" ).getEncoding() );
+ }
+}
Propchange: maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/java/org/apache/maven/archetype/old/descriptor/ArchetypeDescriptorBuilderTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/java/org/apache/maven/archetype/old/descriptor/ArchetypeDescriptorBuilderTest.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Modified: maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/java/org/apache/maven/archetype/test/ArchetypeGenerationTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/java/org/apache/maven/archetype/test/ArchetypeGenerationTest.java?rev=596042&r1=596041&r2=596042&view=diff
==============================================================================
--- maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/java/org/apache/maven/archetype/test/ArchetypeGenerationTest.java (original)
+++ maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/java/org/apache/maven/archetype/test/ArchetypeGenerationTest.java Sat Nov 17 19:19:28 2007
@@ -56,11 +56,11 @@
.toURI().toURL().toExternalForm());
List archetypes = archetype.getAvailableArchetypes( catalogProperties );
System.err.println("archetypes => "+archetypes);
- // Here I am just grabbing a Archetype but in a UI you would take the Archetype objects and present
+ // Here I am just grabbing a OldArchetype but in a UI you would take the OldArchetype objects and present
// them to the user.
Archetype selection = (Archetype) archetypes.get( archetypes.size() -1 );
-System.err.println("Selected Archetype = "+selection);
+System.err.println("Selected OldArchetype = "+selection);
// Now you will present a dialog, or whatever, and grab the following values.
String groupId = "com.mycompany";
@@ -71,7 +71,7 @@
String packageName = "org.mycompany.app";
- // With the selected Archetype and the parameters you can create a generation request as follows:
+ // With the selected OldArchetype and the parameters you can create a generation request as follows:
ArchetypeGenerationRequest agr = new ArchetypeGenerationRequest( selection )
.setOutputDirectory( new File( getBasedir(),
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=596042&r1=596041&r2=596042&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 Nov 17 19:19:28 2007
@@ -31,18 +31,6 @@
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;
-import java.io.FileOutputStream;
-import java.io.FileWriter;
-import java.io.OutputStream;
-import java.io.Writer;
-import java.util.Properties;
-import org.apache.maven.archiver.MavenArchiveConfiguration;
-import org.codehaus.cargo.container.Container;
-import org.codehaus.cargo.container.EmbeddedLocalContainer;
-import org.codehaus.cargo.container.configuration.Configuration;
import org.codehaus.cargo.container.deployable.DeployableType;
import org.codehaus.cargo.container.deployable.WAR;
import org.codehaus.cargo.container.deployer.Deployer;
@@ -50,12 +38,19 @@
import org.codehaus.cargo.container.jetty.Jetty6xEmbeddedLocalDeployer;
import org.codehaus.cargo.container.jetty.Jetty6xEmbeddedStandaloneLocalConfiguration;
import org.codehaus.cargo.container.property.ServletPropertySet;
-import org.codehaus.cargo.generic.configuration.ConfigurationFactory;
-import org.codehaus.cargo.generic.configuration.DefaultConfigurationFactory;
import org.codehaus.cargo.generic.deployable.DefaultDeployableFactory;
import org.codehaus.cargo.generic.deployable.DeployableFactory;
+import org.codehaus.plexus.PlexusTestCase;
+import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.StringUtils;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.OutputStream;
+import java.io.Writer;
+import java.util.Properties;
+
/** @author Jason van Zyl */
public class ArchetyperRoundtripTest
@@ -129,13 +124,14 @@
File generatedArchetypePom = new File( generatedArchetypeDirectory, "pom.xml" );
MavenProject generatedArchetypeProject = projectBuilder.build( generatedArchetypePom,
localRepository, null );
+
File archetypeDirectory = new File( generatedArchetypeDirectory, "src/main/resources" );
- File archetypeArchive = archetype.archiveArchetype(
- archetypeDirectory, generatedArchetypeProject,
+
+ File archetypeArchive = archetype.archiveArchetype( archetypeDirectory,
new File( generatedArchetypeProject.getBuild().getDirectory() ),
- generatedArchetypeProject.getBuild().getFinalName(),
- new MavenArchiveConfiguration() );
- File archetypeInRepository = new File( localRepository.getBasedir(),
+ generatedArchetypeProject.getBuild().getFinalName() );
+
+ File archetypeInRepository = new File( localRepository.getBasedir(),
StringUtils.replace(
generatedArchetypeProject.getGroupId(), ".",
"/" ) + "/" +
@@ -174,7 +170,7 @@
setPackage( "com.mycompany.myapp" ).setOutputDirectory( outputDirectory ).
setLocalRepository( localRepository ).setArchetypeRepository( "http://127.0.0.1:18881/" );
ArchetypeGenerationResult generationResult = archetype.generateProjectFromArchetype( agr );
-
+
if ( generationResult.getCause() != null )
{
fail( generationResult.getCause().getMessage() );
Added: maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/repository/org.apache.maven.archetypes/jars/maven-archetype-quickstart-1.0-alpha-1-SNAPSHOT.jar
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/repository/org.apache.maven.archetypes/jars/maven-archetype-quickstart-1.0-alpha-1-SNAPSHOT.jar?rev=596042&view=auto
==============================================================================
Binary file - no diff available.
Propchange: maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/repository/org.apache.maven.archetypes/jars/maven-archetype-quickstart-1.0-alpha-1-SNAPSHOT.jar
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/repository/org.apache.maven.archetypes/poms/maven-archetype-quickstart-1.0-alpha-1-SNAPSHOT.pom
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/repository/org.apache.maven.archetypes/poms/maven-archetype-quickstart-1.0-alpha-1-SNAPSHOT.pom?rev=596042&view=auto
==============================================================================
--- maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/repository/org.apache.maven.archetypes/poms/maven-archetype-quickstart-1.0-alpha-1-SNAPSHOT.pom (added)
+++ maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/repository/org.apache.maven.archetypes/poms/maven-archetype-quickstart-1.0-alpha-1-SNAPSHOT.pom Sat Nov 17 19:19:28 2007
@@ -0,0 +1,26 @@
+<!--
+ ~ 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.
+ -->
+
+<project>
+ <parent>
+ <artifactId>maven-archetypes</artifactId>
+ <groupId>org.apache.maven.archetypes</groupId>
+ <version>1.0-alpha-1-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>maven-archetype-quickstart</artifactId>
+ <version>1.0-alpha-1-SNAPSHOT</version>
+</project>
\ No newline at end of file
Added: maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/repository/org.apache.maven.archetypes/poms/maven-archetype-quickstart-1.0-alpha-1-SNAPSHOT.version.txt
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/repository/org.apache.maven.archetypes/poms/maven-archetype-quickstart-1.0-alpha-1-SNAPSHOT.version.txt?rev=596042&view=auto
==============================================================================
--- maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/repository/org.apache.maven.archetypes/poms/maven-archetype-quickstart-1.0-alpha-1-SNAPSHOT.version.txt (added)
+++ maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/repository/org.apache.maven.archetypes/poms/maven-archetype-quickstart-1.0-alpha-1-SNAPSHOT.version.txt Sat Nov 17 19:19:28 2007
@@ -0,0 +1 @@
+1.0-alpha-1-SNAPSHOT
\ No newline at end of file
Propchange: maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/repository/org.apache.maven.archetypes/poms/maven-archetype-quickstart-1.0-alpha-1-SNAPSHOT.version.txt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/repository/org.apache.maven.archetypes/poms/maven-archetype-quickstart-1.0-alpha-1-SNAPSHOT.version.txt
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/repository/org.apache.maven.archetypes/poms/maven-archetypes-1.0-alpha-1-SNAPSHOT.pom
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/repository/org.apache.maven.archetypes/poms/maven-archetypes-1.0-alpha-1-SNAPSHOT.pom?rev=596042&view=auto
==============================================================================
--- maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/repository/org.apache.maven.archetypes/poms/maven-archetypes-1.0-alpha-1-SNAPSHOT.pom (added)
+++ maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/repository/org.apache.maven.archetypes/poms/maven-archetypes-1.0-alpha-1-SNAPSHOT.pom Sat Nov 17 19:19:28 2007
@@ -0,0 +1,33 @@
+<!--
+ ~ 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.
+ -->
+
+<model>
+ <parent>
+ <artifactId>maven-archetype</artifactId>
+ <groupId>org.apache.maven</groupId>
+ <version>1.0-alpha-1-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.maven.archetypes</groupId>
+ <artifactId>maven-archetypes</artifactId>
+ <packaging>pom</packaging>
+ <version>1.0-alpha-1-SNAPSHOT</version>
+ <modules>
+ <module>maven-archetype-mojo</module>
+ <module>maven-archetype-quickstart</module>
+ <module>maven-archetype-webapp</module>
+ </modules>
+</model>
Added: maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/repository/org.apache.maven.archetypes/poms/maven-archetypes-1.0-alpha-1-SNAPSHOT.version.txt
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/repository/org.apache.maven.archetypes/poms/maven-archetypes-1.0-alpha-1-SNAPSHOT.version.txt?rev=596042&view=auto
==============================================================================
--- maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/repository/org.apache.maven.archetypes/poms/maven-archetypes-1.0-alpha-1-SNAPSHOT.version.txt (added)
+++ maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/repository/org.apache.maven.archetypes/poms/maven-archetypes-1.0-alpha-1-SNAPSHOT.version.txt Sat Nov 17 19:19:28 2007
@@ -0,0 +1 @@
+1.0-alpha-1-SNAPSHOT
\ No newline at end of file
Propchange: maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/repository/org.apache.maven.archetypes/poms/maven-archetypes-1.0-alpha-1-SNAPSHOT.version.txt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/repository/org.apache.maven.archetypes/poms/maven-archetypes-1.0-alpha-1-SNAPSHOT.version.txt
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/resources/xdocs/index.xml
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/resources/xdocs/index.xml?rev=596042&view=auto
==============================================================================
--- maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/resources/xdocs/index.xml (added)
+++ maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/resources/xdocs/index.xml Sat Nov 17 19:19:28 2007
@@ -0,0 +1,47 @@
+<?xml version="1.0"?>
+
+<!--
+ ~ 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.
+ -->
+
+<document>
+ <properties>
+ <title>Maven</title>
+ <author email="jason@zenplex.com">Jason van Zyl</author>
+ </properties>
+ <body>
+ <section name="Maven">
+ <p>
+ Maven is a Java project management and project comprehension tool. Maven
+ is based on the concept of a project object model (POM) in that all the
+ artifacts produced by Maven are a result of consulting a well defined
+ model for your project. Builds, documentation, source metrics, and source
+ cross-references are all controlled by your POM. Look here to see the
+ full list of Maven's
+ <a href="features.html">
+ <b>features</b>
+ </a>
+ .
+ </p>
+
+ <source>
+ public class Foo
+ {
+ }
+ </source>
+
+ </section>
+ </body>
+</document>
Propchange: maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/resources/xdocs/index.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/trunk/archetypeng/archetypeng-common/src/test/resources/xdocs/index.xml
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"