diff --git a/maven-archetype/maven-archetype-core/src/main/java/org/apache/maven/archetype/Archetype.java b/maven-archetype/maven-archetype-core/src/main/java/org/apache/maven/archetype/Archetype.java
index 6fc5e30023..6367f45ff6 100644
--- a/maven-archetype/maven-archetype-core/src/main/java/org/apache/maven/archetype/Archetype.java
+++ b/maven-archetype/maven-archetype-core/src/main/java/org/apache/maven/archetype/Archetype.java
@@ -1,13 +1,25 @@
-/*
- * Copyright (c) 2004 Your Corporation. All Rights Reserved.
- */
package org.apache.maven.archetype;
-import org.apache.maven.artifact.repository.ArtifactRepository;
+/*
+ * Copyright 2001-2004 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.Map;
import java.util.Set;
-import java.io.File;
+
+import org.apache.maven.artifact.repository.ArtifactRepository;
/**
* @author Jason van Zyl
@@ -23,6 +35,7 @@ public interface Archetype
String ARCHETYPE_POM = "pom.xml";
- void createArchetype( String archetypeId, ArtifactRepository localRepository, Set remoteRepositories, Map parameters )
+ void createArchetype( String archetypeGroupId, String archetypeArtifactId, String archetypeVersion,
+ ArtifactRepository localRepository, Set remoteRepositories, Map parameters )
throws ArchetypeNotFoundException, ArchetypeDescriptorException, ArchetypeTemplateProcessingException;
}
diff --git a/maven-archetype/maven-archetype-core/src/main/java/org/apache/maven/archetype/ArchetypeDescriptorException.java b/maven-archetype/maven-archetype-core/src/main/java/org/apache/maven/archetype/ArchetypeDescriptorException.java
index 663d0e7458..3a92210abf 100644
--- a/maven-archetype/maven-archetype-core/src/main/java/org/apache/maven/archetype/ArchetypeDescriptorException.java
+++ b/maven-archetype/maven-archetype-core/src/main/java/org/apache/maven/archetype/ArchetypeDescriptorException.java
@@ -1,8 +1,21 @@
-/*
- * Copyright (c) 2004 Your Corporation. All Rights Reserved.
- */
package org.apache.maven.archetype;
+/*
+ * Copyright 2001-2004 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 Jason van Zyl
* @version $Id$
diff --git a/maven-archetype/maven-archetype-core/src/main/java/org/apache/maven/archetype/ArchetypeNotFoundException.java b/maven-archetype/maven-archetype-core/src/main/java/org/apache/maven/archetype/ArchetypeNotFoundException.java
index adb46fc65c..dda2fb3430 100644
--- a/maven-archetype/maven-archetype-core/src/main/java/org/apache/maven/archetype/ArchetypeNotFoundException.java
+++ b/maven-archetype/maven-archetype-core/src/main/java/org/apache/maven/archetype/ArchetypeNotFoundException.java
@@ -1,8 +1,21 @@
-/*
- * Copyright (c) 2004 Your Corporation. All Rights Reserved.
- */
package org.apache.maven.archetype;
+/*
+ * Copyright 2001-2004 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 Jason van Zyl
* @version $Id$
diff --git a/maven-archetype/maven-archetype-core/src/main/java/org/apache/maven/archetype/ArchetypeTemplateProcessingException.java b/maven-archetype/maven-archetype-core/src/main/java/org/apache/maven/archetype/ArchetypeTemplateProcessingException.java
index 2a7b60ecdd..29d6cf124c 100644
--- a/maven-archetype/maven-archetype-core/src/main/java/org/apache/maven/archetype/ArchetypeTemplateProcessingException.java
+++ b/maven-archetype/maven-archetype-core/src/main/java/org/apache/maven/archetype/ArchetypeTemplateProcessingException.java
@@ -1,8 +1,21 @@
-/*
- * Copyright (c) 2004 Your Corporation. All Rights Reserved.
- */
package org.apache.maven.archetype;
+/*
+ * Copyright 2001-2004 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 Jason van Zyl
* @version $Id$
diff --git a/maven-archetype/maven-archetype-core/src/main/java/org/apache/maven/archetype/DefaultArchetype.java b/maven-archetype/maven-archetype-core/src/main/java/org/apache/maven/archetype/DefaultArchetype.java
index 517d60ee16..816d9280b7 100644
--- a/maven-archetype/maven-archetype-core/src/main/java/org/apache/maven/archetype/DefaultArchetype.java
+++ b/maven-archetype/maven-archetype-core/src/main/java/org/apache/maven/archetype/DefaultArchetype.java
@@ -1,27 +1,45 @@
package org.apache.maven.archetype;
-import org.apache.maven.archetype.descriptor.ArchetypeDescriptor;
-import org.apache.maven.archetype.descriptor.ArchetypeDescriptorBuilder;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.resolver.ArtifactResolver;
-import org.apache.maven.artifact.manager.WagonManager;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.velocity.VelocityContext;
-import org.apache.velocity.context.Context;
-import org.codehaus.plexus.util.FileUtils;
-import org.codehaus.plexus.velocity.VelocityComponent;
+/*
+ * Copyright 2001-2004 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.File;
import java.io.FileWriter;
import java.io.InputStream;
import java.io.InputStreamReader;
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;
-import java.net.URLClassLoader;
-import java.net.URL;
+
+import org.apache.maven.archetype.descriptor.ArchetypeDescriptor;
+import org.apache.maven.archetype.descriptor.ArchetypeDescriptorBuilder;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.manager.WagonManager;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.resolver.ArtifactResolutionException;
+import org.apache.maven.artifact.resolver.ArtifactResolver;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.context.Context;
+
+import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.velocity.VelocityComponent;
/**
* @author Jason van Zyl
@@ -48,20 +66,30 @@ public class DefaultArchetype
// artifactId = maven-foo-archetype
// version = latest
- public void createArchetype( String archetypeId, ArtifactRepository localRepository, Set remoteRepositories, Map parameters )
+ public void createArchetype( String archetypeGroupId, String archetypeArtifactId, String archetypeVersion,
+ ArtifactRepository localRepository, Set remoteRepositories, Map parameters )
throws ArchetypeNotFoundException, ArchetypeDescriptorException, ArchetypeTemplateProcessingException
{
- Artifact archetypeJar = wagonManager.createArtifact( "maven", "maven-archetype-" + archetypeId, "1.0-alpha-1-SNAPSHOT", "jar" );
+ // ----------------------------------------------------------------------
+ // Download the archetype
+ // ----------------------------------------------------------------------
+
+ Artifact archetypeJar =
+ wagonManager.createArtifact( archetypeGroupId, archetypeArtifactId, archetypeVersion, "jar" );
try
{
artifactResolver.resolve( archetypeJar, remoteRepositories, localRepository );
}
- catch ( Exception e )
+ catch ( ArtifactResolutionException e )
{
throw new ArchetypeNotFoundException( "Cannot download archetype.", e );
}
+ // ----------------------------------------------------------------------
+ //
+ // ----------------------------------------------------------------------
+
String outputDirectory = (String) parameters.get( "outputDirectory" );
String packageName = (String) parameters.get( "package" );
@@ -109,26 +137,32 @@ public class DefaultArchetype
context.put( key, value );
}
+ ClassLoader old = Thread.currentThread().getContextClassLoader();
+
+ Thread.currentThread().setContextClassLoader( archetypeJarLoader );
+
try
{
- ClassLoader old = Thread.currentThread().getContextClassLoader();
-
- Thread.currentThread().setContextClassLoader( archetypeJarLoader );
-
processTemplate( outputDirectory, context, ARCHETYPE_POM, null );
processSources( outputDirectory, context, descriptor.getSources(), packageName );
processSources( outputDirectory, context, descriptor.getTestSources(), packageName );
-
- Thread.currentThread().setContextClassLoader( old );
}
catch ( Exception e )
{
throw new ArchetypeTemplateProcessingException( "Error processing templates.", e );
}
+ finally
+ {
+ Thread.currentThread().setContextClassLoader( old );
+ }
}
+ // ----------------------------------------------------------------------
+ //
+ // ----------------------------------------------------------------------
+
protected void processSources( String outputDirectory, Context context, List sources, String packageName )
throws Exception
{
diff --git a/maven-archetype/maven-archetype-core/src/main/java/org/apache/maven/archetype/descriptor/ArchetypeDescriptor.java b/maven-archetype/maven-archetype-core/src/main/java/org/apache/maven/archetype/descriptor/ArchetypeDescriptor.java
index 50dab54132..06062714f4 100644
--- a/maven-archetype/maven-archetype-core/src/main/java/org/apache/maven/archetype/descriptor/ArchetypeDescriptor.java
+++ b/maven-archetype/maven-archetype-core/src/main/java/org/apache/maven/archetype/descriptor/ArchetypeDescriptor.java
@@ -1,5 +1,21 @@
package org.apache.maven.archetype.descriptor;
+/*
+ * Copyright 2001-2004 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.List;
@@ -21,7 +37,7 @@ public class ArchetypeDescriptor
resources = new ArrayList();
- testSources = new ArrayList();
+ testSources = new ArrayList();
testResources = new ArrayList();
}
diff --git a/maven-archetype/maven-archetype-core/src/main/java/org/apache/maven/archetype/descriptor/ArchetypeDescriptorBuilder.java b/maven-archetype/maven-archetype-core/src/main/java/org/apache/maven/archetype/descriptor/ArchetypeDescriptorBuilder.java
index 805e91df41..e2a72724c7 100644
--- a/maven-archetype/maven-archetype-core/src/main/java/org/apache/maven/archetype/descriptor/ArchetypeDescriptorBuilder.java
+++ b/maven-archetype/maven-archetype-core/src/main/java/org/apache/maven/archetype/descriptor/ArchetypeDescriptorBuilder.java
@@ -1,5 +1,21 @@
package org.apache.maven.archetype.descriptor;
+/*
+ * Copyright 2001-2004 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.Reader;
import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
diff --git a/maven-archetype/maven-archetype-core/src/main/java/org/apache/maven/archetype/descriptor/ArchetypeDescriptorGenerator.java b/maven-archetype/maven-archetype-core/src/main/java/org/apache/maven/archetype/descriptor/ArchetypeDescriptorGenerator.java
index 82ea116858..33b6f4004d 100644
--- a/maven-archetype/maven-archetype-core/src/main/java/org/apache/maven/archetype/descriptor/ArchetypeDescriptorGenerator.java
+++ b/maven-archetype/maven-archetype-core/src/main/java/org/apache/maven/archetype/descriptor/ArchetypeDescriptorGenerator.java
@@ -1,8 +1,21 @@
-/*
- * Copyright (c) 2004 Your Corporation. All Rights Reserved.
- */
package org.apache.maven.archetype.descriptor;
+/*
+ * Copyright 2001-2004 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.
diff --git a/maven-archetype/maven-archetype-core/src/test/java/org/apache/maven/archetype/ArchetypeTest.java b/maven-archetype/maven-archetype-core/src/test/java/org/apache/maven/archetype/ArchetypeTest.java
index 700a7a5544..cd405c25e2 100644
--- a/maven-archetype/maven-archetype-core/src/test/java/org/apache/maven/archetype/ArchetypeTest.java
+++ b/maven-archetype/maven-archetype-core/src/test/java/org/apache/maven/archetype/ArchetypeTest.java
@@ -1,5 +1,21 @@
package org.apache.maven.archetype;
+/*
+ * Copyright 2001-2004 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.PlexusTestCase;
import org.apache.maven.artifact.repository.ArtifactRepository;
@@ -34,7 +50,7 @@ public class ArchetypeTest
parameters.put( "version", "1.0-alpha-1-SNAPSHOT" );
parameters.put( "package", "org.apache.maven.quickstart" );
-
+
parameters.put( "outputDirectory",new File( getBasedir(), "target/archetype" ).getPath() );
// ----------------------------------------------------------------------
@@ -45,7 +61,7 @@ public class ArchetypeTest
Properties mavenProperties = new Properties();
- mavenProperties.load( new FileInputStream( mavenPropertiesFile ) );
+ mavenProperties.load( new FileInputStream( mavenPropertiesFile ) );
ArtifactRepository localRepository = new ArtifactRepository( "local", "file://" + mavenProperties.getProperty( "maven.repo.local" ) );
@@ -55,6 +71,7 @@ public class ArchetypeTest
remoteRepositories.add( remoteRepository );
- archetype.createArchetype( "quickstart", localRepository, remoteRepositories, parameters);
+ archetype.createArchetype( "maven", "maven-archetype-quickstart", "1.0-alpha-1-SNAPSHOT",
+ localRepository, remoteRepositories, parameters);
}
}
\ No newline at end of file
diff --git a/maven-archetype/maven-archetype-core/src/test/java/org/apache/maven/archetype/descriptor/ArchetypeDescriptorBuilderTest.java b/maven-archetype/maven-archetype-core/src/test/java/org/apache/maven/archetype/descriptor/ArchetypeDescriptorBuilderTest.java
index 614942d211..ac4aa98253 100644
--- a/maven-archetype/maven-archetype-core/src/test/java/org/apache/maven/archetype/descriptor/ArchetypeDescriptorBuilderTest.java
+++ b/maven-archetype/maven-archetype-core/src/test/java/org/apache/maven/archetype/descriptor/ArchetypeDescriptorBuilderTest.java
@@ -1,5 +1,21 @@
package org.apache.maven.archetype.descriptor;
+/*
+ * Copyright 2001-2004 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.TestCase;
import java.io.StringReader;
diff --git a/maven-archetype/maven-archetype-plugin/src/main/java/org/apache/maven/plugin/archetype/MavenArchetypePlugin.java b/maven-archetype/maven-archetype-plugin/src/main/java/org/apache/maven/plugin/archetype/MavenArchetypePlugin.java
index 391caa12be..737ee3dc23 100644
--- a/maven-archetype/maven-archetype-plugin/src/main/java/org/apache/maven/plugin/archetype/MavenArchetypePlugin.java
+++ b/maven-archetype/maven-archetype-plugin/src/main/java/org/apache/maven/plugin/archetype/MavenArchetypePlugin.java
@@ -1,5 +1,21 @@
package org.apache.maven.plugin.archetype;
+/*
+ * Copyright 2001-2004 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.Archetype;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.plugin.AbstractPlugin;
@@ -31,6 +47,33 @@ import java.util.Set;
* description=""
*
* @parameter
+ * name="archetypeGroupId"
+ * type="String"
+ * required="true"
+ * validator=""
+ * expression="#archetypeGroupId"
+ * default="maven"
+ * description=""
+ *
+ * @parameter
+ * name="archetypeArtifactId"
+ * type="String"
+ * required="true"
+ * validator=""
+ * expression="#archetypeArtifactId"
+ * default="maven"
+ * description=""
+ *
+ * @parameter
+ * name="archetypeVersion"
+ * type="String"
+ * required="true"
+ * validator=""
+ * expression="#archetypeVersion"
+ * default="maven"
+ * description=""
+ *
+ * @parameter
* name="groupId"
* type="String"
* required="true"
@@ -73,7 +116,10 @@ public class MavenArchetypePlugin
throws Exception
{
// ----------------------------------------------------------------------
- // archetypeId
+ // archetypeGroupId
+ // archetypeArtifactId
+ // archetypeVersion
+ //
// localRepository
// remoteRepository
// parameters
@@ -91,12 +137,17 @@ public class MavenArchetypePlugin
remoteRepositories.add( remoteRepository );
- String archetypeId = (String) request.getParameter( "archetypeId" );
+ String archetypeGroupId = (String) request.getParameter( "archetypeGroupId" );
+
+ String archetypeArtifactId = (String) request.getParameter( "archetypeArtifactId" );
+
+ String archetypeVersion = (String) request.getParameter( "archetypeVersion" );
Archetype archetype = (Archetype) request.getParameter( "archetype" );
request.getParameters().put( "outputDirectory", System.getProperty( "user.dir" ) );
- archetype.createArchetype( "quickstart", localRepository, remoteRepositories, request.getParameters() );
+ archetype.createArchetype( archetypeGroupId, archetypeArtifactId, archetypeVersion,
+ localRepository, remoteRepositories, request.getParameters() );
}
}