diff --git a/maven-archetype/maven-archetype-core/pom.xml b/maven-archetype/maven-archetype-core/pom.xml
index 01b1bb07d0..ba55db4877 100644
--- a/maven-archetype/maven-archetype-core/pom.xml
+++ b/maven-archetype/maven-archetype-core/pom.xml
@@ -11,25 +11,20 @@
plexus
- plexus-container-default
+ plexus-utils
1.0-alpha-2
- jar
- compile
plexus
plexus-velocity
1.0
- jar
- compile
org.apache.maven
maven-artifact
2.0-SNAPSHOT
- jar
- compile
+
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 f7224197ed..436d273c1f 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
@@ -17,15 +17,14 @@ package org.apache.maven.archetype;
*/
import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.codehaus.plexus.PlexusTestCase;
import java.io.File;
-import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.Properties;
/**
* @author Jason van Zyl
@@ -51,27 +50,28 @@ public class ArchetypeTest
parameters.put( "package", "org.apache.maven.quickstart" );
- parameters.put( "outputDirectory",new File( getBasedir(), "target/archetype" ).getPath() );
+ parameters.put( "outputDirectory", new File( getBasedir(), "target/archetype" ).getPath() );
// ----------------------------------------------------------------------
// This needs to be encapsulated in a maven test case.
// ----------------------------------------------------------------------
- File mavenPropertiesFile = new File( System.getProperty( "user.home" ), ".m2/maven.properties" );
+ ArtifactRepositoryLayout layout = (ArtifactRepositoryLayout) container.lookup( ArtifactRepositoryLayout.ROLE,
+ "default" );
- Properties mavenProperties = new Properties();
-
- mavenProperties.load( new FileInputStream( mavenPropertiesFile ) );
-
- ArtifactRepository localRepository = new ArtifactRepository( "local", "file://" + mavenProperties.getProperty( "maven.repo.local" ) );
+ String mavenRepoLocal = getTestFile( "target/local-repository" ).toURL().toString();
+ ArtifactRepository localRepository = new ArtifactRepository( "local", mavenRepoLocal, layout );
List remoteRepositories = new ArrayList();
- ArtifactRepository remoteRepository = new ArtifactRepository( "remote", "http://repo1.maven.org" );
+ String mavenRepoRemote = getTestFile( "src/test/repository" ).toURL().toString();
+ ArtifactRepository remoteRepository = new ArtifactRepository( "remote", mavenRepoRemote, layout );
remoteRepositories.add( remoteRepository );
- archetype.createArchetype( "maven", "maven-archetype-quickstart", "1.0-alpha-1-SNAPSHOT",
- localRepository, remoteRepositories, parameters);
+ archetype.createArchetype( "org.apache.maven.archetypes", "maven-archetype-quickstart", "1.0-alpha-1-SNAPSHOT",
+ localRepository, remoteRepositories, parameters );
+
+ // TODO: validate output
}
-}
\ No newline at end of file
+}
diff --git a/maven-archetype/maven-archetype-plugin/pom.xml b/maven-archetype/maven-archetype-plugin/pom.xml
index 890a0e4ed2..de6c077c8f 100644
--- a/maven-archetype/maven-archetype-plugin/pom.xml
+++ b/maven-archetype/maven-archetype-plugin/pom.xml
@@ -1,7 +1,7 @@
maven-plugin-parent
- org.apache.maven
+ org.apache.maven.plugins
2.0-SNAPSHOT
4.0.0
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 04a5a765cf..e388506d31 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,7 +1,7 @@
package org.apache.maven.plugin.archetype;
/*
- * Copyright 2001-2004 The Apache Software Foundation.
+ * Copyright 2001-2005 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.
@@ -19,95 +19,81 @@ package org.apache.maven.plugin.archetype;
import org.apache.maven.archetype.Archetype;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.plugin.AbstractPlugin;
+import org.apache.maven.plugin.PluginExecutionException;
import org.apache.maven.plugin.PluginExecutionRequest;
import org.apache.maven.plugin.PluginExecutionResponse;
-import java.util.ArrayList;
+import java.io.File;
import java.util.List;
/**
* @goal create
- *
* @description Builds archetype containers.
- *
- * @parameter
- * name="archetype"
- * type="org.apache.maven.archetype.Archetype"
- * required="true"
- * validator=""
- * expression="#component.org.apache.maven.archetype.Archetype"
- * description=""
- *
- * @parameter
- * name="localRepository"
- * type="org.apache.maven.artifact.ArtifactRepository"
- * required="true"
- * validator=""
- * expression="#localRepository"
- * 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"
- * validator=""
- * expression="#groupId"
- * default="maven"
- * description=""
- *
- * @parameter
- * name="artifactId"
- * type="String"
- * required="true"
- * validator=""
- * expression="#artifactId"
- * default="quickstart"
- * description=""
- *
- * @parameter
- * name="version"
- * type="String"
- * required="true"
- * validator=""
- * expression="#version"
- * default="1.0"
- * description=""
- *
- * @parameter
- * name="package"
- * type="String"
- * required="true"
- * validator=""
- * expression="#package"
- * default="org.apache.maven.quickstart"
- * description=""
+ * @parameter name="archetype"
+ * type="org.apache.maven.archetype.Archetype"
+ * required="true"
+ * validator=""
+ * expression="#component.org.apache.maven.archetype.Archetype"
+ * description=""
+ * @parameter name="localRepository"
+ * type="org.apache.maven.artifact.ArtifactRepository"
+ * required="true"
+ * validator=""
+ * expression="#localRepository"
+ * description=""
+ * @parameter name="archetypeGroupId"
+ * type="String"
+ * required="true"
+ * validator=""
+ * expression="#archetypeGroupId"
+ * default="org.apache.maven.archetypes"
+ * description=""
+ * @parameter name="archetypeArtifactId"
+ * type="String"
+ * required="true"
+ * validator=""
+ * expression="#archetypeArtifactId"
+ * default="maven-archetype-quickstart"
+ * description=""
+ * @parameter name="archetypeVersion"
+ * type="String"
+ * required="true"
+ * validator=""
+ * expression="#archetypeVersion"
+ * default="1.0-alpha-1-SNAPSHOT"
+ * description=""
+ * @parameter name="groupId"
+ * type="String"
+ * required="true"
+ * validator=""
+ * expression="#groupId"
+ * description=""
+ * @parameter name="artifactId"
+ * type="String"
+ * required="true"
+ * validator=""
+ * expression="#artifactId"
+ * description=""
+ * @parameter name="version"
+ * type="String"
+ * required="true"
+ * validator=""
+ * expression="#version"
+ * default="1.0-SNAPSHOT"
+ * description=""
+ * @parameter name="package"
+ * type="String"
+ * required="true"
+ * validator=""
+ * expression="#package"
+ * default="com.mycompany.app"
+ * description=""
+ * @parameter name="remoteRepositories"
+ * type="java.util.List"
+ * required="true"
+ * validator=""
+ * expression="#project.remoteArtifactRepositories"
+ * description=""
*/
public class MavenArchetypePlugin
extends AbstractPlugin
@@ -115,6 +101,10 @@ public class MavenArchetypePlugin
public void execute( PluginExecutionRequest request, PluginExecutionResponse response )
throws Exception
{
+ // TODO: prompt for missing values
+ // TODO: use new plugin type
+ // TODO: configurable license
+
// ----------------------------------------------------------------------
// archetypeGroupId
// archetypeArtifactId
@@ -125,17 +115,10 @@ public class MavenArchetypePlugin
// parameters
// ----------------------------------------------------------------------
- // When there is no project how do we get the local repository and remote repos.
- // The local repository will always be present but the remote is in the POM except
- // for the super POM ...
-
ArtifactRepository localRepository = (ArtifactRepository) request.getParameter( "localRepository" );
- List remoteRepositories = new ArrayList();
-
- ArtifactRepository remoteRepository = new ArtifactRepository( "remote", "http://repo1.maven.org" );
-
- remoteRepositories.add( remoteRepository );
+ // From the super POM
+ List remoteRepositories = (List) request.getParameter( "remoteRepositories" );
String archetypeGroupId = (String) request.getParameter( "archetypeGroupId" );
@@ -145,9 +128,19 @@ public class MavenArchetypePlugin
Archetype archetype = (Archetype) request.getParameter( "archetype" );
- request.getParameters().put( "outputDirectory", System.getProperty( "user.dir" ) );
+ String basedir = System.getProperty( "user.dir" );
- archetype.createArchetype( archetypeGroupId, archetypeArtifactId, archetypeVersion,
- localRepository, remoteRepositories, request.getParameters() );
+ // TODO: allow this to be configured
+ File outputDirectory = new File( basedir, (String) request.getParameter( "artifactId" ) );
+ request.getParameters().put( "outputDirectory", outputDirectory.getAbsolutePath() );
+
+ if ( outputDirectory.exists() )
+ {
+ throw new PluginExecutionException(
+ outputDirectory.getName() + " already exists - please run from a clean directory" );
+ }
+
+ archetype.createArchetype( archetypeGroupId, archetypeArtifactId, archetypeVersion, localRepository,
+ remoteRepositories, request.getParameters() );
}
}
diff --git a/maven-archetype/maven-archetypes/maven-archetype-mojo/pom.xml b/maven-archetype/maven-archetypes/maven-archetype-mojo/pom.xml
index ea2668cfa9..84b3e6f6c8 100644
--- a/maven-archetype/maven-archetypes/maven-archetype-mojo/pom.xml
+++ b/maven-archetype/maven-archetypes/maven-archetype-mojo/pom.xml
@@ -1,7 +1,7 @@
maven-archetypes
- org.apache.maven
+ org.apache.maven.archetypes
1.0-alpha-1-SNAPSHOT
4.0.0
diff --git a/maven-archetype/maven-archetypes/maven-archetype-mojo/src/main/resources/archetype-resources/pom.xml b/maven-archetype/maven-archetypes/maven-archetype-mojo/src/main/resources/archetype-resources/pom.xml
index 66fc9a8937..6391a6e4fa 100644
--- a/maven-archetype/maven-archetypes/maven-archetype-mojo/src/main/resources/archetype-resources/pom.xml
+++ b/maven-archetype/maven-archetypes/maven-archetype-mojo/src/main/resources/archetype-resources/pom.xml
@@ -2,15 +2,20 @@
4.0.0
${groupId}
${artifactId}
- jar
+ maven-plugin
${version}
+
+ org.apache.maven
+ maven-plugin
+ 2.0-SNAPSHOT
+
+
junit
junit
3.8.1
- jar
- compile
+ test
diff --git a/maven-archetype/maven-archetypes/maven-archetype-mojo/src/main/resources/archetype-resources/src/main/java/MyMojo.java b/maven-archetype/maven-archetypes/maven-archetype-mojo/src/main/resources/archetype-resources/src/main/java/MyMojo.java
index 1bc102f323..91f8edee22 100644
--- a/maven-archetype/maven-archetypes/maven-archetype-mojo/src/main/resources/archetype-resources/src/main/java/MyMojo.java
+++ b/maven-archetype/maven-archetypes/maven-archetype-mojo/src/main/resources/archetype-resources/src/main/java/MyMojo.java
@@ -1,78 +1,84 @@
package $package;
+/*
+ * Copyright 2001-2005 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.plugin.AbstractPlugin;
-import org.apache.maven.plugin.PluginExecutionRequest;
-import org.apache.maven.plugin.PluginExecutionResponse;
+import org.apache.maven.plugin.PluginExecutionException;
import java.io.File;
import java.io.FileWriter;
+import java.io.IOException;
/**
* @goal touch
*
* @phase process-sources
*
- * @description Goal which cleans the build
+ * @description Goal which touches a timestamp file
*
* @parameter
* name="outputDirectory"
- * type="String"
- * required="true"
- * validator=""
- * expression="#project.build.directory"
- * description=""
- *
- * @parameter
- * name="basedirAlignmentDirectory"
* type="java.io.File"
* required="true"
* validator=""
- * expression="target/test-basedir-alignment"
+ * expression="#project.build.directory"
* description=""
*/
public class MyMojo
extends AbstractPlugin
{
- private static final int DELETE_RETRY_SLEEP_MILLIS = 10;
+ private String outputDirectory;
- public void execute( PluginExecutionRequest request, PluginExecutionResponse response )
- throws Exception
+ public void execute()
+ throws PluginExecutionException
{
- String outputDirectory = (String) request.getParameter( "outputDirectory" );
-
File f = new File( outputDirectory );
-
+
if ( !f.exists() )
{
f.mkdirs();
}
-
- File touch = new File( f, "touch.txt" );
-
- FileWriter w = new FileWriter( touch );
-
- w.write( "touch.txt" );
-
- w.close();
-
- // This parameter should be aligned to the basedir as the parameter type is specified
- // as java.io.File
-
- String basedirAlignmentDirectory = (String) request.getParameter( "basedirAlignmentDirectory" );
- f = new File( basedirAlignmentDirectory );
-
- if ( !f.exists() )
+ File touch = new File( f, "touch.txt" );
+
+ FileWriter w = null;
+ try
{
- f.mkdirs();
- }
-
- touch = new File( f, "touch.txt" );
-
- w = new FileWriter( touch );
-
- w.write( "touch.txt" );
-
- w.close();
+ w = new FileWriter( touch );
+
+ w.write( "touch.txt" );
+ }
+ catch ( IOException e )
+ {
+ throw new PluginExecutionException( "Error creating file " + touch );
+ }
+ finally
+ {
+ if ( w != null )
+ {
+ try
+ {
+ w.close();
+ }
+ catch ( IOException e )
+ {
+ // ignore
+ }
+ }
+ }
}
}
diff --git a/maven-archetype/maven-archetypes/maven-archetype-quickstart/pom.xml b/maven-archetype/maven-archetypes/maven-archetype-quickstart/pom.xml
index eb5303a2f7..8992f03764 100644
--- a/maven-archetype/maven-archetypes/maven-archetype-quickstart/pom.xml
+++ b/maven-archetype/maven-archetypes/maven-archetype-quickstart/pom.xml
@@ -1,7 +1,7 @@
maven-archetypes
- org.apache.maven
+ org.apache.maven.archetypes
1.0-alpha-1-SNAPSHOT
4.0.0
diff --git a/maven-archetype/maven-archetypes/maven-archetype-quickstart/src/main/resources/archetype-resources/pom.xml b/maven-archetype/maven-archetypes/maven-archetype-quickstart/src/main/resources/archetype-resources/pom.xml
index 922308fb18..937beaf160 100644
--- a/maven-archetype/maven-archetypes/maven-archetype-quickstart/src/main/resources/archetype-resources/pom.xml
+++ b/maven-archetype/maven-archetypes/maven-archetype-quickstart/src/main/resources/archetype-resources/pom.xml
@@ -9,8 +9,7 @@
junit
junit
3.8.1
- jar
- compile
+ test
-
\ No newline at end of file
+
diff --git a/maven-archetype/maven-archetypes/maven-archetype-quickstart/src/main/resources/archetype-resources/src/main/java/App.java b/maven-archetype/maven-archetypes/maven-archetype-quickstart/src/main/resources/archetype-resources/src/main/java/App.java
index cd141876f3..c09c3ce4fa 100644
--- a/maven-archetype/maven-archetypes/maven-archetype-quickstart/src/main/resources/archetype-resources/src/main/java/App.java
+++ b/maven-archetype/maven-archetypes/maven-archetype-quickstart/src/main/resources/archetype-resources/src/main/java/App.java
@@ -3,8 +3,6 @@ package $package;
/**
* Hello world!
*
- * @author Jason van Zyl
- *
*/
public class App
{
diff --git a/maven-archetype/maven-archetypes/maven-archetype-quickstart/src/main/resources/archetype-resources/src/test/java/AbstractTestCase.java b/maven-archetype/maven-archetypes/maven-archetype-quickstart/src/main/resources/archetype-resources/src/test/java/AbstractTestCase.java
deleted file mode 100644
index 00e85ad63d..0000000000
--- a/maven-archetype/maven-archetypes/maven-archetype-quickstart/src/main/resources/archetype-resources/src/test/java/AbstractTestCase.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package $package;
-
-import java.io.File;
-
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- * Abstract base class for test cases.
- *
- * @author Jason van Zyl
- */
-public abstract class AbstractTestCase
- extends TestCase
-{
- /**
- * Basedir for all file I/O. Important when running tests from
- * the reactor.
- */
- public String basedir = System.getProperty("basedir");
-
- /**
- * Constructor.
- */
- public AbstractTestCase(String testName)
- {
- super(testName);
- }
-
- /**
- * Get test input file.
- *
- * @param path Path to test input file.
- */
- public String getTestFile(String path)
- {
- return new File(basedir,path).getAbsolutePath();
- }
-}
-
diff --git a/maven-archetype/maven-archetypes/maven-archetype-quickstart/src/main/resources/archetype-resources/src/test/java/AppTest.java b/maven-archetype/maven-archetypes/maven-archetype-quickstart/src/main/resources/archetype-resources/src/test/java/AppTest.java
index a2cbc83927..bd9bf4ef3c 100644
--- a/maven-archetype/maven-archetypes/maven-archetype-quickstart/src/main/resources/archetype-resources/src/test/java/AppTest.java
+++ b/maven-archetype/maven-archetypes/maven-archetype-quickstart/src/main/resources/archetype-resources/src/test/java/AppTest.java
@@ -6,11 +6,9 @@ import junit.framework.TestSuite;
/**
* Unit test for simple App.
- *
- * @author Jason van Zyl
*/
public class AppTest
- extends AbstractTestCase
+ extends TestCase
{
/**
* Create the test case
@@ -35,6 +33,6 @@ public class AppTest
*/
public void testApp()
{
- assertEquals( "maven kicks ass", "maven kicks ass" );
+ assertTrue( true );
}
}
diff --git a/maven-archetype/maven-archetypes/maven-archetype-webapp/pom.xml b/maven-archetype/maven-archetypes/maven-archetype-webapp/pom.xml
index 24dc86cb64..308757f61a 100644
--- a/maven-archetype/maven-archetypes/maven-archetype-webapp/pom.xml
+++ b/maven-archetype/maven-archetypes/maven-archetype-webapp/pom.xml
@@ -1,7 +1,7 @@
maven-archetypes
- org.apache.maven
+ org.apache.maven.archetypes
1.0-alpha-1-SNAPSHOT
4.0.0
diff --git a/maven-archetype/maven-archetypes/maven-archetype-webapp/src/main/resources/archetype-resources/pom.xml b/maven-archetype/maven-archetypes/maven-archetype-webapp/src/main/resources/archetype-resources/pom.xml
index 463370b85b..c2b678f73b 100644
--- a/maven-archetype/maven-archetypes/maven-archetype-webapp/src/main/resources/archetype-resources/pom.xml
+++ b/maven-archetype/maven-archetypes/maven-archetype-webapp/src/main/resources/archetype-resources/pom.xml
@@ -2,22 +2,25 @@
4.0.0
${groupId}
${artifactId}
- jar
+ war
${version}
junit
junit
3.8.1
- jar
- compile
+ test
-
-
- src/main/webapp
-
-
+
+
+ maven-war-plugin
+ 1.0-alpha-1
+
+ ${artifactId}
+
+
+
-
\ No newline at end of file
+
diff --git a/maven-archetype/maven-archetypes/pom.xml b/maven-archetype/maven-archetypes/pom.xml
index 61d9c65162..dd9195e081 100644
--- a/maven-archetype/maven-archetypes/pom.xml
+++ b/maven-archetype/maven-archetypes/pom.xml
@@ -5,7 +5,13 @@
1.0-alpha-1-SNAPSHOT
4.0.0
+ org.apache.maven.archetypes
maven-archetypes
pom
1.0-alpha-1-SNAPSHOT
+
+ maven-archetype-mojo
+ maven-archetype-quickstart
+ maven-archetype-webapp
+
diff --git a/maven-archetype/pom.xml b/maven-archetype/pom.xml
index 9c03531b84..8172b9ff13 100644
--- a/maven-archetype/pom.xml
+++ b/maven-archetype/pom.xml
@@ -8,4 +8,9 @@
maven-archetype
pom
1.0-alpha-1-SNAPSHOT
+
+ maven-archetype-core
+ maven-archetype-plugin
+ maven-archetypes
+