not releasing this module
git-svn-id: https://svn.apache.org/repos/asf/maven/archetype/tags/maven-archetype-parent-2@541545 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/maven-archetype/maven-archetype-core/pom.xml b/maven-archetype/maven-archetype-core/pom.xml
deleted file mode 100644
index de563b9..0000000
--- a/maven-archetype/maven-archetype-core/pom.xml
+++ /dev/null
@@ -1,72 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>org.apache.maven.archetype</groupId>
- <artifactId>maven-archetype</artifactId>
- <version>1.0-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.apache.maven.archetype</groupId>
- <artifactId>maven-archetype-core</artifactId>
- <name>Maven Archetype Core</name>
- <dependencies>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-velocity</artifactId>
- <version>1.1.2</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-file</artifactId>
- <version>1.0-alpha-6</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- <version>1.1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-model</artifactId>
- <version>2.0</version>
- </dependency>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-container-default</artifactId>
- <version>1.0-alpha-9</version>
- </dependency>
- <dependency>
- <groupId>dom4j</groupId>
- <artifactId>dom4j</artifactId>
- <version>1.6.1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven.shared</groupId>
- <artifactId>maven-downloader</artifactId>
- <version>1.0</version>
- </dependency>
- </dependencies>
-</project>
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
deleted file mode 100644
index 63d9c74..0000000
--- a/maven-archetype/maven-archetype-core/src/main/java/org/apache/maven/archetype/Archetype.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package org.apache.maven.archetype;
-
-/*
- * Copyright 2004-2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import org.apache.maven.artifact.repository.ArtifactRepository;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
- * @version $Id$
- */
-public interface Archetype
-{
- String ROLE = Archetype.class.getName();
-
- String ARCHETYPE_DESCRIPTOR = "META-INF/maven/archetype.xml";
-
- String ARCHETYPE_OLD_DESCRIPTOR = "META-INF/archetype.xml";
-
- String ARCHETYPE_RESOURCES = "archetype-resources";
-
- // TODO: delete this, it probably should be project.getFile instead
- String ARCHETYPE_POM = "pom.xml";
-
- void createArchetype( String archetypeGroupId, String archetypeArtifactId, String archetypeVersion,
- ArtifactRepository localRepository, List remoteRepositories, Map parameters )
- throws ArchetypeNotFoundException, ArchetypeDescriptorException, ArchetypeTemplateProcessingException;
-}
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
deleted file mode 100644
index 564e8ed..0000000
--- a/maven-archetype/maven-archetype-core/src/main/java/org/apache/maven/archetype/ArchetypeDescriptorException.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package org.apache.maven.archetype;
-
-/*
- * Copyright 2004-2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
- * @version $Id$
- */
-public class ArchetypeDescriptorException
- extends Exception
-{
- public ArchetypeDescriptorException( String message )
- {
- super( message );
- }
-
- public ArchetypeDescriptorException( Throwable cause )
- {
- super( cause );
- }
-
- public ArchetypeDescriptorException( String message, Throwable cause )
- {
- super( message, cause );
- }
-}
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
deleted file mode 100644
index 7e901ab..0000000
--- a/maven-archetype/maven-archetype-core/src/main/java/org/apache/maven/archetype/ArchetypeNotFoundException.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package org.apache.maven.archetype;
-
-/*
- * Copyright 2004-2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
- * @version $Id$
- */
-public class ArchetypeNotFoundException
- extends Exception
-{
- public ArchetypeNotFoundException( String message )
- {
- super( message );
- }
-
- public ArchetypeNotFoundException( Throwable cause )
- {
- super( cause );
- }
-
- public ArchetypeNotFoundException( String message, Throwable cause )
- {
- super( message, cause );
- }
-}
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
deleted file mode 100644
index 20e2067..0000000
--- a/maven-archetype/maven-archetype-core/src/main/java/org/apache/maven/archetype/ArchetypeTemplateProcessingException.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package org.apache.maven.archetype;
-
-/*
- * Copyright 2004-2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
- * @version $Id$
- */
-public class ArchetypeTemplateProcessingException
- extends Exception
-{
- public ArchetypeTemplateProcessingException( String message )
- {
- super( message );
- }
-
- public ArchetypeTemplateProcessingException( Throwable cause )
- {
- super( cause );
- }
-
- public ArchetypeTemplateProcessingException( String message, Throwable cause )
- {
- super( message, cause );
- }
-}
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
deleted file mode 100644
index abf730e..0000000
--- a/maven-archetype/maven-archetype-core/src/main/java/org/apache/maven/archetype/DefaultArchetype.java
+++ /dev/null
@@ -1,955 +0,0 @@
-package org.apache.maven.archetype;
-
-/*
- * Copyright 2004-2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import org.apache.maven.archetype.descriptor.ArchetypeDescriptor;
-import org.apache.maven.archetype.descriptor.ArchetypeDescriptorBuilder;
-import org.apache.maven.archetype.descriptor.TemplateDescriptor;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.model.Build;
-import org.apache.maven.model.Model;
-import org.apache.maven.model.Parent;
-import org.apache.maven.model.Resource;
-import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
-import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
-import org.apache.maven.shared.downloader.DownloadException;
-import org.apache.maven.shared.downloader.DownloadNotFoundException;
-import org.apache.maven.shared.downloader.Downloader;
-import org.apache.velocity.VelocityContext;
-import org.apache.velocity.context.Context;
-import org.codehaus.plexus.logging.AbstractLogEnabled;
-import org.codehaus.plexus.util.FileUtils;
-import org.codehaus.plexus.util.IOUtil;
-import org.codehaus.plexus.util.StringUtils;
-import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
-import org.codehaus.plexus.velocity.VelocityComponent;
-import org.dom4j.Document;
-import org.dom4j.DocumentException;
-import org.dom4j.Element;
-import org.dom4j.Node;
-import org.dom4j.io.SAXReader;
-import org.dom4j.io.XMLWriter;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.Reader;
-import java.io.StringWriter;
-import java.io.Writer;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * @plexus.component
- * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
- * @version $Id$
- */
-public class DefaultArchetype
- extends AbstractLogEnabled
- implements Archetype
-{
- private static final String DEFAULT_TEST_RESOURCE_DIR = "/src/test/resources";
-
- private static final String DEFAULT_TEST_SOURCE_DIR = "/src/test/java";
-
- private static final String DEFAULT_RESOURCE_DIR = "/src/main/resources";
-
- private static final String DEFAULT_SOURCE_DIR = "/src/main/java";
-
- // ----------------------------------------------------------------------
- // Components
- // ----------------------------------------------------------------------
-
- /**
- * @plexus.requirement
- */
- private VelocityComponent velocity;
-
- /**
- * @plexus.requirement
- */
- private Downloader downloader;
-
- // ----------------------------------------------------------------------
- // Implementation
- // ----------------------------------------------------------------------
-
- // groupId = maven
- // artifactId = maven-foo-archetype
- // version = latest
-
- public void createArchetype( String archetypeGroupId,
- String archetypeArtifactId,
- String archetypeVersion,
- ArtifactRepository localRepository,
- List remoteRepositories,
- Map parameters )
- throws ArchetypeNotFoundException, ArchetypeDescriptorException, ArchetypeTemplateProcessingException
- {
- // ----------------------------------------------------------------------
- // Download the archetype
- // ----------------------------------------------------------------------
-
- File archetype;
-
- try
- {
- archetype = downloader.download( archetypeGroupId, archetypeArtifactId, archetypeVersion, localRepository,
- remoteRepositories );
- }
- catch ( DownloadException e )
- {
- throw new ArchetypeDescriptorException( "Error attempting to download archetype.", e );
- }
- catch ( DownloadNotFoundException e )
- {
- throw new ArchetypeNotFoundException( "Archetype does not exist.", e );
- }
-
- // ---------------------------------------------------------------------
- // Get Logger and display all parameters used
- // ---------------------------------------------------------------------
- if ( getLogger().isInfoEnabled() )
- {
- if ( !parameters.isEmpty() )
- {
- getLogger().info( "----------------------------------------------------------------------------" );
-
- getLogger().info( "Using following parameters for creating Archetype: " + archetypeArtifactId + ":" +
- archetypeVersion );
-
- getLogger().info( "----------------------------------------------------------------------------" );
-
- Set keys = parameters.keySet();
-
- Iterator it = keys.iterator();
-
- while ( it.hasNext() )
- {
- String parameterName = (String) it.next();
-
- String parameterValue = (String) parameters.get( parameterName );
-
- getLogger().info( "Parameter: " + parameterName + ", Value: " + parameterValue );
- }
- }
- else
- {
- getLogger().info( "No Parameters found for creating Archetype" );
- }
- }
-
- // ----------------------------------------------------------------------
- // Load the descriptor
- // ----------------------------------------------------------------------
-
- ArchetypeDescriptorBuilder builder = new ArchetypeDescriptorBuilder();
-
- ArchetypeDescriptor descriptor;
-
- URLClassLoader archetypeJarLoader;
-
- try
- {
- URL[] urls = new URL[1];
-
- urls[0] = archetype.toURL();
-
- archetypeJarLoader = new URLClassLoader( urls );
-
- InputStream is = getStream( ARCHETYPE_DESCRIPTOR, archetypeJarLoader );
-
- if ( is == null )
- {
- is = getStream( ARCHETYPE_OLD_DESCRIPTOR, archetypeJarLoader );
-
- if ( is == null )
- {
- throw new ArchetypeDescriptorException(
- "The " + ARCHETYPE_DESCRIPTOR + " descriptor cannot be found." );
- }
- }
-
- descriptor = builder.build( new InputStreamReader( is ) );
- }
- catch ( IOException e )
- {
- throw new ArchetypeDescriptorException( "Error reading the " + ARCHETYPE_DESCRIPTOR + " descriptor.", e );
- }
- catch ( XmlPullParserException e )
- {
- throw new ArchetypeDescriptorException( "Error reading the " + ARCHETYPE_DESCRIPTOR + " descriptor.", e );
- }
-
- // ----------------------------------------------------------------------
- //
- // ----------------------------------------------------------------------
-
- String basedir = (String) parameters.get( "basedir" );
-
- String artifactId = (String) parameters.get( "artifactId" );
-
- File parentPomFile = new File( basedir, ARCHETYPE_POM );
-
- File outputDirectoryFile;
-
- boolean creating;
- File pomFile;
- if ( parentPomFile.exists() && descriptor.isAllowPartial() && artifactId == null )
- {
- outputDirectoryFile = new File( basedir );
- creating = false;
- pomFile = parentPomFile;
- }
- else
- {
- if ( artifactId == null )
- {
- throw new ArchetypeTemplateProcessingException(
- "Artifact ID must be specified when creating a new project from an archetype." );
- }
-
- outputDirectoryFile = new File( basedir, artifactId );
- creating = true;
-
- if ( outputDirectoryFile.exists() )
- {
- if ( descriptor.isAllowPartial() )
- {
- creating = false;
- }
- else
- {
- throw new ArchetypeTemplateProcessingException(
- outputDirectoryFile.getName() + " already exists - please run from a clean directory" );
- }
- }
-
- pomFile = new File( outputDirectoryFile, ARCHETYPE_POM );
- }
-
- if ( creating )
- {
- if ( parameters.get( "groupId" ) == null )
- {
- throw new ArchetypeTemplateProcessingException(
- "Group ID must be specified when creating a new project from an archetype." );
- }
-
- if ( parameters.get( "version" ) == null )
- {
- throw new ArchetypeTemplateProcessingException(
- "Version must be specified when creating a new project from an archetype." );
- }
- }
-
- String outputDirectory = outputDirectoryFile.getAbsolutePath();
-
- String packageName = (String) parameters.get( "package" );
-
- // ----------------------------------------------------------------------
- // Set up the Velocity context
- // ----------------------------------------------------------------------
-
- Context context = new VelocityContext();
-
- context.put( "package", packageName );
-
- for ( Iterator iterator = parameters.keySet().iterator(); iterator.hasNext(); )
- {
- String key = (String) iterator.next();
-
- Object value = parameters.get( key );
-
- context.put( key, value );
- }
-
- // ----------------------------------------------------------------------
- // Process the templates
- // ----------------------------------------------------------------------
-
- ClassLoader old = Thread.currentThread().getContextClassLoader();
-
- Thread.currentThread().setContextClassLoader( archetypeJarLoader );
-
- Model parentModel = null;
- if ( creating )
- {
- if ( parentPomFile.exists() )
- {
- FileReader fileReader = null;
-
- try
- {
- fileReader = new FileReader( parentPomFile );
- MavenXpp3Reader reader = new MavenXpp3Reader();
- parentModel = reader.read( fileReader );
- if ( !"pom".equals( parentModel.getPackaging() ) )
- {
- throw new ArchetypeTemplateProcessingException(
- "Unable to add module to the current project as it is not of packaging type 'pom'" );
- }
- }
- catch ( IOException e )
- {
- throw new ArchetypeTemplateProcessingException( "Unable to read parent POM", e );
- }
- catch ( XmlPullParserException e )
- {
- throw new ArchetypeTemplateProcessingException( "Unable to read parent POM", e );
- }
- finally
- {
- IOUtil.close( fileReader );
- }
-
- parentModel.getModules().add( artifactId );
- }
- }
-
- try
- {
- processTemplates( pomFile, outputDirectory, context, descriptor, packageName, parentModel );
- }
- finally
- {
- Thread.currentThread().setContextClassLoader( old );
- }
-
- if ( parentModel != null )
- {
-/*
- // TODO: would be nice to just write out with the xpp3 writer again, except that it loses a bunch of info and
- // reformats, so the module is just baked in as a string instead.
- FileWriter fileWriter = null;
-
- try
- {
- fileWriter = new FileWriter( parentPomFile );
-
- MavenXpp3Writer writer = new MavenXpp3Writer();
- writer.write( fileWriter, parentModel );
- }
- catch ( IOException e )
- {
- throw new ArchetypeTemplateProcessingException( "Unable to rewrite parent POM", e );
- }
- finally
- {
- IOUtil.close( fileWriter );
- }
-*/
- FileReader fileReader = null;
- boolean added;
- StringWriter w = new StringWriter();
- try
- {
- fileReader = new FileReader( parentPomFile );
- added = addModuleToParentPom( artifactId, fileReader, w );
- }
- catch ( IOException e )
- {
- throw new ArchetypeTemplateProcessingException( "Unable to rewrite parent POM", e );
- }
- catch ( DocumentException e )
- {
- throw new ArchetypeTemplateProcessingException( "Unable to rewrite parent POM", e );
- }
- finally
- {
- IOUtil.close( fileReader );
- }
-
- if ( added )
- {
- try
- {
- FileUtils.fileWrite( parentPomFile.getAbsolutePath(), w.toString() );
- }
- catch ( IOException e )
- {
- throw new ArchetypeTemplateProcessingException( "Unable to rewrite parent POM", e );
- }
- }
- }
-
- // ----------------------------------------------------------------------
- // Log message on Archetype creation
- // ----------------------------------------------------------------------
- if ( getLogger().isInfoEnabled() )
- {
- getLogger().info( "Archetype created in dir: " + outputDirectory );
- }
-
- }
-
- static boolean addModuleToParentPom( String artifactId,
- Reader fileReader,
- Writer fileWriter )
- throws DocumentException, IOException, ArchetypeTemplateProcessingException
- {
- SAXReader reader = new SAXReader();
- Document document = reader.read( fileReader );
- Element project = document.getRootElement();
-
- String packaging = null;
- Element packagingElement = project.element( "packaging" );
- if ( packagingElement != null )
- {
- packaging = packagingElement.getStringValue();
- }
- if ( !"pom".equals( packaging ) )
- {
- throw new ArchetypeTemplateProcessingException(
- "Unable to add module to the current project as it is not of packaging type 'pom'" );
- }
-
- Element modules = project.element( "modules" );
- if ( modules == null )
- {
- modules = project.addText( " " ).addElement( "modules" );
- modules.setText( "\n " );
- project.addText( "\n" );
- }
- boolean found = false;
- for ( Iterator i = modules.elementIterator( "module" ); i.hasNext() && !found; )
- {
- Element module = (Element) i.next();
- if ( module.getText().equals( artifactId ) )
- {
- found = true;
- }
- }
- if ( !found )
- {
- Node lastTextNode = null;
- for ( Iterator i = modules.nodeIterator(); i.hasNext(); )
- {
- Node node = (Node) i.next();
- if ( node.getNodeType() == Node.ELEMENT_NODE )
- {
- lastTextNode = null;
- }
- else if ( node.getNodeType() == Node.TEXT_NODE )
- {
- lastTextNode = node;
- }
- }
-
- if ( lastTextNode != null )
- {
- modules.remove( lastTextNode );
- }
-
- modules.addText( "\n " );
- modules.addElement( "module" ).setText( artifactId );
- modules.addText( "\n " );
-
- XMLWriter writer = new XMLWriter( fileWriter );
- writer.write( document );
- }
- return !found;
- }
-
- private void processTemplates( File pomFile,
- String outputDirectory,
- Context context,
- ArchetypeDescriptor descriptor,
- String packageName,
- Model parentModel )
- throws ArchetypeTemplateProcessingException
- {
- if ( !pomFile.exists() )
- {
- processTemplate( outputDirectory, context, ARCHETYPE_POM, new TemplateDescriptor(), false, null );
- }
-
- // ---------------------------------------------------------------------
- // Model generated for the new archetype, so process it now
- // ---------------------------------------------------------------------
-
- Model generatedModel;
- FileReader pomReader = null;
- try
- {
- pomReader = new FileReader( pomFile );
-
- MavenXpp3Reader reader = new MavenXpp3Reader();
-
- generatedModel = reader.read( pomReader );
- }
- catch ( IOException e )
- {
- throw new ArchetypeTemplateProcessingException( "Error reading POM", e );
- }
- catch ( XmlPullParserException e )
- {
- throw new ArchetypeTemplateProcessingException( "Error reading POM", e );
- }
- finally
- {
- IOUtil.close( pomReader );
- }
-
- if ( parentModel != null )
- {
- Parent parent = new Parent();
- parent.setGroupId( parentModel.getGroupId() );
- if ( parent.getGroupId() == null )
- {
- parent.setGroupId( parentModel.getParent().getGroupId() );
- }
- parent.setArtifactId( parentModel.getArtifactId() );
- parent.setVersion( parentModel.getVersion() );
- if ( parent.getVersion() == null )
- {
- parent.setVersion( parentModel.getParent().getVersion() );
- }
- generatedModel.setParent( parent );
-
- FileWriter pomWriter = null;
- try
- {
- pomWriter = new FileWriter( pomFile );
-
- MavenXpp3Writer writer = new MavenXpp3Writer();
- writer.write( pomWriter, generatedModel );
- }
- catch ( IOException e )
- {
- throw new ArchetypeTemplateProcessingException( "Error rewriting POM", e );
- }
- finally
- {
- IOUtil.close( pomWriter );
- }
- }
-
- // XXX: Following POM processing block may be a candidate for
- // refactoring out into service methods or moving to
- // createProjectDirectoryStructure(outputDirectory)
- Build build = generatedModel.getBuild();
-
- boolean overrideSrcDir = false;
-
- boolean overrideResourceDir = false;
-
- boolean overrideTestSrcDir = false;
-
- boolean overrideTestResourceDir = false;
-
- boolean foundBuildElement = build != null;
-
- if ( getLogger().isDebugEnabled() )
- {
- getLogger().debug(
- "********************* Debug info for resources created from generated Model ***********************" );
- }
-
- if ( getLogger().isDebugEnabled() )
- {
- getLogger().debug( "Was build element found in generated POM?: " + foundBuildElement );
- }
-
- // create source directory if specified in POM
- if ( foundBuildElement && null != build.getSourceDirectory() )
- {
- if ( getLogger().isDebugEnabled() )
- {
- getLogger().debug( "Overriding default source directory " );
- }
-
- overrideSrcDir = true;
-
- String srcDirectory = build.getSourceDirectory();
-
- srcDirectory = StringUtils.replace( srcDirectory, "\\", "/" );
-
- FileUtils.mkdir( getOutputDirectory( outputDirectory, srcDirectory ) );
- }
-
- // create script source directory if specified in POM
- if ( foundBuildElement && null != build.getScriptSourceDirectory() )
- {
- if ( getLogger().isDebugEnabled() )
- {
- getLogger().debug( "Overriding default script source directory " );
- }
-
- String scriptSourceDirectory = build.getScriptSourceDirectory();
-
- scriptSourceDirectory = StringUtils.replace( scriptSourceDirectory, "\\", "/" );
-
- FileUtils.mkdir( getOutputDirectory( outputDirectory, scriptSourceDirectory ) );
- }
-
- // create resource director(y/ies) if specified in POM
- if ( foundBuildElement && build.getResources().size() > 0 )
- {
- if ( getLogger().isDebugEnabled() )
- {
- getLogger().info( "Overriding default resource directory " );
- }
-
- overrideResourceDir = true;
-
- Iterator resourceItr = build.getResources().iterator();
-
- while ( resourceItr.hasNext() )
- {
- Resource resource = (Resource) resourceItr.next();
-
- String resourceDirectory = resource.getDirectory();
-
- resourceDirectory = StringUtils.replace( resourceDirectory, "\\", "/" );
-
- FileUtils.mkdir( getOutputDirectory( outputDirectory, resourceDirectory ) );
- }
- }
- // create test source directory if specified in POM
- if ( foundBuildElement && null != build.getTestSourceDirectory() )
- {
- if ( getLogger().isDebugEnabled() )
- {
- getLogger().debug( "Overriding default test directory " );
- }
-
- overrideTestSrcDir = true;
-
- String testDirectory = build.getTestSourceDirectory();
-
- testDirectory = StringUtils.replace( testDirectory, "\\", "/" );
-
- FileUtils.mkdir( getOutputDirectory( outputDirectory, testDirectory ) );
- }
-
- // create test resource directory if specified in POM
- if ( foundBuildElement && build.getTestResources().size() > 0 )
- {
- if ( getLogger().isDebugEnabled() )
- {
- getLogger().debug( "Overriding default test resource directory " );
- }
-
- overrideTestResourceDir = true;
-
- Iterator testResourceItr = build.getTestResources().iterator();
-
- while ( testResourceItr.hasNext() )
- {
- Resource resource = (Resource) testResourceItr.next();
-
- String testResourceDirectory = resource.getDirectory();
-
- testResourceDirectory = StringUtils.replace( testResourceDirectory, "\\", "/" );
-
- FileUtils.mkdir( getOutputDirectory( outputDirectory, testResourceDirectory ) );
- }
- }
-
- getLogger().info(
- "********************* End of debug info from resources from generated POM ***********************" );
-
- // ----------------------------------------------------------------------
- // Main
- // ----------------------------------------------------------------------
-
- if ( descriptor.getSources().size() > 0 )
- {
- if ( !overrideSrcDir )
- {
- FileUtils.mkdir( outputDirectory + DEFAULT_SOURCE_DIR );
- processSources( outputDirectory, context, descriptor, packageName, DEFAULT_SOURCE_DIR );
- }
- else
- {
- processSources( outputDirectory, context, descriptor, packageName, build.getSourceDirectory() );
- }
- }
-
- if ( descriptor.getResources().size() > 0 )
- {
- if ( !overrideResourceDir )
- {
- FileUtils.mkdir( outputDirectory + DEFAULT_RESOURCE_DIR );
- }
- processResources( outputDirectory, context, descriptor, packageName );
- }
-
- // ----------------------------------------------------------------------
- // Test
- // ----------------------------------------------------------------------
-
- if ( descriptor.getTestSources().size() > 0 )
- {
- if ( !overrideTestSrcDir )
- {
- FileUtils.mkdir( outputDirectory + DEFAULT_TEST_SOURCE_DIR );
- processTestSources( outputDirectory, context, descriptor, packageName, DEFAULT_TEST_SOURCE_DIR );
- }
- else
- {
- processTestSources( outputDirectory, context, descriptor, packageName, build.getTestSourceDirectory() );
- }
- }
-
- if ( descriptor.getTestResources().size() > 0 )
- {
- if ( !overrideTestResourceDir )
- {
- FileUtils.mkdir( outputDirectory + DEFAULT_TEST_RESOURCE_DIR );
- }
- processTestResources( outputDirectory, context, descriptor, packageName );
- }
-
- // ----------------------------------------------------------------------
- // Site
- // ----------------------------------------------------------------------
-
- if ( descriptor.getSiteResources().size() > 0 )
- {
- processSiteResources( outputDirectory, context, descriptor, packageName );
- }
- }
-
- private void processTemplate( String outputDirectory,
- Context context,
- String template,
- TemplateDescriptor descriptor,
- boolean packageInFileName,
- String packageName )
- throws ArchetypeTemplateProcessingException
- {
- processTemplate( outputDirectory, context, template, descriptor, packageInFileName, packageName, null );
- }
-
- private String getOutputDirectory( String outputDirectory,
- String testResourceDirectory )
- {
- return outputDirectory +
- ( testResourceDirectory.startsWith( "/" ) ? testResourceDirectory : "/" + testResourceDirectory );
- }
-
- // ----------------------------------------------------------------------
- //
- // ----------------------------------------------------------------------
-
- protected void processSources( String outputDirectory,
- Context context,
- ArchetypeDescriptor descriptor,
- String packageName,
- String sourceDirectory )
- throws ArchetypeTemplateProcessingException
- {
- for ( Iterator i = descriptor.getSources().iterator(); i.hasNext(); )
- {
- String template = (String) i.next();
-
- processTemplate( outputDirectory, context, template, descriptor.getSourceDescriptor( template ), true,
- packageName, sourceDirectory );
- }
- }
-
- protected void processTestSources( String outputDirectory,
- Context context,
- ArchetypeDescriptor descriptor,
- String packageName,
- String testSourceDirectory )
- throws ArchetypeTemplateProcessingException
- {
- for ( Iterator i = descriptor.getTestSources().iterator(); i.hasNext(); )
- {
- String template = (String) i.next();
-
- processTemplate( outputDirectory, context, template, descriptor.getTestSourceDescriptor( template ), true,
- packageName, testSourceDirectory );
- }
- }
-
- protected void processResources( String outputDirectory,
- Context context,
- ArchetypeDescriptor descriptor,
- String packageName )
- throws ArchetypeTemplateProcessingException
- {
- for ( Iterator i = descriptor.getResources().iterator(); i.hasNext(); )
- {
- String template = (String) i.next();
-
- processTemplate( outputDirectory, context, template, descriptor.getResourceDescriptor( template ), false,
- packageName );
- }
- }
-
- protected void processTestResources( String outputDirectory,
- Context context,
- ArchetypeDescriptor descriptor,
- String packageName )
- throws ArchetypeTemplateProcessingException
- {
- for ( Iterator i = descriptor.getTestResources().iterator(); i.hasNext(); )
- {
- String template = (String) i.next();
-
- processTemplate( outputDirectory, context, template, descriptor.getTestResourceDescriptor( template ),
- false, packageName );
- }
- }
-
- protected void processSiteResources( String outputDirectory,
- Context context,
- ArchetypeDescriptor descriptor,
- String packageName )
- throws ArchetypeTemplateProcessingException
- {
- for ( Iterator i = descriptor.getSiteResources().iterator(); i.hasNext(); )
- {
- String template = (String) i.next();
-
- processTemplate( outputDirectory, context, template, descriptor.getSiteResourceDescriptor( template ),
- false, packageName );
- }
- }
-
- protected void processTemplate( String outputDirectory,
- Context context,
- String template,
- TemplateDescriptor descriptor,
- boolean packageInFileName,
- String packageName,
- String sourceDirectory )
- throws ArchetypeTemplateProcessingException
- {
- File f;
-
- template = StringUtils.replace( template, "\\", "/" );
-
- if ( packageInFileName && packageName != null )
- {
- String templateFileName = StringUtils.replace( template, "/", File.separator );
-
- String path = packageName.replace( '.', '/' );
-
- String filename = FileUtils.filename( templateFileName );
-
- String dirname = FileUtils.dirname( templateFileName ).replace( '\\', '/' );
-
- sourceDirectory = sourceDirectory.replace( '\\', '/' );
- if ( sourceDirectory.startsWith( "/" ) )
- {
- sourceDirectory = sourceDirectory.substring( 1 );
- }
-
- if ( !dirname.startsWith( sourceDirectory ) )
- {
- throw new ArchetypeTemplateProcessingException(
- "Template '" + template + "' not in directory '" + sourceDirectory + "'" );
- }
-
- String extraPackages = dirname.substring( sourceDirectory.length() );
- if ( extraPackages.startsWith( "/" ) )
- {
- extraPackages = extraPackages.substring( 1 );
- }
- if ( extraPackages.length() > 0 )
- {
- path += "/" + extraPackages;
- }
-
- f = new File( new File( new File( outputDirectory, sourceDirectory ), path ), filename );
- }
- else
- {
- f = new File( outputDirectory, template );
- }
-
- if ( !f.getParentFile().exists() )
- {
- f.getParentFile().mkdirs();
- }
-
- if ( descriptor.isFiltered() )
- {
- Writer writer = null;
- try
- {
- writer = new OutputStreamWriter( new FileOutputStream( f ), descriptor.getEncoding() );
-
- template = ARCHETYPE_RESOURCES + "/" + template;
-
- velocity.getEngine().mergeTemplate( template, descriptor.getEncoding(), context, writer );
-
- writer.flush();
- }
- catch ( Exception e )
- {
- throw new ArchetypeTemplateProcessingException( "Error merging velocity templates", e );
- }
- finally
- {
- IOUtil.close( writer );
- }
- }
- else
- {
- InputStream is = getStream( ARCHETYPE_RESOURCES + "/" + template, null );
-
- OutputStream fos = null;
-
- try
- {
- fos = new FileOutputStream( f );
-
- IOUtil.copy( is, fos );
- }
- catch ( Exception e )
- {
- throw new ArchetypeTemplateProcessingException( "Error copying file", e );
- }
- finally
- {
- IOUtil.close( fos );
-
- IOUtil.close( is );
- }
- }
- }
-
- protected void createProjectDirectoryStructure( String outputDirectory )
- {
- }
-
- private InputStream getStream( String name,
- ClassLoader loader )
- {
- if ( loader == null )
- {
- return Thread.currentThread().getContextClassLoader().getResourceAsStream( name );
- }
- return loader.getResourceAsStream( name );
- }
-}
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
deleted file mode 100644
index 735cb4f..0000000
--- a/maven-archetype/maven-archetype-core/src/main/java/org/apache/maven/archetype/descriptor/ArchetypeDescriptor.java
+++ /dev/null
@@ -1,261 +0,0 @@
-package org.apache.maven.archetype.descriptor;
-
-/*
- * Copyright 2004-2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class ArchetypeDescriptor
-{
- private String id;
-
- private List sources;
-
- private List testSources;
-
- private List resources;
-
- private List testResources;
-
- private List siteResources;
-
- /**
- * <code>Map</code> that associates the items in the <code>List</code>
- * <code>sources</code> with their attributes (instances of
- * <code>TemplateDescriptor</code>.
- */
- private Map sourcesDescriptors;
-
- /**
- * <code>Map</code> that associates the items in the <code>List</code>
- * <code>testSources</code> with their attributes (instances of
- * <code>TemplateDescriptor</code>.
- */
- private Map testSourcesDescriptors;
-
- /**
- * <code>Map</code> that associates the items in the <code>List</code>
- * <code>resources</code> with their attributes (instances of
- * <code>TemplateDescriptor</code>.
- */
- private Map resourcesDescriptors;
-
- /**
- * <code>Map</code> that associates the items in the <code>List</code>
- * <code>testResources</code> with their attributes (instances of
- * <code>TemplateDescriptor</code>.
- */
- private Map testResourcesDescriptors;
-
- /**
- * <code>Map</code> that associates the items in the <code>List</code>
- * <code>siteResources</code> with their attributes (instances of
- * <code>TemplateDescriptor</code>.
- */
- private Map siteResourcesDescriptors;
-
- /**
- * This indicates the archetype can be a whole project or can be part
- * of another project. An example is a site archetype where the POM and
- * directory structure may already exist and you simply want to generate
- * the site directory structure.
- */
- private boolean allowPartial;
-
- public ArchetypeDescriptor()
- {
- sources = new ArrayList();
-
- resources = new ArrayList();
-
- testSources = new ArrayList();
-
- testResources = new ArrayList();
-
- siteResources = new ArrayList();
-
- sourcesDescriptors = new HashMap();
-
- testSourcesDescriptors = new HashMap();
-
- resourcesDescriptors = new HashMap();
-
- testResourcesDescriptors = new HashMap();
-
- siteResourcesDescriptors = new HashMap();
- }
-
- // ----------------------------------------------------------------------
- //
- // ----------------------------------------------------------------------
-
- public String getId()
- {
- return id;
- }
-
- public void setId( String id )
- {
- this.id = id;
- }
-
- public void addSource( String source )
- {
- sources.add( source );
-
- putSourceDescriptor( source, new TemplateDescriptor() );
- }
-
- public List getSources()
- {
- return sources;
- }
-
- public void putSourceDescriptor( String source, TemplateDescriptor descriptor )
- {
- sourcesDescriptors.put( source, descriptor );
- }
-
- public TemplateDescriptor getSourceDescriptor( String source )
- {
- return (TemplateDescriptor) sourcesDescriptors.get( source );
- }
-
- public Map getSourcesDescriptors()
- {
- return sourcesDescriptors;
- }
-
- public void addTestSource( String testSource )
- {
- testSources.add( testSource );
-
- putTestSourceDescriptor( testSource, new TemplateDescriptor() );
- }
-
- public List getTestSources()
- {
- return testSources;
- }
-
- public void putTestSourceDescriptor( String testSource, TemplateDescriptor descriptor )
- {
- testSourcesDescriptors.put( testSource, descriptor );
- }
-
- public TemplateDescriptor getTestSourceDescriptor( String testSource )
- {
- return (TemplateDescriptor) testSourcesDescriptors.get( testSource );
- }
-
- public Map getTestSourcesDescriptors()
- {
- return testSourcesDescriptors;
- }
-
- public void addResource( String resource )
- {
- resources.add( resource );
-
- putResourceDescriptor( resource, new TemplateDescriptor() );
- }
-
- public List getResources()
- {
- return resources;
- }
-
- public void putResourceDescriptor( String resource, TemplateDescriptor descriptor )
- {
- resourcesDescriptors.put( resource, descriptor );
- }
-
- public TemplateDescriptor getResourceDescriptor( String resource )
- {
- return (TemplateDescriptor) resourcesDescriptors.get( resource );
- }
-
- public Map getReourcesDescriptors()
- {
- return resourcesDescriptors;
- }
-
- public void addTestResource( String testResource )
- {
- testResources.add( testResource );
- putTestResourceDescriptor( testResource, new TemplateDescriptor() );
- }
-
- public List getTestResources()
- {
- return testResources;
- }
-
- public void putTestResourceDescriptor( String testResource, TemplateDescriptor descriptor )
- {
- testResourcesDescriptors.put( testResource, descriptor );
- }
-
- public TemplateDescriptor getTestResourceDescriptor( String testResource )
- {
- return (TemplateDescriptor) testResourcesDescriptors.get( testResource );
- }
-
- public Map getTestReourcesDescriptors()
- {
- return testResourcesDescriptors;
- }
-
- public void addSiteResource( String siteResource )
- {
- siteResources.add( siteResource );
-
- putSiteResourceDescriptor( siteResource, new TemplateDescriptor() );
- }
-
- public List getSiteResources()
- {
- return siteResources;
- }
-
- public void putSiteResourceDescriptor( String siteResource, TemplateDescriptor descriptor )
- {
- siteResourcesDescriptors.put( siteResource, descriptor );
- }
-
- public TemplateDescriptor getSiteResourceDescriptor( String siteResource )
- {
- return (TemplateDescriptor) siteResourcesDescriptors.get( siteResource );
- }
-
- public Map getSiteReourcesDescriptors()
- {
- return siteResourcesDescriptors;
- }
-
- public boolean isAllowPartial()
- {
- return allowPartial;
- }
-
- public void setAllowPartial( boolean allowPartial )
- {
- this.allowPartial = allowPartial;
- }
-}
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
deleted file mode 100644
index c721572..0000000
--- a/maven-archetype/maven-archetype-core/src/main/java/org/apache/maven/archetype/descriptor/ArchetypeDescriptorBuilder.java
+++ /dev/null
@@ -1,406 +0,0 @@
-package org.apache.maven.archetype.descriptor;
-
-/*
- * Copyright 2004-2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import org.codehaus.plexus.util.xml.Xpp3Dom;
-import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
-import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
-
-import java.io.IOException;
-import java.io.Reader;
-import java.nio.charset.IllegalCharsetNameException;
-import java.nio.charset.UnsupportedCharsetException;
-
-/**
- * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
- * @version $Id$
- */
-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;
- }
-}
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
deleted file mode 100644
index d40cdeb..0000000
--- a/maven-archetype/maven-archetype-core/src/main/java/org/apache/maven/archetype/descriptor/ArchetypeDescriptorGenerator.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package org.apache.maven.archetype.descriptor;
-
-/*
- * Copyright 2004-2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Pass over the directory containing the sources of the archetype and create
- * the appropriate descriptor.
- *
- * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
- * @version $Id$
- */
-public class ArchetypeDescriptorGenerator
-{
-}
diff --git a/maven-archetype/maven-archetype-core/src/main/java/org/apache/maven/archetype/descriptor/TemplateDescriptor.java b/maven-archetype/maven-archetype-core/src/main/java/org/apache/maven/archetype/descriptor/TemplateDescriptor.java
deleted file mode 100644
index 281b84b..0000000
--- a/maven-archetype/maven-archetype-core/src/main/java/org/apache/maven/archetype/descriptor/TemplateDescriptor.java
+++ /dev/null
@@ -1,125 +0,0 @@
-package org.apache.maven.archetype.descriptor;
-
-/*
- * Copyright 2004-2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import java.io.OutputStreamWriter;
-import java.nio.charset.Charset;
-import java.nio.charset.IllegalCharsetNameException;
-import java.nio.charset.UnsupportedCharsetException;
-
-/**
- * Contains the attributes of an archetype's template (either a source or resource file).
- * The attributes indicate if the template should be filtered and it's encoding.
- */
-public class TemplateDescriptor
-{
-
- /**
- * Determines if the template should be filtered or not.
- */
- private boolean filtered = true;
-
- /**
- * Determines the template's encoding.
- */
- private String encoding;
-
- /**
- * Creates a new instance of <code>TemplateDescriptor<code> that should be filtered
- * and has the default encoding.
- */
- public TemplateDescriptor()
- {
- setFiltered( true );
-
- setEncoding( getDefaultEncoding() );
- }
-
- /**
- * Returns the canonical name of the default character encoding of this Java
- * virtual machine.
- *
- * @return the name of the default character encoding.
- */
- private static String getDefaultEncoding()
- {
- String name = System.getProperty( "file.encoding" );
-
- if ( name == null )
- {
- OutputStreamWriter out = new OutputStreamWriter( System.out );
-
- name = out.getEncoding();
- }
-
- name = Charset.forName( name ).name();
-
- return name;
- }
-
- /**
- * Returns <code>true</code> if the template should be filtered and
- * <code>false</code> otherwise.
- *
- * @return <code>true</code> if the template should be filtered and
- * <code>false</code> otherwise.
- */
- public boolean isFiltered()
- {
- return this.filtered;
- }
-
- /**
- * Defines whether the template should be filtered (processed by Velocity)
- * or not.
- *
- * @param filtered <code>true</code> if it should be processed by Velocity and
- * <code>fales</code> otherwise.
- */
- public void setFiltered( boolean filtered )
- {
- this.filtered = filtered;
- }
-
- /**
- * Returns the name of the encoding of the template file (e.g.
- * <code>us-ascci</code>, <code>utf-8</code>, <code>iso-8859-1</code>).
- *
- * @return the name of the encoding of the template file.
- */
- public String getEncoding()
- {
- return this.encoding;
- }
-
- /**
- * Sets the name of the encoding of the template file.
- *
- * @param encoding New value of property encoding.
- * @throws IllegalCharsetNameException if the given charset name is illegal
- * @throws UnsupportedCharsetException if no support for the named encoding
- * is available in this instance of the Java virtual machine
- */
- public void setEncoding( String encoding )
- throws IllegalCharsetNameException, UnsupportedCharsetException
- {
- Charset.forName( encoding );
-
- this.encoding = encoding;
- }
-
-}
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
deleted file mode 100644
index 2a9fcfb..0000000
--- a/maven-archetype/maven-archetype-core/src/test/java/org/apache/maven/archetype/ArchetypeTest.java
+++ /dev/null
@@ -1,320 +0,0 @@
-package org.apache.maven.archetype;
-
-/*
- * Copyright 2004-2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import org.apache.maven.artifact.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 Archetype 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( Archetype.ARCHETYPE_RESOURCES + "/" + Archetype.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(), Archetype.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( "Archetype 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 " + Archetype.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( DefaultArchetype.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( DefaultArchetype.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( DefaultArchetype.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( DefaultArchetype.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( DefaultArchetype.addModuleToParentPom( "myArtifactId3", new StringReader( pom ), out ) );
-
- // empty means unchanged
- assertEquals( "", out.toString() );
- }
-
- public void testAddModuleToParentPOMNoPackaging()
- throws DocumentException, IOException
- {
- try
- {
- String pom = "<project>\n</project>";
- DefaultArchetype.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>";
- DefaultArchetype.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 = (Archetype) lookup( Archetype.ROLE );
- }
-}
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
deleted file mode 100644
index 08fd416..0000000
--- a/maven-archetype/maven-archetype-core/src/test/java/org/apache/maven/archetype/descriptor/ArchetypeDescriptorBuilderTest.java
+++ /dev/null
@@ -1,246 +0,0 @@
-package org.apache.maven.archetype.descriptor;
-
-/*
- * Copyright 2004-2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import 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() );
- }
-}
diff --git a/maven-archetype/maven-archetype-core/src/test/repository/org.apache.maven.archetypes/jars/maven-archetype-quickstart-1.0-alpha-1-SNAPSHOT.jar b/maven-archetype/maven-archetype-core/src/test/repository/org.apache.maven.archetypes/jars/maven-archetype-quickstart-1.0-alpha-1-SNAPSHOT.jar
deleted file mode 100755
index 85ae0c5..0000000
--- a/maven-archetype/maven-archetype-core/src/test/repository/org.apache.maven.archetypes/jars/maven-archetype-quickstart-1.0-alpha-1-SNAPSHOT.jar
+++ /dev/null
Binary files differ
diff --git a/maven-archetype/maven-archetype-core/src/test/repository/org.apache.maven.archetypes/poms/maven-archetype-quickstart-1.0-alpha-1-SNAPSHOT.pom b/maven-archetype/maven-archetype-core/src/test/repository/org.apache.maven.archetypes/poms/maven-archetype-quickstart-1.0-alpha-1-SNAPSHOT.pom
deleted file mode 100755
index ee21329..0000000
--- a/maven-archetype/maven-archetype-core/src/test/repository/org.apache.maven.archetypes/poms/maven-archetype-quickstart-1.0-alpha-1-SNAPSHOT.pom
+++ /dev/null
@@ -1,26 +0,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.
- -->
-
-<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
diff --git a/maven-archetype/maven-archetype-core/src/test/repository/org.apache.maven.archetypes/poms/maven-archetype-quickstart-1.0-alpha-1-SNAPSHOT.version.txt b/maven-archetype/maven-archetype-core/src/test/repository/org.apache.maven.archetypes/poms/maven-archetype-quickstart-1.0-alpha-1-SNAPSHOT.version.txt
deleted file mode 100755
index 33f4519..0000000
--- a/maven-archetype/maven-archetype-core/src/test/repository/org.apache.maven.archetypes/poms/maven-archetype-quickstart-1.0-alpha-1-SNAPSHOT.version.txt
+++ /dev/null
@@ -1 +0,0 @@
-1.0-alpha-1-SNAPSHOT
\ No newline at end of file
diff --git a/maven-archetype/maven-archetype-core/src/test/repository/org.apache.maven.archetypes/poms/maven-archetypes-1.0-alpha-1-SNAPSHOT.pom b/maven-archetype/maven-archetype-core/src/test/repository/org.apache.maven.archetypes/poms/maven-archetypes-1.0-alpha-1-SNAPSHOT.pom
deleted file mode 100755
index 74dda84..0000000
--- a/maven-archetype/maven-archetype-core/src/test/repository/org.apache.maven.archetypes/poms/maven-archetypes-1.0-alpha-1-SNAPSHOT.pom
+++ /dev/null
@@ -1,33 +0,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.
- -->
-
-<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>
diff --git a/maven-archetype/maven-archetype-core/src/test/repository/org.apache.maven.archetypes/poms/maven-archetypes-1.0-alpha-1-SNAPSHOT.version.txt b/maven-archetype/maven-archetype-core/src/test/repository/org.apache.maven.archetypes/poms/maven-archetypes-1.0-alpha-1-SNAPSHOT.version.txt
deleted file mode 100755
index 33f4519..0000000
--- a/maven-archetype/maven-archetype-core/src/test/repository/org.apache.maven.archetypes/poms/maven-archetypes-1.0-alpha-1-SNAPSHOT.version.txt
+++ /dev/null
@@ -1 +0,0 @@
-1.0-alpha-1-SNAPSHOT
\ No newline at end of file
diff --git a/maven-archetype/maven-archetype-core/src/test/resources/xdocs/index.xml b/maven-archetype/maven-archetype-core/src/test/resources/xdocs/index.xml
deleted file mode 100644
index 13a50cd..0000000
--- a/maven-archetype/maven-archetype-core/src/test/resources/xdocs/index.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-<?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>
diff --git a/maven-archetype/maven-archetype-core/src/test/resources/xdocs/navigation.xml b/maven-archetype/maven-archetype-core/src/test/resources/xdocs/navigation.xml
deleted file mode 100644
index 055f5ec..0000000
--- a/maven-archetype/maven-archetype-core/src/test/resources/xdocs/navigation.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
- ~ 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 name="Maven">
-
- <title>Maven</title>
-
- <body>
- <links>
- <item name="Plexus" href="http://plexus.codehaus.org"/>
- </links>
-
- <menu name="Quick Links">
- <item name="Model" href="/maven.html"/>
- </menu>
- </body>
-</project>
diff --git a/maven-archetype/maven-archetype-creator/pom.xml b/maven-archetype/maven-archetype-creator/pom.xml
deleted file mode 100644
index b7f67a9..0000000
--- a/maven-archetype/maven-archetype-creator/pom.xml
+++ /dev/null
@@ -1,66 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>org.apache.maven.archetype</groupId>
- <artifactId>maven-archetype</artifactId>
- <version>1.0-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <artifactId>maven-archetype-creator</artifactId>
- <name>Maven Archetype Creator</name>
- <url>http://maven.apache.org</url>
- <dependencies>
- <dependency>
- <groupId>org.apache.maven.archetype</groupId>
- <artifactId>maven-archetype-model</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-project</artifactId>
- <version>2.0</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-container-default</artifactId>
- <version>1.0-alpha-9</version>
- </dependency>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-archiver</artifactId>
- <version>1.0-alpha-5</version>
- </dependency>
- <dependency>
- <groupId>oro</groupId>
- <artifactId>oro</artifactId>
- <version>2.0.8</version>
- </dependency>
- </dependencies>
-</project>
diff --git a/maven-archetype/maven-archetype-creator/src/main/archetype/archetype.properties b/maven-archetype/maven-archetype-creator/src/main/archetype/archetype.properties
deleted file mode 100644
index 6827c0c..0000000
--- a/maven-archetype/maven-archetype-creator/src/main/archetype/archetype.properties
+++ /dev/null
@@ -1,17 +0,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.
-#
-
-package=org.apache.maven.archetype
diff --git a/maven-archetype/maven-archetype-creator/src/main/java/org/apache/maven/archetype/ArchetypeCreationException.java b/maven-archetype/maven-archetype-creator/src/main/java/org/apache/maven/archetype/ArchetypeCreationException.java
deleted file mode 100644
index e58ec93..0000000
--- a/maven-archetype/maven-archetype-creator/src/main/java/org/apache/maven/archetype/ArchetypeCreationException.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package org.apache.maven.archetype;
-
-/*
- * Copyright 2004-2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Jason van Zyl
- * @version $Revision:$
- */
-public class ArchetypeCreationException
- extends Exception
-{
- public ArchetypeCreationException( String message )
- {
- super( message );
- }
-
- public ArchetypeCreationException( Throwable cause )
- {
- super( cause );
- }
-
- public ArchetypeCreationException( String message, Throwable cause )
- {
- super( message, cause );
- }
-}
diff --git a/maven-archetype/maven-archetype-creator/src/main/java/org/apache/maven/archetype/ArchetypeCreator.java b/maven-archetype/maven-archetype-creator/src/main/java/org/apache/maven/archetype/ArchetypeCreator.java
deleted file mode 100644
index c74750d..0000000
--- a/maven-archetype/maven-archetype-creator/src/main/java/org/apache/maven/archetype/ArchetypeCreator.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package org.apache.maven.archetype;
-
-/*
- * Copyright 2004-2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.project.MavenProject;
-
-import java.io.File;
-import java.util.Properties;
-
-/**
- * @author Jason van Zyl
- * @version $Revision:$
- */
-public interface ArchetypeCreator
-{
- static String ROLE = ArchetypeCreator.class.getName();
-
- File createArchetype( File basedir, ArtifactRepository localRepository, File targetDirectory,
- Properties properties )
- throws ArchetypeCreationException;
-
- File createArchetype( MavenProject project, ArtifactRepository localRepository, File targetDirectory,
- Properties properties )
- throws ArchetypeCreationException;
-}
diff --git a/maven-archetype/maven-archetype-creator/src/main/java/org/apache/maven/archetype/Copier.java b/maven-archetype/maven-archetype-creator/src/main/java/org/apache/maven/archetype/Copier.java
deleted file mode 100644
index f9ed05a..0000000
--- a/maven-archetype/maven-archetype-creator/src/main/java/org/apache/maven/archetype/Copier.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package org.apache.maven.archetype;
-
-/*
- * Copyright 2004-2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import java.io.File;
-import java.io.IOException;
-
-/**
- * @author Jason van Zyl
- * @version $Revision:$
- */
-public interface Copier
-{
- void copy( File source, File target )
- throws IOException;
-}
diff --git a/maven-archetype/maven-archetype-creator/src/main/java/org/apache/maven/archetype/DefaultArchetypeCreator.java b/maven-archetype/maven-archetype-creator/src/main/java/org/apache/maven/archetype/DefaultArchetypeCreator.java
deleted file mode 100644
index 282e40d..0000000
--- a/maven-archetype/maven-archetype-creator/src/main/java/org/apache/maven/archetype/DefaultArchetypeCreator.java
+++ /dev/null
@@ -1,366 +0,0 @@
-package org.apache.maven.archetype;
-
-/*
- * Copyright 2004-2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import org.apache.maven.archetype.model.ArchetypeModel;
-import org.apache.maven.archetype.model.io.xpp3.ArchetypeXpp3Writer;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.model.Model;
-import org.apache.maven.model.Resource;
-import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
-import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
-import org.apache.maven.project.MavenProject;
-import org.apache.maven.project.MavenProjectBuilder;
-import org.apache.maven.project.ProjectBuildingException;
-import org.codehaus.plexus.archiver.Archiver;
-
-import java.io.File;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Properties;
-
-/**
- * The Archetype Creator will take an existing Maven project and turn it into a archetype, or project
- * template that can be used by anyone. It is the easiest way to take a fully functional Maven projet and
- * transform it into a archetype.
- *
- * @author jason van zyl
- * @plexus.component
- * @todo dealing adequately with multi module builds
- */
-public class DefaultArchetypeCreator
- implements ArchetypeCreator
-{
- /**
- * @plexus.requirement
- */
- private MavenProjectBuilder projectBuilder;
-
- /**
- * @plexus.requirement role-hint="jar"
- */
- private Archiver archiver;
-
- private MavenXpp3Reader modelReader;
-
- private MavenXpp3Writer modelWriter;
-
- ArchetypeXpp3Writer archetypeModelWriter;
-
- public DefaultArchetypeCreator()
- {
- modelReader = new MavenXpp3Reader();
-
- modelWriter = new MavenXpp3Writer();
-
- archetypeModelWriter = new ArchetypeXpp3Writer();
- }
-
- public File createArchetype( File basedir, ArtifactRepository localRepository, File targetDirectory,
- Properties properties )
- throws ArchetypeCreationException
- {
- File pom = new File( basedir, "pom.xml" );
-
- MavenProject project;
-
- try
- {
- project = projectBuilder.build( pom, localRepository, null );
- }
- catch ( ProjectBuildingException e )
- {
- throw new ArchetypeCreationException( "Cannot read POM of the source project.", e );
- }
-
- return createArchetype( project, localRepository, targetDirectory, properties );
- }
-
- private String clipToBasedir( String path, File basedir )
- throws IOException
- {
- return new File( path ).getCanonicalPath().substring( basedir.getCanonicalPath().length() + 1 );
- }
-
- public File createArchetype( MavenProject project, ArtifactRepository localRepository, File targetDirectory,
- Properties properties )
- throws ArchetypeCreationException
- {
- if ( !targetDirectory.exists() )
- {
- if ( !targetDirectory.mkdirs() )
- {
- throw new ArchetypeCreationException( "Cannot create target directory for archetype creation." );
- }
- }
-
- // basedir for the source project
- File basedir = project.getFile().getParentFile();
-
- // Source directory as stated in the source POM, this may not be the default src/main/java
- String sourceDirectory = null;
-
- // Test source directory as state in the source POM, this may not be the default src/test/java
- String testSourceDirectory = null;
-
- // ----------------------------------------------------------------------
- // Create the archetype archetypeModel
- //
- // -> add all the main sources to the model
- // -> add all the main resources to the model
- // -> add all the test sources to the model
- // -> add all the test resources to the model
- // ----------------------------------------------------------------------
-
- ArchetypeModel archetypeModel = new ArchetypeModel();
-
- archetypeModel.setId( project.getArtifactId() );
-
- try
- {
- // ----------------------------------------------------------------------
- // Sources
- // ----------------------------------------------------------------------
-
- // Typically src/main/java, but could be different
- sourceDirectory = clipToBasedir( project.getBuild().getSourceDirectory(), basedir );
-
- List sources = getFiles( project.getBuild().getSourceDirectory() );
-
- for ( Iterator i = sources.iterator(); i.hasNext(); )
- {
- archetypeModel.addSource( clipToBasedir( (String) i.next(), basedir ) );
- }
-
- // ----------------------------------------------------------------------
- // Resources
- // ----------------------------------------------------------------------
-
- List resourceElements = project.getBuild().getResources();
-
- for ( Iterator i = resourceElements.iterator(); i.hasNext(); )
- {
- Resource resource = (Resource) i.next();
-
- List resources = getFiles( resource.getDirectory() );
-
- for ( Iterator j = resources.iterator(); j.hasNext(); )
- {
- archetypeModel.addResource( clipToBasedir( (String) j.next(), basedir ) );
- }
- }
-
- // ----------------------------------------------------------------------
- // Test Sources
- // ----------------------------------------------------------------------
-
- // Typicall src/test/java, but could be different
- testSourceDirectory = clipToBasedir( project.getBuild().getTestSourceDirectory(), basedir );
-
- List testSources = getFiles( project.getBuild().getTestSourceDirectory() );
-
- for ( Iterator i = testSources.iterator(); i.hasNext(); )
- {
- archetypeModel.addTestSource( clipToBasedir( (String) i.next(), basedir ) );
- }
-
- // ----------------------------------------------------------------------
- // Test Resources
- // ----------------------------------------------------------------------
-
- List testResourceElements = project.getBuild().getResources();
-
- for ( Iterator i = testResourceElements.iterator(); i.hasNext(); )
- {
- Resource resource = (Resource) i.next();
-
- List resources = getFiles( resource.getDirectory() );
-
- for ( Iterator j = resources.iterator(); j.hasNext(); )
- {
- archetypeModel.addTestResource( clipToBasedir( (String) j.next(), basedir ) );
- }
- }
- }
- catch ( IOException e )
- {
- throw new ArchetypeCreationException( "Error reading source directory specified in the source POM.", e );
- }
-
- // ----------------------------------------------------------------------
- // Write out the archetype model
- // ----------------------------------------------------------------------
-
- File archetypeModelFile = new File( targetDirectory, "archetype.xml" );
-
- try
- {
- archetypeModelWriter.write( new FileWriter( archetypeModelFile ), archetypeModel );
-
- }
- catch ( IOException e )
- {
- throw new ArchetypeCreationException( "Error writing archetype model file.", e );
- }
-
- // ----------------------------------------------------------------------
- // Create the POM which needs to have ${variables} plugged into the POM.
- // We need to put in the ${variables} into the model that will be
- // substituted in when a user creates a project from this archetype
- //
- // -> groupId
- // -> artifactId
- // -> version
- // -> ${name}
- // ----------------------------------------------------------------------
-
- Model model = null;
-
- try
- {
- model = modelReader.read( new FileReader( project.getFile() ) );
- }
- catch ( Exception e )
- {
- // do nothing as the POM was already parsed, I just need the model here because the model
- // coming in with the POM seems to polluted with runtime values.
- }
-
- model.setGroupId( "${groupId}" );
-
- model.setArtifactId( "${artifactId}" );
-
- model.setVersion( "${version}" );
-
- model.setName( "${name}" );
-
- File pomFile = new File( targetDirectory, "pom.xml" );
-
- try
- {
- modelWriter.write( new FileWriter( pomFile ), model );
- }
- catch ( IOException e )
- {
- throw new ArchetypeCreationException( "Error writing archetype.", e );
- }
-
- // ----------------------------------------------------------------------
- //
- // ----------------------------------------------------------------------
-
- File finalDir = new File( basedir, "target/archetype-project" );
-
- if ( !finalDir.exists() )
- {
- finalDir.mkdirs();
- }
-
- try
- {
- String basePackage = properties.getProperty( "package" );
-
- // Create a directory where we can drop the filtered project files
- File filterDir = new File( basedir, "target/filtered-project" );
-
- // Use the model/project values to copy the sources
- filterCopy( new File( basedir, sourceDirectory ), new File( filterDir, sourceDirectory ), properties );
-
- // Use the model/project values to copy the test sources
- filterCopy( new File( basedir, testSourceDirectory ), new File( filterDir, testSourceDirectory ),
- properties );
-
- // Now we need to remove the portion of the path that corresonds to package that was used in the
- // archetype master so that when a user generates from it they can specify their own package path
- // to be used. So we need to copy from:
- //
- // [filterDir]/src/main/java/${package}/..
- // to
- // [finalDir]/srcm/main/java/
-
- File finalSourceDir = new File( finalDir, sourceDirectory );
- FileUtils.copyDirectoryStructure( new File( sourceDirectory, basePackage ), finalSourceDir );
-
- File finalTestSourceDir = new File( finalDir, testSourceDirectory );
- FileUtils.copyDirectoryStructure( new File( testSourceDirectory, basePackage ), finalTestSourceDir );
- }
- catch ( IOException e )
- {
- throw new ArchetypeCreationException( "Error copying and filtering archetype resources.", e );
- }
-
- File archetypeJar = new File( targetDirectory, "archetype.jar" );
-
- try
- {
- // ----------------------------------------------------------------------
- // New Format
- // ----------------------------------------------------------------------
-
- archiver.addFile( archetypeModelFile, "META-INF/maven/archetype.xml" );
-
- archiver.addFile( pomFile, "pom.xml" );
-
- archiver.addDirectory( finalDir );
-
- // ----------------------------------------------------------------------
- // Old Format
- // ----------------------------------------------------------------------
-
- archiver.addFile( pomFile, "archetype-resources/pom.xml" );
-
- archiver.addFile( archetypeModelFile, "META-INF/archetype.xml" );
-
- archiver.addDirectory( finalDir, "archetype-resources/" );
-
- archiver.setDestFile( archetypeJar );
-
- archiver.createArchive();
- }
- catch ( Exception e )
- {
- throw new ArchetypeCreationException( "Error creating archetype JAR.", e );
- }
-
- return archetypeJar;
- }
-
- private List getFiles( String directory )
- throws IOException
- {
- File f = new File( directory );
-
- if ( !f.exists() )
- {
- return Collections.EMPTY_LIST;
- }
-
- return FileUtils.getFileNames( f, "**/**", "**/.svn/**", true );
- }
-
- private void filterCopy( File source, File target, Properties properties )
- throws IOException
- {
- String basePackage = properties.getProperty( "package" );
- FileUtils.copyDirectoryStructure( source, target, new FilteringCopier( basePackage, "${package}" ) );
- }
-}
-
diff --git a/maven-archetype/maven-archetype-creator/src/main/java/org/apache/maven/archetype/FileUtils.java b/maven-archetype/maven-archetype-creator/src/main/java/org/apache/maven/archetype/FileUtils.java
deleted file mode 100644
index 9296a1c..0000000
--- a/maven-archetype/maven-archetype-creator/src/main/java/org/apache/maven/archetype/FileUtils.java
+++ /dev/null
@@ -1,1574 +0,0 @@
-package org.apache.maven.archetype;
-
-/*
- * Copyright 2004-2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import org.codehaus.plexus.util.DirectoryScanner;
-import org.codehaus.plexus.util.IOUtil;
-import org.codehaus.plexus.util.StringUtils;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.text.DecimalFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Random;
-import java.util.Vector;
-
-/**
- * This class provides basic facilities for manipulating files and file paths.
- * <p/>
- * <h3>Path-related methods</h3>
- * <p/>
- * <p>Methods exist to retrieve the components of a typical file path. For example
- * <code>/www/hosted/mysite/index.html</code>, can be broken into:
- * <ul>
- * <li><code>/www/hosted/mysite/</code> -- retrievable through {@link #getPath}</li>
- * <li><code>index.html</code> -- retrievable through {@link #removePath}</li>
- * <li><code>/www/hosted/mysite/index</code> -- retrievable through {@link #removeExtension}</li>
- * <li><code>html</code> -- retrievable through {@link #getExtension}</li>
- * </ul>
- * There are also methods to {@link #catPath concatenate two paths}, {@link #resolveFile resolve a
- * path relative to a File} and {@link #normalize} a path.
- * </p>
- * <p/>
- * <h3>File-related methods</h3>
- * <p/>
- * There are methods to create a {@link #toFile File from a URL}, copy a
- * {@link #copyFileToDirectory File to a directory},
- * copy a {@link #copyFile File to another File},
- * copy a {@link #copyURLToFile URL's contents to a File},
- * as well as methods to {@link #deleteDirectory(File) delete} and {@link #cleanDirectory(File)
- * clean} a directory.
- * </p>
- * <p/>
- * Common {@link java.io.File} manipulation routines.
- * <p/>
- * Taken from the commons-utils repo.
- * Also code from Alexandria's FileUtils.
- * And from Avalon Excalibur's IO.
- * And from Ant.
- *
- * @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</A>
- * @author <a href="mailto:sanders@codehaus.org">Scott Sanders</a>
- * @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
- * @author <a href="mailto:Christoph.Reck@dlr.de">Christoph.Reck</a>
- * @author <a href="mailto:peter@codehaus.org">Peter Donald</a>
- * @author <a href="mailto:jefft@codehaus.org">Jeff Turner</a>
- * @version $Id$
- */
-public class FileUtils
-{
- /**
- * The number of bytes in a kilobyte.
- */
- public static final int ONE_KB = 1024;
-
- /**
- * The number of bytes in a megabyte.
- */
- public static final int ONE_MB = ONE_KB * ONE_KB;
-
- /**
- * The number of bytes in a gigabyte.
- */
- public static final int ONE_GB = ONE_KB * ONE_MB;
-
- public static String[] getDefaultExcludes()
- {
- return DirectoryScanner.DEFAULTEXCLUDES;
- }
-
- public static List getDefaultExcludesAsList()
- {
- return Arrays.asList( getDefaultExcludes() );
- }
-
- /**
- * Returns a human-readable version of the file size (original is in
- * bytes).
- *
- * @param size The number of bytes.
- * @return A human-readable display value (includes units).
- */
- public static String byteCountToDisplaySize( int size )
- {
- String displaySize;
-
- if ( size / ONE_GB > 0 )
- {
- displaySize = String.valueOf( size / ONE_GB ) + " GB";
- }
- else if ( size / ONE_MB > 0 )
- {
- displaySize = String.valueOf( size / ONE_MB ) + " MB";
- }
- else if ( size / ONE_KB > 0 )
- {
- displaySize = String.valueOf( size / ONE_KB ) + " KB";
- }
- else
- {
- displaySize = String.valueOf( size ) + " bytes";
- }
-
- return displaySize;
- }
-
- /**
- * Returns the directory path portion of a file specification string.
- * Matches the equally named unix command.
- *
- * @return The directory portion excluding the ending file separator.
- */
- public static String dirname( String filename )
- {
- int i = filename.lastIndexOf( File.separator );
- return ( i >= 0 ? filename.substring( 0, i ) : "" );
- }
-
- /**
- * Returns the filename portion of a file specification string.
- *
- * @return The filename string with extension.
- */
- public static String filename( String filename )
- {
- int i = filename.lastIndexOf( File.separator );
- return ( i >= 0 ? filename.substring( i + 1 ) : filename );
- }
-
- /**
- * Returns the filename portion of a file specification string.
- * Matches the equally named unix command.
- *
- * @return The filename string without extension.
- */
- public static String basename( String filename )
- {
- return basename( filename, extension( filename ) );
- }
-
- /**
- * Returns the filename portion of a file specification string.
- * Matches the equally named unix command.
- */
- public static String basename( String filename, String suffix )
- {
- int i = filename.lastIndexOf( File.separator ) + 1;
- int lastDot = ( ( suffix != null ) && ( suffix.length() > 0 ) ) ? filename.lastIndexOf( suffix ) : -1;
-
- if ( lastDot >= 0 )
- {
- return filename.substring( i, lastDot );
- }
- else if ( i > 0 )
- {
- return filename.substring( i );
- }
- else
- {
- return filename; // else returns all (no path and no extension)
- }
- }
-
- /**
- * Returns the extension portion of a file specification string.
- * This everything after the last dot '.' in the filename (NOT including
- * the dot).
- */
- public static String extension( String filename )
- {
- int lastDot = filename.lastIndexOf( '.' );
-
- if ( lastDot >= 0 )
- {
- return filename.substring( lastDot + 1 );
- }
- else
- {
- return "";
- }
- }
-
- /**
- * Check if a file exits.
- *
- * @param fileName The name of the file to check.
- * @return true if file exists.
- */
- public static boolean fileExists( String fileName )
- {
- File file = new File( fileName );
- return file.exists();
- }
-
- public static String fileRead( String file )
- throws IOException
- {
- return fileRead( new File( file ) );
- }
-
- public static String fileRead( File file )
- throws IOException
- {
- StringBuffer buf = new StringBuffer();
-
- FileInputStream in = null;
-
- try
- {
- in = new FileInputStream( file );
- int count;
- byte[] b = new byte[512];
- while ( ( count = in.read( b ) ) > 0 ) // blocking read
- {
- buf.append( new String( b, 0, count ) );
- }
- }
- finally
- {
- IOUtil.close( in );
- }
-
- return buf.toString();
- }
-
- /**
- * Appends data to a file. The file will be created if it does not exist.
- *
- * @param fileName The name of the file to write.
- * @param data The content to write to the file.
- */
- public static void fileAppend( String fileName, String data )
- throws IOException
- {
- FileOutputStream out = null;
- try
- {
- out = new FileOutputStream( fileName, true );
- out.write( data.getBytes() );
- }
- finally
- {
- IOUtil.close( out );
- }
- }
-
- /**
- * Writes data to a file. The file will be created if it does not exist.
- *
- * @param fileName The name of the file to write.
- * @param data The content to write to the file.
- */
- public static void fileWrite( String fileName, String data )
- throws IOException
- {
- FileOutputStream out = null;
- try
- {
- out = new FileOutputStream( fileName );
- out.write( data.getBytes() );
- }
- finally
- {
- IOUtil.close( out );
- }
- }
-
- /**
- * Deletes a file.
- *
- * @param fileName The name of the file to delete.
- */
- public static void fileDelete( String fileName )
- {
- File file = new File( fileName );
- file.delete();
- }
-
- /**
- * Waits for NFS to propagate a file creation, imposing a timeout.
- *
- * @param fileName The name of the file.
- * @param seconds The maximum time in seconds to wait.
- * @return True if file exists.
- */
- public static boolean waitFor( String fileName, int seconds )
- {
- return waitFor( new File( fileName ), seconds );
- }
-
- public static boolean waitFor( File file, int seconds )
- {
- int timeout = 0;
- int tick = 0;
- while ( !file.exists() )
- {
- if ( tick++ >= 10 )
- {
- tick = 0;
- if ( timeout++ > seconds )
- {
- return false;
- }
- }
- try
- {
- Thread.sleep( 100 );
- }
- catch ( InterruptedException ignore )
- {
- }
- }
- return true;
- }
-
- /**
- * Creates a file handle.
- *
- * @param fileName The name of the file.
- * @return A <code>File</code> manager.
- */
- public static File getFile( String fileName )
- {
- return new File( fileName );
- }
-
- /**
- * Given a directory and an array of extensions return an array of compliant files.
- * <p/>
- * TODO Should an ignore list be passed in?
- * TODO Should a recurse flag be passed in?
- * <p/>
- * The given extensions should be like "java" and not like ".java"
- */
- public static String[] getFilesFromExtension( String directory, String[] extensions )
- {
-
- Vector files = new Vector();
-
- java.io.File currentDir = new java.io.File( directory );
-
- String[] unknownFiles = currentDir.list();
-
- if ( unknownFiles == null )
- {
- return new String[0];
- }
-
- for ( int i = 0; i < unknownFiles.length; ++i )
- {
- String currentFileName = directory + System.getProperty( "file.separator" ) + unknownFiles[i];
- java.io.File currentFile = new java.io.File( currentFileName );
-
- if ( currentFile.isDirectory() )
- {
-
- //ignore all CVS directories...
- if ( currentFile.getName().equals( "CVS" ) )
- {
- continue;
- }
-
- //ok... transverse into this directory and get all the files... then combine
- //them with the current list.
-
- String[] fetchFiles = getFilesFromExtension( currentFileName, extensions );
- files = blendFilesToVector( files, fetchFiles );
-
- }
- else
- {
- //ok... add the file
-
- String add = currentFile.getAbsolutePath();
- if ( isValidFile( add, extensions ) )
- {
- files.addElement( add );
-
- }
-
- }
- }
-
- //ok... move the Vector into the files list...
-
- String[] foundFiles = new String[files.size()];
- files.copyInto( foundFiles );
-
- return foundFiles;
-
- }
-
-
- /**
- * Private hepler method for getFilesFromExtension()
- */
- private static Vector blendFilesToVector( Vector v, String[] files )
- {
-
- for ( int i = 0; i < files.length; ++i )
- {
- v.addElement( files[i] );
- }
-
- return v;
- }
-
- /**
- * Checks to see if a file is of a particular type(s).
- * Note that if the file does not have an extension, an empty string
- * ("") is matched for.
- */
- private static boolean isValidFile( String file, String[] extensions )
- {
-
- String extension = extension( file );
- if ( extension == null )
- {
- extension = "";
- }
-
- //ok.. now that we have the "extension" go through the current know
- //excepted extensions and determine if this one is OK.
-
- for ( int i = 0; i < extensions.length; ++i )
- {
- if ( extensions[i].equals( extension ) )
- {
- return true;
- }
- }
-
- return false;
-
- }
-
- /**
- * Simple way to make a directory
- */
- public static void mkdir( String dir )
- {
- File file = new File( dir );
- if ( !file.exists() )
- {
- file.mkdirs();
- }
- }
-
- /**
- * Compare the contents of two files to determine if they are equal or not.
- *
- * @param file1 the first file
- * @param file2 the second file
- * @return true if the content of the files are equal or they both don't exist, false otherwise
- */
- public static boolean contentEquals( final File file1, final File file2 )
- throws IOException
- {
- final boolean file1Exists = file1.exists();
- if ( file1Exists != file2.exists() )
- {
- return false;
- }
-
- if ( !file1Exists )
- {
- // two not existing files are equal
- return true;
- }
-
- if ( file1.isDirectory() || file2.isDirectory() )
- {
- // don't want to compare directory contents
- return false;
- }
-
- InputStream input1 = null;
- InputStream input2 = null;
- try
- {
- input1 = new FileInputStream( file1 );
- input2 = new FileInputStream( file2 );
- return IOUtil.contentEquals( input1, input2 );
-
- }
- finally
- {
- IOUtil.close( input1 );
- IOUtil.close( input2 );
- }
- }
-
- /**
- * Convert from a <code>URL</code> to a <code>File</code>.
- *
- * @param url File URL.
- * @return The equivalent <code>File</code> object, or <code>null</code> if the URL's protocol
- * is not <code>file</code>
- */
- public static File toFile( final URL url )
- {
- if ( url.getProtocol().equals( "file" ) == false )
- {
- return null;
- }
- else
- {
- final String filename = url.getFile().replace( '/', File.separatorChar );
- return new File( filename );
- }
- }
-
- /**
- * Convert the array of Files into a list of URLs.
- *
- * @param files the array of files
- * @return the array of URLs
- * @throws IOException if an error occurs
- */
- public static URL[] toURLs( final File[] files )
- throws IOException
- {
- final URL[] urls = new URL[files.length];
-
- for ( int i = 0; i < urls.length; i++ )
- {
- urls[i] = files[i].toURL();
- }
-
- return urls;
- }
-
- /**
- * Remove extension from filename.
- * ie
- * <pre>
- * foo.txt --> foo
- * a\b\c.jpg --> a\b\c
- * a\b\c --> a\b\c
- * </pre>
- *
- * @param filename the filename
- * @return the filename minus extension
- */
- public static String removeExtension( final String filename )
- {
- final int index = filename.lastIndexOf( '.' );
-
- if ( -1 == index )
- {
- return filename;
- }
- else
- {
- return filename.substring( 0, index );
- }
- }
-
- /**
- * Get extension from filename.
- * ie
- * <pre>
- * foo.txt --> "txt"
- * a\b\c.jpg --> "jpg"
- * a\b\c --> ""
- * </pre>
- *
- * @param filename the filename
- * @return the extension of filename or "" if none
- */
- public static String getExtension( final String filename )
- {
- final int index = filename.lastIndexOf( '.' );
-
- if ( -1 == index )
- {
- return "";
- }
- else
- {
- return filename.substring( index + 1 );
- }
- }
-
- /**
- * Remove path from filename. Equivalent to the unix command <code>basename</code>
- * ie.
- * <pre>
- * a/b/c.txt --> c.txt
- * a.txt --> a.txt
- * </pre>
- *
- * @param filepath the filepath
- * @return the filename minus path
- */
- public static String removePath( final String filepath )
- {
- return removePath( filepath, File.separatorChar );
- }
-
- /**
- * Remove path from filename.
- * ie.
- * <pre>
- * a/b/c.txt --> c.txt
- * a.txt --> a.txt
- * </pre>
- *
- * @param filepath the filepath
- * @return the filename minus path
- */
- public static String removePath( final String filepath, final char fileSeparatorChar )
- {
- final int index = filepath.lastIndexOf( fileSeparatorChar );
-
- if ( -1 == index )
- {
- return filepath;
- }
- else
- {
- return filepath.substring( index + 1 );
- }
- }
-
- /**
- * Get path from filename. Roughly equivalent to the unix command <code>dirname</code>.
- * ie.
- * <pre>
- * a/b/c.txt --> a/b
- * a.txt --> ""
- * </pre>
- *
- * @param filepath the filepath
- * @return the filename minus path
- */
- public static String getPath( final String filepath )
- {
- return getPath( filepath, File.separatorChar );
- }
-
- /**
- * Get path from filename.
- * ie.
- * <pre>
- * a/b/c.txt --> a/b
- * a.txt --> ""
- * </pre>
- *
- * @param filepath the filepath
- * @return the filename minus path
- */
- public static String getPath( final String filepath, final char fileSeparatorChar )
- {
- final int index = filepath.lastIndexOf( fileSeparatorChar );
- if ( -1 == index )
- {
- return "";
- }
- else
- {
- return filepath.substring( 0, index );
- }
- }
-
- /**
- * Copy file from source to destination. If <code>destinationDirectory</code> does not exist, it
- * (and any parent directories) will be created. If a file <code>source</code> in
- * <code>destinationDirectory</code> exists, it will be overwritten.
- *
- * @param source An existing <code>File</code> to copy.
- * @param destinationDirectory A directory to copy <code>source</code> into.
- * @throws java.io.FileNotFoundException if <code>source</code> isn't a normal file.
- * @throws IllegalArgumentException if <code>destinationDirectory</code> isn't a directory.
- * @throws IOException if <code>source</code> does not exist, the file in
- * <code>destinationDirectory</code> cannot be written to, or an IO error occurs during copying.
- */
- public static void copyFileToDirectory( final String source, final String destinationDirectory )
- throws IOException
- {
- copyFileToDirectory( new File( source ), new File( destinationDirectory ), standardCopier );
- }
-
- public static void copyFileToDirectory( final String source, final String destinationDirectory,
- final Copier copier )
- throws IOException
- {
- copyFileToDirectory( new File( source ), new File( destinationDirectory ), copier );
- }
-
- /**
- * Copy file from source to destination. If <code>destinationDirectory</code> does not exist, it
- * (and any parent directories) will be created. If a file <code>source</code> in
- * <code>destinationDirectory</code> exists, it will be overwritten.
- *
- * @param source An existing <code>File</code> to copy.
- * @param destinationDirectory A directory to copy <code>source</code> into.
- * @throws java.io.FileNotFoundException if <code>source</code> isn't a normal file.
- * @throws IllegalArgumentException if <code>destinationDirectory</code> isn't a directory.
- * @throws IOException if <code>source</code> does not exist, the file in
- * <code>destinationDirectory</code> cannot be written to, or an IO error occurs during copying.
- */
-
- public static void copyFileToDirectory( final File source, final File destinationDirectory )
- throws IOException
- {
- copyFileToDirectory( source, destinationDirectory, standardCopier );
- }
-
-
- public static void copyFileToDirectory( final File source, final File destinationDirectory, final Copier copier )
- throws IOException
- {
- if ( destinationDirectory.exists() && !destinationDirectory.isDirectory() )
- {
- throw new IllegalArgumentException( "Destination is not a directory" );
- }
-
- copyFile( source, new File( destinationDirectory, source.getName() ), copier );
- }
-
- /**
- * Copy file from source to destination. The directories up to <code>destination</code> will be
- * created if they don't already exist. <code>destination</code> will be overwritten if it
- * already exists.
- *
- * @param source An existing non-directory <code>File</code> to copy bytes from.
- * @param destination A non-directory <code>File</code> to write bytes to (possibly
- * overwriting).
- * @throws IOException if <code>source</code> does not exist, <code>destination</code> cannot be
- * written to, or an IO error occurs during copying.
- * @throws java.io.FileNotFoundException if <code>destination</code> is a directory
- * (use {@link #copyFileToDirectory}).
- */
-
- static Copier standardCopier = new StandardCopier();
-
- public static void copyFile( final File source, final File destination )
- throws IOException
- {
- copyFile( source, destination, standardCopier );
- }
-
- public static void copyFile( final File source, final File destination, Copier copier )
- throws IOException
- {
- //check source exists
- if ( !source.exists() )
- {
- final String message = "File " + source + " does not exist";
- throw new IOException( message );
- }
-
- //does destinations directory exist ?
- if ( destination.getParentFile() != null && !destination.getParentFile().exists() )
- {
- destination.getParentFile().mkdirs();
- }
-
- //make sure we can write to destination
- if ( destination.exists() && !destination.canWrite() )
- {
- final String message = "Unable to open file " + destination + " for writing.";
- throw new IOException( message );
- }
-
- copier.copy( source, destination );
-
- /*
-
- This isn't true if you are filtering while copying
-
- if ( source.length() != destination.length() )
- {
- final String message = "Failed to copy full contents from " + source +
- " to " + destination;
- throw new IOException( message );
- }
- */
- }
-
- /**
- * Copies bytes from the URL <code>source</code> to a file <code>destination</code>.
- * The directories up to <code>destination</code> will be created if they don't already exist.
- * <code>destination</code> will be overwritten if it already exists.
- *
- * @param source A <code>URL</code> to copy bytes from.
- * @param destination A non-directory <code>File</code> to write bytes to (possibly
- * overwriting).
- * @throws IOException if
- * <ul>
- * <li><code>source</code> URL cannot be opened</li>
- * <li><code>destination</code> cannot be written to</li>
- * <li>an IO error occurs during copying</li>
- * </ul>
- */
- public static void copyURLToFile( final URL source, final File destination )
- throws IOException
- {
- //does destination directory exist ?
- if ( destination.getParentFile() != null && !destination.getParentFile().exists() )
- {
- destination.getParentFile().mkdirs();
- }
-
- //make sure we can write to destination
- if ( destination.exists() && !destination.canWrite() )
- {
- final String message = "Unable to open file " + destination + " for writing.";
- throw new IOException( message );
- }
-
- InputStream input = null;
- FileOutputStream output = null;
- try
- {
- input = source.openStream();
- output = new FileOutputStream( destination );
- IOUtil.copy( input, output );
- }
- finally
- {
- IOUtil.close( input );
- IOUtil.close( output );
- }
- }
-
- /**
- * Normalize a path.
- * Eliminates "/../" and "/./" in a string. Returns <code>null</code> if the ..'s went past the
- * root.
- * Eg:
- * <pre>
- * /foo// --> /foo/
- * /foo/./ --> /foo/
- * /foo/../bar --> /bar
- * /foo/../bar/ --> /bar/
- * /foo/../bar/../baz --> /baz
- * //foo//./bar --> /foo/bar
- * /../ --> null
- * </pre>
- *
- * @param path the path to normalize
- * @return the normalized String, or <code>null</code> if too many ..'s.
- */
- public static String normalize( final String path )
- {
- String normalized = path;
- // Resolve occurrences of "//" in the normalized path
- while ( true )
- {
- int index = normalized.indexOf( "//" );
- if ( index < 0 )
- {
- break;
- }
- normalized = normalized.substring( 0, index ) + normalized.substring( index + 1 );
- }
-
- // Resolve occurrences of "/./" in the normalized path
- while ( true )
- {
- int index = normalized.indexOf( "/./" );
- if ( index < 0 )
- {
- break;
- }
- normalized = normalized.substring( 0, index ) + normalized.substring( index + 2 );
- }
-
- // Resolve occurrences of "/../" in the normalized path
- while ( true )
- {
- int index = normalized.indexOf( "/../" );
- if ( index < 0 )
- {
- break;
- }
- if ( index == 0 )
- {
- return null; // Trying to go outside our context
- }
- int index2 = normalized.lastIndexOf( '/', index - 1 );
- normalized = normalized.substring( 0, index2 ) + normalized.substring( index + 3 );
- }
-
- // Return the normalized path that we have completed
- return normalized;
- }
-
- /**
- * Will concatenate 2 paths. Paths with <code>..</code> will be
- * properly handled.
- * <p>Eg.,<br />
- * <code>/a/b/c</code> + <code>d</code> = <code>/a/b/d</code><br />
- * <code>/a/b/c</code> + <code>../d</code> = <code>/a/d</code><br />
- * </p>
- * <p/>
- * Thieved from Tomcat sources...
- *
- * @return The concatenated paths, or null if error occurs
- */
- public static String catPath( final String lookupPath, final String path )
- {
- // Cut off the last slash and everything beyond
- int index = lookupPath.lastIndexOf( "/" );
- String lookup = lookupPath.substring( 0, index );
- String pth = path;
-
- // Deal with .. by chopping dirs off the lookup path
- while ( pth.startsWith( "../" ) )
- {
- if ( lookup.length() > 0 )
- {
- index = lookup.lastIndexOf( "/" );
- lookup = lookup.substring( 0, index );
- }
- else
- {
- // More ..'s than dirs, return null
- return null;
- }
-
- index = pth.indexOf( "../" ) + 3;
- pth = pth.substring( index );
- }
-
- return new StringBuffer( lookup ).append( "/" ).append( pth ).toString();
- }
-
- /**
- * Resolve a file <code>filename</code> to it's canonical form. If <code>filename</code> is
- * relative (doesn't start with <code>/</code>), it will be resolved relative to
- * <code>baseFile</code>, otherwise it is treated as a normal root-relative path.
- *
- * @param baseFile Where to resolve <code>filename</code> from, if <code>filename</code> is
- * relative.
- * @param filename Absolute or relative file path to resolve.
- * @return The canonical <code>File</code> of <code>filename</code>.
- */
- public static File resolveFile( final File baseFile, String filename )
- {
- String filenm = filename;
- if ( '/' != File.separatorChar )
- {
- filenm = filename.replace( '/', File.separatorChar );
- }
-
- if ( '\\' != File.separatorChar )
- {
- filenm = filename.replace( '\\', File.separatorChar );
- }
-
- // deal with absolute files
- if ( filenm.startsWith( File.separator ) )
- {
- File file = new File( filenm );
-
- try
- {
- file = file.getCanonicalFile();
- }
- catch ( final IOException ioe )
- {
- }
-
- return file;
- }
- // FIXME: I'm almost certain this // removal is unnecessary, as getAbsoluteFile() strips
- // them. However, I'm not sure about this UNC stuff. (JT)
- final char[] chars = filename.toCharArray();
- final StringBuffer sb = new StringBuffer();
-
- //remove duplicate file separators in succession - except
- //on win32 at start of filename as UNC filenames can
- //be \\AComputer\AShare\myfile.txt
- int start = 0;
- if ( '\\' == File.separatorChar )
- {
- sb.append( filenm.charAt( 0 ) );
- start++;
- }
-
- for ( int i = start; i < chars.length; i++ )
- {
- final boolean doubleSeparator = File.separatorChar == chars[i] && File.separatorChar == chars[i - 1];
-
- if ( !doubleSeparator )
- {
- sb.append( chars[i] );
- }
- }
-
- filenm = sb.toString();
-
- //must be relative
- File file = ( new File( baseFile, filenm ) ).getAbsoluteFile();
-
- try
- {
- file = file.getCanonicalFile();
- }
- catch ( final IOException ioe )
- {
- }
-
- return file;
- }
-
- /**
- * Delete a file. If file is directory delete it and all sub-directories.
- */
- public static void forceDelete( final String file )
- throws IOException
- {
- forceDelete( new File( file ) );
- }
-
- /**
- * Delete a file. If file is directory delete it and all sub-directories.
- */
- public static void forceDelete( final File file )
- throws IOException
- {
- if ( ! file.exists() )
- {
- return;
- }
-
- if ( file.isDirectory() )
- {
- deleteDirectory( file );
- }
- else
- {
- if ( !file.delete() )
- {
- final String message = "File " + file + " unable to be deleted.";
- throw new IOException( message );
- }
- }
- }
-
- /**
- * Schedule a file to be deleted when JVM exits.
- * If file is directory delete it and all sub-directories.
- */
- public static void forceDeleteOnExit( final File file )
- throws IOException
- {
- if ( ! file.exists() )
- {
- return;
- }
-
- if ( file.isDirectory() )
- {
- deleteDirectoryOnExit( file );
- }
- else
- {
- file.deleteOnExit();
- }
- }
-
- /**
- * Recursively schedule directory for deletion on JVM exit.
- */
- private static void deleteDirectoryOnExit( final File directory )
- throws IOException
- {
- if ( !directory.exists() )
- {
- return;
- }
-
- cleanDirectoryOnExit( directory );
- directory.deleteOnExit();
- }
-
- /**
- * Clean a directory without deleting it.
- */
- private static void cleanDirectoryOnExit( final File directory )
- throws IOException
- {
- if ( !directory.exists() )
- {
- final String message = directory + " does not exist";
- throw new IllegalArgumentException( message );
- }
-
- if ( !directory.isDirectory() )
- {
- final String message = directory + " is not a directory";
- throw new IllegalArgumentException( message );
- }
-
- IOException exception = null;
-
- final File[] files = directory.listFiles();
- for ( int i = 0; i < files.length; i++ )
- {
- final File file = files[i];
- try
- {
- forceDeleteOnExit( file );
- }
- catch ( final IOException ioe )
- {
- exception = ioe;
- }
- }
-
- if ( null != exception )
- {
- throw exception;
- }
- }
-
-
- /**
- * Make a directory. If there already exists a file with specified name or
- * the directory is unable to be created then an exception is thrown.
- */
- public static void forceMkdir( final File file )
- throws IOException
- {
- if ( file.exists() )
- {
- if ( file.isFile() )
- {
- final String message =
- "File " + file + " exists and is " + "not a directory. Unable to create directory.";
- throw new IOException( message );
- }
- }
- else
- {
- if ( false == file.mkdirs() )
- {
- final String message = "Unable to create directory " + file;
- throw new IOException( message );
- }
- }
- }
-
- /**
- * Recursively delete a directory.
- */
- public static void deleteDirectory( final String directory )
- throws IOException
- {
- deleteDirectory( new File( directory ) );
- }
-
- /**
- * Recursively delete a directory.
- */
- public static void deleteDirectory( final File directory )
- throws IOException
- {
- if ( !directory.exists() )
- {
- return;
- }
-
- cleanDirectory( directory );
- if ( !directory.delete() )
- {
- final String message = "Directory " + directory + " unable to be deleted.";
- throw new IOException( message );
- }
- }
-
- /**
- * Clean a directory without deleting it.
- */
- public static void cleanDirectory( final String directory )
- throws IOException
- {
- cleanDirectory( new File( directory ) );
- }
-
- /**
- * Clean a directory without deleting it.
- */
- public static void cleanDirectory( final File directory )
- throws IOException
- {
- if ( !directory.exists() )
- {
- final String message = directory + " does not exist";
- throw new IllegalArgumentException( message );
- }
-
- if ( !directory.isDirectory() )
- {
- final String message = directory + " is not a directory";
- throw new IllegalArgumentException( message );
- }
-
- IOException exception = null;
-
- final File[] files = directory.listFiles();
- for ( int i = 0; i < files.length; i++ )
- {
- final File file = files[i];
- try
- {
- forceDelete( file );
- }
- catch ( final IOException ioe )
- {
- exception = ioe;
- }
- }
-
- if ( null != exception )
- {
- throw exception;
- }
- }
-
- /**
- * Recursively count size of a directory.
- *
- * @return size of directory in bytes.
- */
- public static long sizeOfDirectory( final String directory )
- {
- return sizeOfDirectory( new File( directory ) );
- }
-
- /**
- * Recursively count size of a directory.
- *
- * @return size of directory in bytes.
- */
- public static long sizeOfDirectory( final File directory )
- {
- if ( !directory.exists() )
- {
- final String message = directory + " does not exist";
- throw new IllegalArgumentException( message );
- }
-
- if ( !directory.isDirectory() )
- {
- final String message = directory + " is not a directory";
- throw new IllegalArgumentException( message );
- }
-
- long size = 0;
-
- final File[] files = directory.listFiles();
- for ( int i = 0; i < files.length; i++ )
- {
- final File file = files[i];
-
- if ( file.isDirectory() )
- {
- size += sizeOfDirectory( file );
- }
- else
- {
- size += file.length();
- }
- }
-
- return size;
- }
-
- public static List getFiles( File directory, String includes, String excludes )
- throws IOException
- {
- return getFiles( directory, includes, excludes, true );
- }
-
- public static List getFiles( File directory, String includes, String excludes, boolean includeBasedir )
- throws IOException
- {
- List fileNames = getFileNames( directory, includes, excludes, includeBasedir );
-
- List files = new ArrayList();
-
- for ( Iterator i = fileNames.iterator(); i.hasNext(); )
- {
- files.add( new File( (String) i.next() ) );
- }
-
- return files;
- }
-
- public static String FS = System.getProperty( "file.separator" );
-
- /**
- * Return a list of files as String depending options.
- * This method use case sensitive file name.
- *
- * @param directory the directory to scan
- * @param includes the includes pattern, comma separated
- * @param excludes the excludes pattern, comma separated
- * @param includeBasedir true to include the base dir in each String of file
- * @return a list of files as String
- * @throws IOException
- */
- public static List getFileNames( File directory, String includes, String excludes, boolean includeBasedir )
- throws IOException
- {
- return getFileNames( directory, includes, excludes, includeBasedir, true );
- }
-
- /**
- * Return a list of files as String depending options.
- *
- * @param directory the directory to scan
- * @param includes the includes pattern, comma separated
- * @param excludes the excludes pattern, comma separated
- * @param includeBasedir true to include the base dir in each String of file
- * @param isCaseSensitive true if case sensitive
- * @return a list of files as String
- * @throws IOException
- */
- public static List getFileNames( File directory, String includes, String excludes, boolean includeBasedir,
- boolean isCaseSensitive )
- throws IOException
- {
- DirectoryScanner scanner = new DirectoryScanner();
-
- scanner.setBasedir( directory );
-
- if ( includes != null )
- {
- scanner.setIncludes( StringUtils.split( includes, "," ) );
- }
-
- if ( excludes != null )
- {
- scanner.setExcludes( StringUtils.split( excludes, "," ) );
- }
-
- scanner.setCaseSensitive( isCaseSensitive );
-
- scanner.scan();
-
- String[] files = scanner.getIncludedFiles();
-
- List list = new ArrayList();
-
- for ( int i = 0; i < files.length; i++ )
- {
- if ( includeBasedir )
- {
- list.add( directory + FileUtils.FS + files[i] );
- }
- else
- {
- list.add( files[i] );
- }
- }
-
- return list;
- }
-
- public static void copyDirectory( File sourceDirectory, File destinationDirectory )
- throws IOException
- {
- copyDirectory( sourceDirectory, destinationDirectory, "**", null );
- }
-
- public static void copyDirectory( File sourceDirectory, File destinationDirectory, String includes,
- String excludes )
- throws IOException
- {
- copyDirectory( sourceDirectory, destinationDirectory, includes, excludes, standardCopier );
- }
-
- public static void copyDirectory( File sourceDirectory, File destinationDirectory, String includes, String excludes,
- Copier copier )
- throws IOException
- {
- if ( ! sourceDirectory.exists() )
- {
- return;
- }
-
- List files = getFiles( sourceDirectory, includes, excludes );
-
- for ( Iterator i = files.iterator(); i.hasNext(); )
- {
- File file = (File) i.next();
-
- copyFileToDirectory( file, destinationDirectory, copier );
- }
- }
-
- /**
- * Copies a entire directory structure.
- * <p/>
- * Note:
- * <ul>
- * <li>It will include empty directories.
- * <li>The <code>sourceDirectory</code> must exists.
- * </ul>
- *
- * @param sourceDirectory
- * @param destinationDirectory
- * @throws IOException
- */
- public static void copyDirectoryStructure( File sourceDirectory, File destinationDirectory )
- throws IOException
- {
- copyDirectoryStructure( sourceDirectory, destinationDirectory, standardCopier );
- }
-
-
- public static void copyDirectoryStructure( File sourceDirectory, File destinationDirectory, Copier copier )
- throws IOException
- {
- if ( !sourceDirectory.exists() )
- {
- throw new IOException( "Source directory doesn't exists (" + sourceDirectory.getAbsolutePath() + ")." );
- }
-
- File[] files = sourceDirectory.listFiles();
-
- String sourcePath = sourceDirectory.getAbsolutePath();
-
- for ( int i = 0; i < files.length; i++ )
- {
- File file = files[i];
-
- String dest = file.getAbsolutePath();
-
- dest = dest.substring( sourcePath.length() + 1 );
-
- File destination = new File( destinationDirectory, dest );
-
- if ( file.isFile() )
- {
- destination = destination.getParentFile();
-
- FileUtils.copyFileToDirectory( file, destination, copier );
- }
- else if ( file.isDirectory() )
- {
- if ( !destination.exists() && !destination.mkdirs() )
- {
- throw new IOException(
- "Could not create destination directory '" + destination.getAbsolutePath() + "'." );
- }
-
- copyDirectoryStructure( file, destination, copier );
- }
- else
- {
- throw new IOException( "Unknown file type: " + file.getAbsolutePath() );
- }
- }
- }
-
-
- /**
- * Renames a file, even if that involves crossing file system boundaries.
- * <p/>
- * <p>This will remove <code>to</code> (if it exists), ensure that
- * <code>to</code>'s parent directory exists and move
- * <code>from</code>, which involves deleting <code>from</code> as
- * well.</p>
- *
- * @param from the file to move
- * @param to the new file name
- * @throws IOException if anything bad happens during this
- * process. Note that <code>to</code> may have been deleted
- * already when this happens.
- */
- public static void rename( File from, File to )
- throws IOException
- {
- if ( to.exists() && !to.delete() )
- {
- throw new IOException( "Failed to delete " + to + " while trying to rename " + from );
- }
-
- File parent = to.getParentFile();
- if ( parent != null && !parent.exists() && !parent.mkdirs() )
- {
- throw new IOException( "Failed to create directory " + parent + " while trying to rename " + from );
- }
-
- if ( !from.renameTo( to ) )
- {
- copyFile( from, to );
- if ( !from.delete() )
- {
- throw new IOException( "Failed to delete " + from + " while trying to rename it." );
- }
- }
- }
-
- /**
- * Create a temporary file in a given directory.
- * <p/>
- * <p>The file denoted by the returned abstract pathname did not
- * exist before this method was invoked, any subsequent invocation
- * of this method will yield a different file name.</p>
- * <p/>
- * The filename is prefixNNNNNsuffix where NNNN is a random number
- * </p>
- * <p>This method is different to File.createTempFile of JDK 1.2
- * as it doesn't create the file itself.
- * It uses the location pointed to by java.io.tmpdir
- * when the parentDir attribute is
- * null.</p>
- *
- * @param prefix prefix before the random number
- * @param suffix file extension; include the '.'
- * @param parentDir Directory to create the temporary file in -
- * java.io.tmpdir used if not specificed
- * @return a File reference to the new temporary file.
- */
- public static File createTempFile( String prefix, String suffix, File parentDir )
- {
-
- File result = null;
- String parent = System.getProperty( "java.io.tmpdir" );
- if ( parentDir != null )
- {
- parent = parentDir.getPath();
- }
- DecimalFormat fmt = new DecimalFormat( "#####" );
- Random rand = new Random( System.currentTimeMillis() + Runtime.getRuntime().freeMemory() );
- synchronized ( rand )
- {
- do
- {
- result = new File( parent, prefix + fmt.format( Math.abs( rand.nextInt() ) ) + suffix );
- }
- while ( result.exists() );
- }
- return result;
- }
-}
diff --git a/maven-archetype/maven-archetype-creator/src/main/java/org/apache/maven/archetype/FilteringCopier.java b/maven-archetype/maven-archetype-creator/src/main/java/org/apache/maven/archetype/FilteringCopier.java
deleted file mode 100644
index 9f261e1..0000000
--- a/maven-archetype/maven-archetype-creator/src/main/java/org/apache/maven/archetype/FilteringCopier.java
+++ /dev/null
@@ -1,124 +0,0 @@
-package org.apache.maven.archetype;
-
-/*
- * Copyright 2004-2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import org.apache.oro.text.regex.Pattern;
-import org.apache.oro.text.regex.PatternCompiler;
-import org.apache.oro.text.regex.PatternMatcher;
-import org.apache.oro.text.regex.Perl5Compiler;
-import org.apache.oro.text.regex.Perl5Matcher;
-import org.apache.oro.text.regex.Perl5Substitution;
-import org.apache.oro.text.regex.Util;
-import org.codehaus.plexus.util.IOUtil;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-/**
- * @author Jason van Zyl
- * @version $Revision:$
- */
-public class FilteringCopier
- implements Copier
-{
- private String find;
-
- private String replace;
-
- PatternMatcher matcher = new Perl5Matcher();
-
- Pattern pattern = null;
-
- PatternCompiler compiler = new Perl5Compiler();
-
- String regularExpression, input, sub, result;
-
- public FilteringCopier( String find, String replace )
- {
- this.find = find;
-
- this.replace = replace;
- }
-
- public void copy( File source, File destination )
- throws IOException
- {
- InputStream input = null;
-
- OutputStream output = null;
-
- try
- {
- /*
- input = new ReplaceStringInputStream( new FileInputStream( source ), find, replace );
-
- output = new FileOutputStream( destination );
-
- IOUtil.copy( input, output );
- */
-
- //input = new ReplaceStringInputStream( new FileInputStream( source ), find, replace );
-
- input = new FileInputStream( source );
-
- String s = streamToString( input );
-
- pattern = compiler.compile( find );
-
- // Perform substitution and print result.
- result = Util.substitute( matcher, pattern,
- new Perl5Substitution( replace, Perl5Substitution.INTERPOLATE_ALL ), s,
- Util.SUBSTITUTE_ALL );
-
- FileUtils.fileWrite( destination.getAbsolutePath(), result );
-
- }
- catch ( Exception e )
- {
- e.printStackTrace();
- }
- finally
- {
- IOUtil.close( input );
-
- IOUtil.close( output );
- }
- }
-
- public static String streamToString( InputStream in )
- throws IOException
- {
- StringBuffer text = new StringBuffer();
- try
- {
- int b;
- while ( ( b = in.read() ) != -1 )
- {
- text.append( (char) b );
- }
- }
- finally
- {
- in.close();
- }
- return text.toString();
- }
-
-}
diff --git a/maven-archetype/maven-archetype-creator/src/main/java/org/apache/maven/archetype/StandardCopier.java b/maven-archetype/maven-archetype-creator/src/main/java/org/apache/maven/archetype/StandardCopier.java
deleted file mode 100644
index c85eb85..0000000
--- a/maven-archetype/maven-archetype-creator/src/main/java/org/apache/maven/archetype/StandardCopier.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package org.apache.maven.archetype;
-
-/*
- * Copyright 2004-2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import org.codehaus.plexus.util.IOUtil;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-
-/**
- * @author Jason van Zyl
- * @version $Revision:$
- */
-public class StandardCopier
- implements Copier
-{
- public void copy( File source, File destination )
- throws IOException
- {
- FileInputStream input = null;
-
- FileOutputStream output = null;
-
- try
- {
- input = new FileInputStream( source );
-
- output = new FileOutputStream( destination );
-
- IOUtil.copy( input, output );
- }
- finally
- {
- IOUtil.close( input );
-
- IOUtil.close( output );
- }
- }
-}
diff --git a/maven-archetype/maven-archetype-creator/src/test/java/org/apache/maven/archetype/DefaultArchetypeCreatorTest.java b/maven-archetype/maven-archetype-creator/src/test/java/org/apache/maven/archetype/DefaultArchetypeCreatorTest.java
deleted file mode 100644
index e9b0b1f..0000000
--- a/maven-archetype/maven-archetype-creator/src/test/java/org/apache/maven/archetype/DefaultArchetypeCreatorTest.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package org.apache.maven.archetype;
-
-/*
- * Copyright 2004-2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import org.codehaus.plexus.PlexusTestCase;
-
-import java.io.File;
-
-public class DefaultArchetypeCreatorTest
- extends PlexusTestCase
-{
- public void testArchetypeCreator()
- throws Exception
- {
- ArchetypeCreator creator = (ArchetypeCreator) lookup( ArchetypeCreator.ROLE );
-
- File pom = new File( getBasedir(), "pom.xml" );
- }
-}
diff --git a/maven-archetype/maven-archetype-model/archetype-model.xml b/maven-archetype/maven-archetype-model/archetype-model.xml
deleted file mode 100644
index 36fe0f0..0000000
--- a/maven-archetype/maven-archetype-model/archetype-model.xml
+++ /dev/null
@@ -1,85 +0,0 @@
-<archetype>
- <id>quickstart</id>
- <fileSets>
-
- <!--
-
- o filtering
- o arbitrary directories even if it to make the job easier internally. we
- really don't want people making any sort of directory structure they
- want.
- o a tool to create archetypes easily
-
- <plugin>
- <id>maven-archetype-plugin</id>
- <executions>
- <execution>
- <goals>
- <goal>bundle</goal>
- </goals>
- </execution>
- <configuration>
-
- How do we want to configure this?
-
- o directory tree of archetypes?
- o one archetype per project?
-
- <descriptor>src/main/archetype/archetype.xml</descriptor>
- </configuration>
- </executions>
- </plugin>
-
-
- o need to specify parameters and metadata about parameters
- - pluggable validation type/group
- - localized descriptions
-
- o any ideas to take from the IDEA template mechanism that uses velocity
-
- -->
-
- <!-- Project application sources -->
- <fileSet>
- <directory>src/main/java</directory>
- <filtering>true</filtering>
- </fileSet>
-
- <!-- Project application resources -->
- <fileSet>
- <directory>src/main/resources</directory>
- <filtering>true</filtering>
- </fileSet>
-
- <!-- Project test sources -->
- <fileSet>
- <directory>src/test/java</directory>
- <filtering>true</filtering>
- </fileSet>
-
- <!-- Project test resources -->
- <fileSet>
- <directory>src/test/resources</directory>
- <filtering>true</filtering>
- </fileSet>
-
- <!-- Project site -->
- <fileSet>
- <directory>src/site</directory>
- <filtering>true</filtering>
- </fileSet>
-
- </fileSets>
-
- <!-- So we'll collect these parameters and feed them into the velocity context -->
- <parameters>
- <parameter>
- <name></name>
- <type></type>
- <required></required>
- <!-- This will get farmed out to a resource bundle -->
- <descriptionKey></descriptionKey>
- </parameter>
- </parameters>
-
-</archetype>
diff --git a/maven-archetype/maven-archetype-model/pom.xml b/maven-archetype/maven-archetype-model/pom.xml
deleted file mode 100644
index 2849bec..0000000
--- a/maven-archetype/maven-archetype-model/pom.xml
+++ /dev/null
@@ -1,63 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>org.apache.maven.archetype</groupId>
- <artifactId>maven-archetype</artifactId>
- <version>1.0-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <artifactId>maven-archetype-model</artifactId>
- <name>Maven Archetype Model</name>
- <dependencies>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- <version>1.1</version>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.modello</groupId>
- <artifactId>modello-maven-plugin</artifactId>
- <version>1.0-alpha-8</version>
- <executions>
- <execution>
- <goals>
- <goal>java</goal>
- <goal>xpp3-writer</goal>
- <goal>xpp3-reader</goal>
- <goal>xsd</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <version>1.0.0</version>
- <model>src/main/mdo/archetype.mdo</model>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/maven-archetype/maven-archetype-model/src/main/mdo/archetype.mdo b/maven-archetype/maven-archetype-model/src/main/mdo/archetype.mdo
deleted file mode 100644
index dc12ec0..0000000
--- a/maven-archetype/maven-archetype-model/src/main/mdo/archetype.mdo
+++ /dev/null
@@ -1,79 +0,0 @@
-<?xml version="1.0"?>
-
- <!-- START SNIPPET: modello-model -->
-
-<model>
- <id>archetype</id>
- <name>Archetype</name>
- <description><![CDATA[Maven's model for the archetype descriptor.]]></description>
- <defaults>
- <default>
- <key>package</key>
- <value>org.apache.maven.archetype.model</value>
- </default>
- </defaults>
- <classes>
- <class rootElement="true" xml.tagName="archetype">
- <name>ArchetypeModel</name>
- <description>Describes the assembly layout and packaging.</description>
- <version>1.0.0</version>
- <fields>
- <field>
- <name>id</name>
- <version>1.0.0</version>
- <required>true</required>
- <type>String</type>
- </field>
- <field>
- <name>allowPartial</name>
- <version>1.0.0</version>
- <required>true</required>
- <type>boolean</type>
- </field>
- <field>
- <name>sources</name>
- <version>1.0.0</version>
- <association>
- <type>String</type>
- <multiplicity>*</multiplicity>
- </association>
- </field>
- <field>
- <name>resources</name>
- <version>1.0.0</version>
- <association>
- <type>String</type>
- <multiplicity>*</multiplicity>
- </association>
- </field>
- <field>
- <name>testSources</name>
- <version>1.0.0</version>
- <association>
- <type>String</type>
- <multiplicity>*</multiplicity>
- </association>
- </field>
- <field>
- <name>testResources</name>
- <version>1.0.0</version>
- <association>
- <type>String</type>
- <multiplicity>*</multiplicity>
- </association>
- </field>
- <field>
- <name>siteResources</name>
- <version>1.0.0</version>
- <association>
- <type>String</type>
- <multiplicity>*</multiplicity>
- </association>
- </field>
- </fields>
- </class>
- </classes>
-</model>
-
- <!-- END SNIPPET: modello-model -->
-
diff --git a/maven-archetype/maven-archetype-plugin/pom.xml b/maven-archetype/maven-archetype-plugin/pom.xml
deleted file mode 100644
index fb96531..0000000
--- a/maven-archetype/maven-archetype-plugin/pom.xml
+++ /dev/null
@@ -1,148 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <artifactId>maven-archetype</artifactId>
- <groupId>org.apache.maven.archetype</groupId>
- <version>1.0-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-archetype-plugin</artifactId>
- <packaging>maven-plugin</packaging>
- <name>Maven Archetype Plugin</name>
- <description>
- The Maven Archetype Plugin builds archetype containers.
- </description>
- <url>http://maven.apache.org/plugins/maven-archetype-plugin/</url>
- <inceptionYear>2001</inceptionYear>
- <mailingLists>
- <mailingList>
- <name>Maven User List</name>
- <subscribe>users-subscribe@maven.apache.org</subscribe>
- <unsubscribe>users-unsubscribe@maven.apache.org</unsubscribe>
- <post>users@maven.apache.org</post>
- <archive>http://mail-archives.apache.org/mod_mbox/maven-users</archive>
- <otherArchives>
- <otherArchive>http://www.mail-archive.com/users@maven.apache.org/</otherArchive>
- <otherArchive>http://www.nabble.com/Maven---Users-f178.html</otherArchive>
- </otherArchives>
- </mailingList>
- <mailingList>
- <name>Maven Developer List</name>
- <subscribe>dev-subscribe@maven.apache.org</subscribe>
- <unsubscribe>dev-unsubscribe@maven.apache.org</unsubscribe>
- <post>dev@maven.apache.org</post>
- <archive>http://mail-archives.apache.org/mod_mbox/maven-dev</archive>
- </mailingList>
- <mailingList>
- <name>Maven Commits List</name>
- <subscribe>commits-subscribe@maven.apache.org</subscribe>
- <unsubscribe>commits-unsubscribe@maven.apache.org</unsubscribe>
- <post>commits@maven.apache.org</post>
- <archive>http://mail-archives.apache.org/mod_mbox/maven-dev</archive>
- </mailingList>
- </mailingLists>
- <scm>
- <connection>scm:svn:http://svn.apache.org/repos/asf/maven/archetype/trunk/maven-archetype/maven-archetype-plugin/</connection>
- <developerConnection>scm:svn:http://svn.apache.org/repos/asf/maven/archetype/trunk/maven-archetype/maven-archetype-plugin/</developerConnection>
- <url>http://svn.apache.org/repos/asf/maven/archetype/trunk/maven-archetype/maven-archetype-plugin/</url>
- </scm>
- <prerequisites>
- <maven>2.0</maven>
- </prerequisites>
- <dependencies>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-plugin-api</artifactId>
- <version>2.0</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-project</artifactId>
- <version>2.0</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-artifact</artifactId>
- <version>2.0</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven.archetype</groupId>
- <artifactId>maven-archetype-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.maven.archetype</groupId>
- <artifactId>maven-archetype-creator</artifactId>
- </dependency>
- </dependencies>
- <reporting>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-plugin-plugin</artifactId>
- <version>2.3</version>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jxr-plugin</artifactId>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- </plugin>
- </plugins>
- </reporting>
- <profiles>
- <profile>
- <id>ciProfile</id>
- <activation>
- <property>
- <name>enableCiProfile</name>
- <value>true</value>
- </property>
- </activation>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-docck-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>check</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
- <distributionManagement>
- <site>
- <id>apache.website</id>
- <url>scp://people.apache.org/www/maven.apache.org/plugins/maven-archetype-plugin</url>
- </site>
- </distributionManagement>
-</project>
diff --git a/maven-archetype/maven-archetype-plugin/src/main/java/org/apache/maven/plugin/archetype/CreateArchetypeFromProjectMojo.java b/maven-archetype/maven-archetype-plugin/src/main/java/org/apache/maven/plugin/archetype/CreateArchetypeFromProjectMojo.java
deleted file mode 100644
index 3ad635a..0000000
--- a/maven-archetype/maven-archetype-plugin/src/main/java/org/apache/maven/plugin/archetype/CreateArchetypeFromProjectMojo.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright (c) 2006 Your Corporation. All Rights Reserved.
- */
-package org.apache.maven.plugin.archetype;
-
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.archetype.Archetype;
-import org.apache.maven.archetype.ArchetypeNotFoundException;
-import org.apache.maven.archetype.ArchetypeDescriptorException;
-import org.apache.maven.archetype.ArchetypeTemplateProcessingException;
-import org.apache.maven.archetype.ArchetypeCreator;
-import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
-import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
-import org.apache.maven.project.MavenProject;
-import org.apache.maven.project.MavenProjectHelper;
-import org.codehaus.plexus.util.StringUtils;
-
-import java.util.List;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.ArrayList;
-import java.util.Properties;
-import java.io.File;
-import java.io.FileInputStream;
-
-/**
- * Builds archetype containers based from an existing Maven project (currently
- * under development).
- *
- * @goal create-from-project
- * @description Create an archetype from an existing Maven project.
- * @requiresProject true
- */
-public class CreateArchetypeFromProjectMojo
- extends AbstractMojo
-{
- /**
- * The Maven Project to be used as the basis for the creating of the archetype.
- *
- * @parameter expression="${project}"
- * @required
- */
- private MavenProject project;
-
- /**
- * Maven's local repository.
- *
- * @parameter expression="${localRepository}"
- * @required
- */
- private ArtifactRepository localRepository;
-
- /**
- * Output build directory.
- *
- * @parameter expression="${targetDirectory}" default-value="${project.build.directory}"
- * @required
- */
- private File targetDirectory;
-
- /**
- * Maven ArchetypeCreator
- *
- * @component
- */
- private ArchetypeCreator archetypeCreator;
-
- /**
- * Maven ProjectHelper
- *
- * @component
- */
- private MavenProjectHelper projectHelper;
-
-
- /**
- * Contains Archetype Properties.
- *
- * @parameter expression="${archetypeProperties}" default-value="${basedir}/src/main/archetype/archetype.properties"
- * @required
- */
- private File archetypeProperties;
-
- public void execute()
- throws MojoExecutionException
- {
- try
- {
- Properties p = new Properties();
-
- p.load( new FileInputStream( archetypeProperties ) );
-
- File archetypeJar = archetypeCreator.createArchetype( project, localRepository, targetDirectory, p );
-
- projectHelper.attachArtifact( project, "jar", "archetype", archetypeJar );
- }
- catch ( Exception e )
- {
- throw new MojoExecutionException( "Cannot create archetype from this project.", e );
- }
- }
-}
diff --git a/maven-archetype/maven-archetype-plugin/src/main/java/org/apache/maven/plugin/archetype/MavenArchetypeMojo.java b/maven-archetype/maven-archetype-plugin/src/main/java/org/apache/maven/plugin/archetype/MavenArchetypeMojo.java
deleted file mode 100644
index 9cc3894..0000000
--- a/maven-archetype/maven-archetype-plugin/src/main/java/org/apache/maven/plugin/archetype/MavenArchetypeMojo.java
+++ /dev/null
@@ -1,264 +0,0 @@
-package org.apache.maven.plugin.archetype;
-
-/*
- * 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.archetype.Archetype;
-import org.apache.maven.archetype.ArchetypeDescriptorException;
-import org.apache.maven.archetype.ArchetypeNotFoundException;
-import org.apache.maven.archetype.ArchetypeTemplateProcessingException;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
-import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
-import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.project.MavenProject;
-import org.codehaus.plexus.util.StringUtils;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * The archetype creation goal looks for an archetype with a given groupId,
- * artifactId, and version and retrieves it from the remote repository. Once the
- * archetype is retrieved, it is then processed against a set of user parameters
- * to create a working Maven project.
- *
- * @description Creates archetype containers.
- * @requiresProject false
- * @goal create
- */
-public class MavenArchetypeMojo
- extends AbstractMojo
-{
- /**
- * Used to create the Archetype specified by the groupId, artifactId, and
- * version from the remote repository.
- *
- * @component
- */
- private Archetype archetype;
-
- /**
- * Used to create ArtifactRepository objects given the urls of the remote
- * repositories.
- *
- * @component
- */
- private ArtifactRepositoryFactory artifactRepositoryFactory;
-
- /**
- * Determines whether the layout is legacy or not.
- *
- * @component role="org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout" roleHint="default"
- */
- private ArtifactRepositoryLayout defaultArtifactRepositoryLayout;
-
-
- /**
- * Maven's local repository.
- *
- * @parameter expression="${localRepository}"
- * @required
- */
- private ArtifactRepository localRepository;
-
- /**
- * The Archetype Group Id to be used.
- *
- * @parameter expression="${archetypeGroupId}" default-value="org.apache.maven.archetype"
- * @required
- */
- private String archetypeGroupId;
-
- /**
- * The Archetype Artifact Id to be used.
- *
- * @parameter expression="${archetypeArtifactId}" default-value="maven-archetype-quickstart"
- * @required
- */
- private String archetypeArtifactId;
-
- /**
- * The Archetype Version to be used.
- *
- * @parameter expression="${archetypeVersion}" default-value="RELEASE"
- * @required
- */
- private String archetypeVersion;
-
- /**
- * The Group Id of the project to be build.
- *
- * @parameter expression="${groupId}"
- */
- private String groupId;
-
- /**
- * The Artifact Id of the project to be build.
- *
- * @parameter expression="${artifactId}"
- */
- private String artifactId;
-
- /**
- * The Version of the project to be build.
- *
- * @parameter expression="${version}" default-value="1.0-SNAPSHOT"
- * @required
- */
- private String version;
-
- /**
- * The Package Name of the project to be build.
- *
- * @parameter expression="${packageName}" alias="package"
- */
- private String packageName;
-
- /**
- * The remote repositories available for discovering dependencies and extensions as indicated
- * by the POM.
- *
- * @parameter expression="${project.remoteArtifactRepositories}"
- * @required
- */
- private List pomRemoteRepositories;
-
- /**
- * Other remote repositories available for discovering dependencies and extensions.
- *
- * @parameter expression="${remoteRepositories}"
- */
- private String remoteRepositories;
-
- /**
- * The project to be created an archetype of.
- *
- * @parameter expression="${project}"
- */
- private MavenProject project;
-
- /**
- * @parameter default-value="${user.dir}"
- */
- private String basedir = System.getProperty( "user.dir" );
-
- public void execute()
- throws MojoExecutionException
- {
- // TODO: prompt for missing values
- // TODO: configurable license
-
- // ----------------------------------------------------------------------
- // archetypeGroupId
- // archetypeArtifactId
- // archetypeVersion
- //
- // localRepository
- // remoteRepository
- // parameters
- // ----------------------------------------------------------------------
-
- if ( project.getFile() != null && groupId == null )
- {
- groupId = project.getGroupId();
- }
-
- if ( packageName == null )
- {
- getLog().info( "Defaulting package to group ID: " + groupId );
-
- packageName = groupId;
- }
-
- // TODO: context mojo more appropriate?
- Map map = new HashMap();
-
- map.put( "basedir", basedir );
-
- map.put( "package", packageName );
-
- map.put( "packageName", packageName );
-
- map.put( "groupId", groupId );
-
- map.put( "artifactId", artifactId );
-
- map.put( "version", version );
-
- List archetypeRemoteRepositories = new ArrayList( pomRemoteRepositories );
-
- if ( remoteRepositories != null )
- {
- getLog().info( "We are using command line specified remote repositories: " + remoteRepositories );
-
- archetypeRemoteRepositories = new ArrayList();
-
- String[] s = StringUtils.split( remoteRepositories, "," );
-
- for ( int i = 0; i < s.length; i++ )
- {
- archetypeRemoteRepositories.add( createRepository( s[i], "id" + i ) );
- }
- }
-
- try
- {
- archetype.createArchetype( archetypeGroupId, archetypeArtifactId, archetypeVersion, localRepository,
- archetypeRemoteRepositories, map );
- }
- catch ( ArchetypeNotFoundException e )
- {
- throw new MojoExecutionException( "Error creating from archetype", e );
- }
- catch ( ArchetypeDescriptorException e )
- {
- throw new MojoExecutionException( "Error creating from archetype", e );
- }
- catch ( ArchetypeTemplateProcessingException e )
- {
- throw new MojoExecutionException( "Error creating from archetype", e );
- }
- }
-
- //TODO: this should be put in John's artifact utils and used from there instead of being repeated here. Creating
- // artifact repositories is someowhat cumbersome atm.
- public ArtifactRepository createRepository( String url, String repositoryId )
- {
- // snapshots vs releases
- // offline = to turning the update policy off
-
- //TODO: we'll need to allow finer grained creation of repositories but this will do for now
-
- String updatePolicyFlag = ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS;
-
- String checksumPolicyFlag = ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN;
-
- ArtifactRepositoryPolicy snapshotsPolicy =
- new ArtifactRepositoryPolicy( true, updatePolicyFlag, checksumPolicyFlag );
-
- ArtifactRepositoryPolicy releasesPolicy =
- new ArtifactRepositoryPolicy( true, updatePolicyFlag, checksumPolicyFlag );
-
- return artifactRepositoryFactory.createArtifactRepository( repositoryId, url, defaultArtifactRepositoryLayout,
- snapshotsPolicy, releasesPolicy );
- }
-}
-
diff --git a/maven-archetype/maven-archetype-plugin/src/main/resources/plexus.xml b/maven-archetype/maven-archetype-plugin/src/main/resources/plexus.xml
deleted file mode 100644
index 29891fb..0000000
--- a/maven-archetype/maven-archetype-plugin/src/main/resources/plexus.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-<plexus>
- <components>
- <component>
- <role>org.codehaus.plexus.builder.PlexusBuilder</role>
- <implementation>org.codehaus.plexus.builder.DefaultPlexusBuilder</implementation>
- <requirements>
- <requirement>
- <role>org.apache.maven.artifact.resolver.ArtifactResolver</role>
- </requirement>
- <requirement>
- <role>org.apache.maven.artifact.collector.ArtifactCollector</role>
- </requirement>
- <requirement>
- <role>org.apache.maven.project.MavenProjectBuilder</role>
- </requirement>
- <requirement>
- <role>org.codehaus.plexus.velocity.VelocityComponent</role>
- </requirement>
- </requirements>
- </component>
-
- <component>
- <role>org.codehaus.plexus.velocity.VelocityComponent</role>
- <implementation>org.codehaus.plexus.velocity.DefaultVelocityComponent</implementation>
- <configuration>
- <properties>
- <property>
- <name>resource.loader</name>
- <value>classpath</value>
- </property>
- <property>
- <name>classpath.resource.loader.class</name>
- <value>org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader</value>
- </property>
- </properties>
- </configuration>
- </component>
- </components>
-</plexus>
diff --git a/maven-archetype/maven-archetype-plugin/src/site/apt/examples/archetype.apt b/maven-archetype/maven-archetype-plugin/src/site/apt/examples/archetype.apt
deleted file mode 100644
index cf028de..0000000
--- a/maven-archetype/maven-archetype-plugin/src/site/apt/examples/archetype.apt
+++ /dev/null
@@ -1,226 +0,0 @@
- ------
- Guide to Creating Archetypes
- ------
- Jason van Zyl, Alexander Hars, Franz Allan Valencia See
- ------
- 25 July 2006
- ------
-
-~~ Copyright 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.
-
-~~ NOTE: For help with the syntax of this file, see:
-~~ http://maven.apache.org/guides/mini/guide-apt-format.html
-
-Guide to Creating Archetypes
-
- Creating an archetype is a pretty straight forward process. An archetype is a
- very simple plugin, that contains the project prototype you wish to create.
- An archetype is made up of:
-
- * an archetype descriptor (<<<archetype.xml>>> in directory:
- <<<src/main/resources/META-INF/>>>). It lists all the files that will be
- contained in the archetype and categorizes them so they can be processed
- correctly by the archetype generation mechanism.
-
- * the prototype files that are copied by the archetype (directory:
- <<<src/main/resources/archetype-resources/>>>)
-
- * the prototpye pom (<<<pom.xml>>> in:
- <<<src/main/resources/archetype-resources>>>)
-
- * a pom for the archetype (<<<pom.xml>>> in the archetype's root directory).
-
- []
-
- To create an archetype follow these steps:
-
-* 1. Create a new project and pom.xml for the archetype plugin
-
- An example <<<pom.xml>>> for an archetype plugin looks as follows:
-
-+----+
-
-<project>
- <modelVersion>4.0.0</modelVersion>
- <groupId>my.groupId</groupId>
- <artifactId>my-archetype-id</artifactId>
- <version>1.0-SNAPSHOT</version>
- <packaging>maven-plugin</packaging>
-</project>
-
-+----+
-
- All you need to specify is a <<<groupId>>>, <<<artifactId>>> and
- <<<version>>>. These three parameters will be needed later for invoking the
- archetype via <<<archetype:create>>> from the commandline.
-
-* 2. Create the archetype descriptor
-
- The archetype descriptor is a file called <<<archetype.xml>>> which must be
- located in <<<src/main/resources/META-INF/>>> An example for an archetype
- descriptor can be found in the quickstart archetype:
-
-+----+
-
-<archetype>
- <id>quickstart</id>
- <sources>
- <source>src/main/java/App.java</source>
- </sources>
- <testSources>
- <source>src/test/java/AppTest.java</source>
- </testSources>
-</archetype>
-
-+----+
-
- The <<<\<id\>>>> tag should be the same as the <<<artifactId>>> in the
- archetype <<<pom.xml>>>.
-
- An optional <<<\<allowPartial\>true\</allowPartial\>>>> tag makes it possible
- to run the <<<archetype:create>>> even on existing projects.
-
- The <<<\<sources\>>>>, <<<\<resources\>>>>, <<<\<testResources\>>>> and
- <<<\<siteResources\>>>> tags represent the different sections of the project:
-
- * <<<\<sources\>>>> = <<<src/main/java>>>
-
- * <<<\<resources\>>>> = <<<src/main/resources>>>
-
- * <<<\<testSources\>>>> = <<<src/test/java>>>
-
- * <<<\<testResources\>>>> = <<<src/test/resources>>>
-
- * <<<\<siteResources\>>>> = <<<src/site>>>
-
- []
-
- <<<\<sources\>>>> and <<<\<testSources\>>>> can contain <<<\<source\>>>>
- elements that specify a source file.
-
- <<<\<testResources\>>>> and <<<\<siteResources\>>>> can contain
- <<<\<resource\>>>> elements that specify a resource file.
-
- Place other resources such as the ones in the <<<src/main/webapp>>> directory
- inside the <<<\<resources\>>>> tag.
-
- At this point one can only specify individual files to be created but not empty
- directories.
-
- Thus the quickstart archetype shown above defines the following directory
- structure:
-
-+----+
-
-archetype
-|-- pom.xml
-`-- src
- `-- main
- `-- resources
- |-- META-INF
- | `-- archetype.xml
- `-- archetype-resources
- |-- pom.xml
- `-- src
- |-- main
- | `-- java
- | `-- App.java
- `-- test
- `-- java
- `-- AppTest.java
-
-+----+
-
-* 3. Create the prototype files and the prototype pom.xml
-
- The next component of the archetype to be created is the prototype
- <<<pom.xml>>>. Any <<<pom.xml>>> will do, just don't forget to the set
- <<<artifactId>>> and <<<groupId>>> as variables ( <<<$\{artifactId\}>>> /
- <<<$\{groupId\}>>> ). Both variables will be initialized from the commandline
- when calling <<<archetype:create>>>.
-
- An example for a prototype <<<pom.xml>>> is:
-
-+----+
-
-<project>
- <modelVersion>4.0.0</modelVersion>
- <groupId>${groupId}</groupId>
- <artifactId>${artifactId}</artifactId>
- <packaging>jar</packaging>
- <version>${version}</version>
- <name>A custom project</name>
- <url>http://www.myorganization.org</url>
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-</project>
-
-+----+
-
-* 4. Install and run the archetype
-
- Now you are ready to install the archetype:
-
-+----+
-
-mvn install
-
-+----+
-
- Now that you have created an archetype you can try it on your local system by
- using the following command. In this command, you need to specify the full
- information about the archetype you want to use (its <<<groupId>>>, its
- <<<artifactId>>>, its <<<version>>>) and the information about the new project
- you want to create (<<<artifactId>>> and <<<groupId>>>). Don't forget to
- include the version of your archetype (if you don't include the version, you
- archetype creation may fail with a message that version:RELEASE was not found)
-
-
-+----+
-
-mvn archetype:create \
- -DarchetypeGroupId=<archetype-groupId> \
- -DarchetypeArtifactId=<archetype-artifactId> \
- -DarchetypeVersion=<archetype-version> \
- -DgroupId=<my.groupid> \
- -DartifactId=<my-artifactId>
-
-+----+
-
- Once you are happy with the state of your archetype you can deploy (or submit
- it to ibiblio) it as any other artifact and the archetype will then be
- available to any user of Maven.
-
-* Alternative way to start creating your Archetype
-
- Instead of manually creating the directory structure needed for an archetype,
- simply use
-
-+------+
-mvn archetype:create
- -DgroupId=[your project's group id]
- -DartifactId=[your project's artifact id]
- -DarchetypeArtifactId=maven-archetype-archetype
-+------+
-
- Afterwhich, you can now customize the contents of the <<<archetype-resources>>>
- directory, and <<<archetype.xml>>>, then, proceed to Step#4 (Install and run
- the archetype plugin).
diff --git a/maven-archetype/maven-archetype-plugin/src/site/apt/examples/j2ee-simple.apt b/maven-archetype/maven-archetype-plugin/src/site/apt/examples/j2ee-simple.apt
deleted file mode 100644
index 36f0ce1..0000000
--- a/maven-archetype/maven-archetype-plugin/src/site/apt/examples/j2ee-simple.apt
+++ /dev/null
@@ -1,74 +0,0 @@
- ------
- J2ee Simple
- ------
- Franz Allan Valencia See
- ------
- July 2006
- ------
-
-~~ Copyright 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.
-
-~~ NOTE: For help with the syntax of this file, see:
-~~ http://maven.apache.org/guides/mini/guide-apt-format.html
-
-Creating a simple j2ee Project
-
- Creating the directory structure of a J2EE project can be tedious. However, if
- you would use <<<maven-archetype-j2ee-simple>>>, the usual directories for a
- j2ee project would be provided for you.
-
-+------+
-mvn archetype:create
- -DgroupId=[your project's group id]
- -DartifactId=[your project's artifact id]
- -DarchetypeArtifactId=maven-archetype-j2ee-simple
-+------+
-
- This would then create a maven project.
-
-+------+
-.
- |-- ear
- | `-- pom.xml
- |-- ejb
- | |-- src
- | | `-- main
- | | `-- resources
- | | `-- META-INF
- | | `-- ejb-jar.xml
- | `-- pom.xml
- |-- primary-source
- | `-- pom.xml
- |-- projects
- | |-- logging
- | | `-- pom.xml
- | `-- pom.xml
- |-- servlets
- | |-- servlet
- | | |-- src
- | | | `-- main
- | | | `-- webapp
- | | | |-- WEB-INF
- | | | | `-- web.xml
- | | | `-- index.jsp
- | | `-- pom.xml
- | `-- pom.xml
- |-- src
- | `-- main
- | `-- resources
- `-- pom.xml
-+------+
-
-
diff --git a/maven-archetype/maven-archetype-plugin/src/site/apt/examples/mojo.apt b/maven-archetype/maven-archetype-plugin/src/site/apt/examples/mojo.apt
deleted file mode 100644
index 2b50287..0000000
--- a/maven-archetype/maven-archetype-plugin/src/site/apt/examples/mojo.apt
+++ /dev/null
@@ -1,50 +0,0 @@
- ------
- Mojo
- ------
- Franz Allan Valencia See
- ------
- July 2006
- ------
-
-~~ Copyright 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.
-
-~~ NOTE: For help with the syntax of this file, see:
-~~ http://maven.apache.org/guides/mini/guide-apt-format.html
-
-Creating a mojo
-
- A maven plugin is composed of one or more mojos. And to start the creation of
- a maven plugin, you can use <<<maven-archetype-mojo>>> to create a mojo.
-
-+------+
-mvn archetype:create
- -DgroupId=[your project's group id]
- -DartifactId=[your project's artifact id]
- -DarchetypeArtifactId=maven-archetype-mojo
-+------+
-
- This would then create a maven project.
-
-+------+
-.
- |-- src
- | `-- main
- | `-- java
- | `-- [your project's package]
- | `-- MyMojo.java
- `-- pom.xml
-+------+
-
-
diff --git a/maven-archetype/maven-archetype-plugin/src/site/apt/examples/portlet.apt b/maven-archetype/maven-archetype-plugin/src/site/apt/examples/portlet.apt
deleted file mode 100644
index 0192e36..0000000
--- a/maven-archetype/maven-archetype-plugin/src/site/apt/examples/portlet.apt
+++ /dev/null
@@ -1,63 +0,0 @@
- ------
- Portlet
- ------
- Franz Allan Valencia See
- ------
- July 2006
- ------
-
-~~ Copyright 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.
-
-~~ NOTE: For help with the syntax of this file, see:
-~~ http://maven.apache.org/guides/mini/guide-apt-format.html
-
-Creating a portlet
-
- Use <<<maven-archetype-webapp>>> to start a simple webapp maven project. The
- command is as follows
-
-+------+
-mvn archetype:create
- -DgroupId=[your project's group id]
- -DartifactId=[your project's artifact id]
- -DarchetypeArtifactId=maven-archetype-portlet
-+------+
-
- This would then create a maven project.
-
-+------+
-.
- |-- src
- | `-- main
- | `-- java
- | |-- [your project's package]
- | | `-- MyPortal.java
- | |-- jetspeed
- | | `-- web.xml
- | |-- resources
- | |-- webapp
- | | |-- WEB-INF
- | | | |-- tld
- | | | | `-- portlet.tld
- | | | |-- portlet.xml
- | | | `-- web.xml
- | | |-- help.jsp
- | | |-- maximized.jsp
- | | `-- normal.jsp
- | `-- index.jsp
- `-- pom.xml
-+------+
-
-
diff --git a/maven-archetype/maven-archetype-plugin/src/site/apt/examples/remote-repositories.apt b/maven-archetype/maven-archetype-plugin/src/site/apt/examples/remote-repositories.apt
deleted file mode 100644
index 1c2ea55..0000000
--- a/maven-archetype/maven-archetype-plugin/src/site/apt/examples/remote-repositories.apt
+++ /dev/null
@@ -1,85 +0,0 @@
- ------
- Remote Repositories
- ------
- Franz Allan Valencia See
- ------
- July 2006
- ------
-
-~~ Copyright 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.
-
-~~ NOTE: For help with the syntax of this file, see:
-~~ http://maven.apache.org/guides/mini/guide-apt-format.html
-
-Specifying the Remote Repositories
-
- To use an archetype found in a remote repository, use the
- <<<remoteRepositories>>> property / parameter.
-
-+------+
-mvn archetype:create
- -DgroupId=[your group id]
- -DartifactId=[your artifact id]
- -DarchetypeGroupId=[group id of the remote archetype]
- -DarchetypeArtifactId=[artifact id of the remote archetype]
- -DarchetypeVersion=[version of the remote archetype]
- -DremoteRepositories=[urls of your remote repositories]
-+------+
-
- For example, if you want to use a
- <<<remote.archetype.gid:remote-archetype-aid:1.0>>>
- to create a <<<your.proj.gid:your-proj-aid project>>> and that archetype
- is located at <<<http://remote.archetypes.url>>>, then your maven command
- would be
-
-+------+
-mvn archetype:create \
- -DgroupId=your.proj.gid \
- -DartifactId=your-proj-aid \
- -DarchetypeGroupId=remote.archetype.gid \
- -DarchetypeArtifactId=remote-archetype-aid \
- -DarchetypeVersion=1.0 \
- -DremoteRepositories=http://remote.archetypes.url
-+------+
-
- Moreover, you can specify several remote repositories by using a comma (,).
-
-+------+
-mvn archetype:create \
- -DgroupId=your.proj.gid \
- -DartifactId=your-proj-aid \
- -DarchetypeGroupId=remote.archetype.gid \
- -DarchetypeArtifactId=remote-archetype-aid \
- -DarchetypeVersion=1.0 \
- -DremoteRepositories=http://remote.archetypes.url,http://another.url
-+------+
-
- Furthermore, you can specify your remote repositories through a parent pom.
-
-+------+
-<project>
- [...]
- <packaging>pom</packaging>
- [...]
- <repositories>
- <repository>
- [...]
- <id> [remote repository id] </id>
- <url> [remote repository's url] </url>
- [...]
- </repository>
- </repositories>
-</project>
-+------+
diff --git a/maven-archetype/maven-archetype-plugin/src/site/apt/examples/simple.apt b/maven-archetype/maven-archetype-plugin/src/site/apt/examples/simple.apt
deleted file mode 100644
index c0452d4..0000000
--- a/maven-archetype/maven-archetype-plugin/src/site/apt/examples/simple.apt
+++ /dev/null
@@ -1,92 +0,0 @@
- ------
- Simple
- ------
- Franz Allan Valencia See
- ------
- July 2006
- ------
-
-~~ Copyright 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.
-
-~~ NOTE: For help with the syntax of this file, see:
-~~ http://maven.apache.org/guides/mini/guide-apt-format.html
-
-
-Creating a simple java application
-
- To start of with your java project, you can use
- <<<maven-archetype-quickstart.>>> Simply, you'd just have to provide a
- <<<groupId>>> and an <<<artifactId>>> (at the least).
-
-+------+
-mvn archetype:create
- -DgroupId=[your project's group id]
- -DartifactId=[your project's artifact id]
- -DarchetypeArtifactId=maven-archetype-quickstart
-+------+
-
- or simply,
-
-+------+
-mvn archetype:create
- -DgroupId=[your project's group id]
- -DartifactId=[your project's artifact id]
-+------+
-
- This would then create a maven project.
-
-+------+
-.
- |-- src
- | |-- main
- | | `-- java
- | | `-- [your project's package]
- | | `-- App.java
- | `-- test
- | `-- java
- | `-- [your project's package]
- | `-- AppTest.java
- `-- pom.xml
-+------+
-
- For example if we execute this command
-
-+------+
-mvn archetype:create
- -DgroupId=your.simple.java.gid
- -DartifactId=your-simple-java-aid
-+------+
-
- We would get this
-
-+------+
-.
- |-- src
- | |-- main
- | | `-- java
- | | `-- your
- | | `-- simple
- | | `-- java
- | | `-- aid
- | | `-- App.java
- | `-- test
- | `-- java
- | `-- your
- | `-- simple
- | `-- java
- | `-- aid
- | `-- AppTest.java
- `-- pom.xml
-+------+
diff --git a/maven-archetype/maven-archetype-plugin/src/site/apt/examples/site.apt b/maven-archetype/maven-archetype-plugin/src/site/apt/examples/site.apt
deleted file mode 100644
index 4cba3f2..0000000
--- a/maven-archetype/maven-archetype-plugin/src/site/apt/examples/site.apt
+++ /dev/null
@@ -1,204 +0,0 @@
- ------
- Site
- ------
- Franz Allan Valencia See
- ------
- July 2006
- ------
-
-~~ Copyright 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.
-
-~~ NOTE: For help with the syntax of this file, see:
-~~ http://maven.apache.org/guides/mini/guide-apt-format.html
-
-Creating a site
-
- You can create a site either by using <<<maven-archetype-site-simple>>> or
- <<<maven-archetype-site>>>. You just need to set your maven project's
- <<<groupId>>> and <<<artifactId>>>.
-
- To jump start a simple site, choose <<<maven-archetype-site-simple>>>,
-
-+------+
-mvn archetype:create
- -DgroupId=[your project's group id]
- -DartifactId=[your project's artifact id]
- -DarchetypeArtifactId=maven-archetype-site-simple
-+------+
-
- and it will generate a maven project with the following contents.
-
-+------+
-.
- |-- src
- | `-- main
- | `-- site
- | |-- apt
- | | `-- index.apt
- | `-- site.xml
- `-- pom.xml
-+------+
-
- The <<<index.apt>>> produced is of "Almost Plain Text" format which is used
- for documentation (<To learn more about the APT Format, kindly refer to the
- {{{http://maven.apache.org/guides/mini/guide-apt-format.html}APT Format Guide}}>).
-
- But to create a more complete version of a site, use
- <<<maven-archetype-site>>>.
-
-+------+
-mvn archetype:create
- -DgroupId=[your project's group id]
- -DartifactId=[your project's artifact id]
- -DarchetypeArtifactId=maven-archetype-site
-+------+
-
- This would then create a maven project.
-
-+------+
-.
- |-- src
- | `-- main
- | `-- site
- | |-- apt
- | | |-- format.apt
- | | `-- index.apt
- | |-- fml
- | | `-- faq.fml
- | |-- fr
- | | |-- apt
- | | | |-- format.apt
- | | | `-- index.apt
- | | |-- fml
- | | | `-- faq.fml
- | | `-- xdoc
- | | `-- xdoc.xml
- | |-- xdoc
- | | `-- xdoc.xml
- | |-- site.xml
- | `-- site_fr.xml
- `-- pom.xml
-+------+
-
- Furthermore, both archetypes are capable of creating archetype containers over
- an existing maven project. For example, if we first create a simple j2ee maven
- project.
-
-+------+
-mvn archetype:create
- -DgroupId=sample.gid
- -DartifactId=sample-aid
- -DarchetypeArtifactId=maven-archetype-j2ee-simple
-+------+
-
- We would have the following contents for our maven project.
-
-+------+
-.
- |-- ear
- | `-- pom.xml
- |-- ejb
- | |-- src
- | | `-- main
- | | `-- resources
- | | `-- META-INF
- | | `-- ejb-jar.xml
- | `-- pom.xml
- |-- primary-source
- | `-- pom.xml
- |-- projects
- | |-- logging
- | | `-- pom.xml
- | `-- pom.xml
- |-- servlets
- | |-- servlet
- | | |-- src
- | | | `-- main
- | | | `-- webapp
- | | | |-- WEB-INF
- | | | | `-- web.xml
- | | | `-- index.jsp
- | | `-- pom.xml
- | `-- pom.xml
- |-- src
- | `-- main
- | `-- resources
- `-- pom.xml
-+------+
-
- And if we envoke the following commands from the same directory.
-
-+------+
-mvn archetype:create
- -DgroupId=sample.gid
- -DartifactId=sample-aid
- -DarchetypeArtifactId=maven-archetype-site
-+------+
-
- The contents of the site archetype would then insert itself with that of the
- existing maven project.
-
-+------+
-.
- |-- ear
- | `-- pom.xml
- |-- ejb
- | |-- src
- | | `-- main
- | | `-- resources
- | | `-- META-INF
- | | `-- ejb-jar.xml
- | `-- pom.xml
- |-- primary-source
- | `-- pom.xml
- |-- projects
- | |-- logging
- | | `-- pom.xml
- | `-- pom.xml
- |-- servlets
- | |-- servlet
- | | |-- src
- | | | `-- main
- | | | `-- webapp
- | | | |-- WEB-INF
- | | | | `-- web.xml
- | | | `-- index.jsp
- | | `-- pom.xml
- | `-- pom.xml
- |-- src
- | `-- main
- | |-- resources
- | `-- site
- | |-- apt
- | | |-- format.apt
- | | `-- index.apt
- | |-- fml
- | | `-- faq.fml
- | |-- fr
- | | |-- apt
- | | | |-- format.apt
- | | | `-- index.apt
- | | |-- fml
- | | | `-- faq.fml
- | | `-- xdoc
- | | `-- xdoc.xml
- | |-- xdoc
- | | `-- xdoc.xml
- | |-- site.xml
- | `-- site_fr.xml
- `-- pom.xml
-+------+
-
- while retaining the existing maven project's pom.
diff --git a/maven-archetype/maven-archetype-plugin/src/site/apt/examples/webapp.apt b/maven-archetype/maven-archetype-plugin/src/site/apt/examples/webapp.apt
deleted file mode 100644
index 37b4039..0000000
--- a/maven-archetype/maven-archetype-plugin/src/site/apt/examples/webapp.apt
+++ /dev/null
@@ -1,53 +0,0 @@
- ------
- Webapp
- ------
- Franz Allan Valencia See
- ------
- July 2006
- ------
-
-~~ Copyright 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.
-
-~~ NOTE: For help with the syntax of this file, see:
-~~ http://maven.apache.org/guides/mini/guide-apt-format.html
-
-Creating a webapp
-
- Use <<<maven-archetype-webapp>>> to start a simple webapp maven project. The
- command is as follows
-
-+------+
-mvn archetype:create
- -DgroupId=[your project's group id]
- -DartifactId=[your project's artifact id]
- -DarchetypeArtifactId=maven-archetype-webapp
-+------+
-
- This would then create a maven project.
-
-+------+
-.
- |-- src
- | `-- main
- | `-- java
- | |-- resources
- | |-- webapp
- | | `-- WEB-INF
- | | `-- web.xml
- | `-- index.jsp
- `-- pom.xml
-+------+
-
-
diff --git a/maven-archetype/maven-archetype-plugin/src/site/apt/index.apt b/maven-archetype/maven-archetype-plugin/src/site/apt/index.apt
deleted file mode 100644
index 107ec38..0000000
--- a/maven-archetype/maven-archetype-plugin/src/site/apt/index.apt
+++ /dev/null
@@ -1,98 +0,0 @@
- ------
- Introduction
- ------
- Franz Allan Valencia See
- ------
- 17 July 2006
- ------
-
-~~ Copyright 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.
-
-~~ NOTE: For help with the syntax of this file, see:
-~~ http://maven.apache.org/guides/mini/guide-apt-format.html
-
-Maven 2 Archetype Plugin
-
- The Archetype Plugin allows the user to build archetype containers. These
- archetype containers contains the pom, default source, test, resources,
- test-resources, and site-resources files in a specific directory structure. The
- content of the pom, the default files, and the directory structure depends on
- the what archetype container was built.
-
- Upon writing this documentation, there are ten (10) available archetype
- containers provided by maven These are:
-
- * <<<maven-archetype-archetype>>>
-
- * <<<maven-archetype-j2ee-simple>>>
-
- * <<<maven-archetype-mojo>>>
-
- * <<<maven-archetype-portlet>>>
-
- * <<<maven-archetype-profiles>>> (<currently under development>)
-
- * <<<maven-archetype-quickstart>>>
-
- * <<<maven-archetype-simple>>> (<currently under development>)
-
- * <<<maven-archetype-site>>>
-
- * <<<maven-archetype-site-simple>>>, and
-
- * <<<maven-archetype-webapp>>>
-
-* Goals Overview
-
- The Archetype Plugin has two goals:
-
- * {{{create-mojo.html}archetype:create}} looks for an achetype with a given
- <<<groupId>>>, <<<artifactId>>>, and <<<version>>> and retrieves it from
- the remote repository. Once the archetype is retrieved, it is then
- processed against a set of user parameters to create a working Maven
- project.
-
- * {{{create-from-project-mojo.html}archetype:create-from-project}} creates an
- archetype from an existing Maven projecct.
-
-* Usage
-
- Instructions on how to use the Archetype Plugin can be found
- {{{usage.html}here}}.
-
-* Examples
-
- The following examples show how to use the Archetype Plugin in more advanced
- usecases:
-
- * {{{examples/remote-repositories.html}Specifying the Remote Repositories}}
-
- * {{{examples/simple.html}Creating a Simple Java Application}}
-
- * {{{examples/site.html}Creating a Site}}
-
- * {{{examples/j2ee-simple.html}Creating a Simple J2ee Project}}
-
- * {{{examples/webapp.html}Creating a Webapp}}
-
- * {{{examples/portlet.html}Creating a Portlet}}
-
- * {{{examples/mojo.html}Creating a Mojo}}
-
- * {{{examples/archetype.html}Creating your own Archetype}}
-
-
-
-
diff --git a/maven-archetype/maven-archetype-plugin/src/site/apt/usage.apt b/maven-archetype/maven-archetype-plugin/src/site/apt/usage.apt
deleted file mode 100644
index fc59b61..0000000
--- a/maven-archetype/maven-archetype-plugin/src/site/apt/usage.apt
+++ /dev/null
@@ -1,117 +0,0 @@
- ------
- Usage
- ------
- Franz Allan Valencia See
- ------
- 17 July 2006
- ------
-
-~~ Copyright 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.
-
-~~ NOTE: For help with the syntax of this file, see:
-~~ http://maven.apache.org/guides/mini/guide-apt-format.html
-
-Usage
-
-* Create
-
- The create goal creates a pom, the default files (source, test, resources,
- test-resources, site-resources), in a specific directory structure. The most
- basic way of using this is by calling the goal with only two expressions: the
- <<<groupId>>> and <<<artifactId>>> of the project to be build. For example,
- using
-
-+-----+
- mvn archetype:create \
- -DgroupId=sample.group.id \
- -DartifactId=sample-artifact-id
-+-----+
-
- this would create an <<<App.java>>> and an <<<AppTest.java>>>, both under the
- <<<sample.group.id>>> package. The <<<App.java>>> is a simple "Hello World"
- program while the <<<AppTest.java>>> is a subclass of
- <<<junit.framework.TestCase>>> that has one test which always passes.
-
- You can also specify other parameters such as version of the project to be
- created, the <<<packageName>>> of the classes, <<<remoteRepositories>>> and
- <<<pomRemoteRepositories>>> (See
- {{{examples/remote-repositories.html}Specifying the Remote Repositories}}),
- and the <<<archetypeGroupId>>>,
- <<<archetypeArtifactId>>>, and <<<archetypeVersion>>>.
-
- If the version is not specified, the default will be used which is
- <<<1.0-SNAPSHOT>>>. Also, if the <<<packageName>>> is not specified, the
- <<<maven-archetype-plugin>>> would derive the classes default package name
- based on the <<<groupId>>> (i.e. a <<<groupId sample.group.id>>> would have a
- default package name <<<sample.group.id>>>).
-
- Moreover, if the <<<archetypeGroupId>>>, <<<archetypeArtifactId>>> and
- <<<archetypeVersion>>> is not specified (as with the example above), the
- default would be used, which is <<<org.apache.maven.archetypes>>>,
- <<<maven-archetype-quickstart>>> and <<<1.0-SNAPSHOT>>> respectively.
-
- Thus, the above command is the same as
-
-+-----+
- mvn archetype:create
- -DgroupId=sample.group.id \
- -DartifactId=sample-artifact-id \
- -Dversion=1.0-SNAPSHOT \
- -DpackageName=sample.group.id \
- -DarchetypeGroupId=org.apache.maven.archetypes \
- -DarchetypeArtifactId=maven-archetype-quickstart \
- -DarchetypeVersion=1.0-SNAPSHOT
-+-----+
-
- But if you want to use a different archetype other than the default, you'd
- have to specify the following parameters: <<<archetypeGroupId>>>,
- <<<archetypeArtifactId>>>, and <<<archetypeVersion>>>.
-
- So for example, if you wish to create a project with a <<<groupId>>>
- <<<my.company.projects>>>, <<<artifactId>>> <<<my-project>>>, using an
- archetype with an <<<artifactId>>> <<<my-archetype>>>, <<<version>>>
- <<<1.0-archetype-SNAPSHOT>>>, under the <<<groupId>>>
- <<<my.company.archetypes>>>, you'd have to execute
-
-+-----+
-mvn archetype:create \
- -DgroupId=my.company.projects \
- -DartifactId=my-project \
- -DarchetypeGroupId=my.company.archetypes \
- -DarchetypeArtifactId=my-archetype \
- -DarchetypeVersion=1.0-archetype-SNAPSHOT
-+-----+
-
- But if the archetype that you're going to use has an element
- (<<<archetypeGroupId>>>, <<<archetypeArtifactId>>>, or <<<archetypeVersion>>>)
- has the same value as that of the default, then you don't have to specify that
- element.
-
- For example, if you're going to use <<<maven-archetype-webapp>>>
- <<<version>>> <<<1.0-SNAPSHOT>>> which is in under the <<<groupId>>>
- <<<org.apache.maven.archetypes>>>, you can simply use the following command
-
-+-----+
-mvn archetype:create
- -DgroupId=my.company.projects
- -DartifactId=another-project
- -DarchetypeArtifactId=maven-archetype-webapp
-+-----+
-
-* Create From Project
-
- Builds archetype containers based from an existing Maven project (<currently
- under development>).
-
diff --git a/maven-archetype/maven-archetype-plugin/src/site/fml/faq.fml b/maven-archetype/maven-archetype-plugin/src/site/fml/faq.fml
deleted file mode 100644
index 0975af3..0000000
--- a/maven-archetype/maven-archetype-plugin/src/site/fml/faq.fml
+++ /dev/null
@@ -1,73 +0,0 @@
-<?xml version="1.0"?>
-
-<!--
- ~ Copyright 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.
- -->
-
-<faqs id="FAQ" title="Frequently Asked Questions">
- <part id="General">
- <faq id="What is Archetype?">
- <question>
- What is Archetype?
- </question>
- <answer>
- <p>In short, Archetype is a Maven project templating toolkit. An
- archetype is defined as <i>an original pattern or model from which all
- other things of the same kind are made</i>. The names fits as we are
- trying to provide a system that provides a consistent means of
- generating Maven projects. Archetype will help authors create Maven
- project templates for users, and provides users with the means to
- generate parameterized versions of those project templates.</p>
-
- <p>Using archetypes provides a great way to enable developers quickly in
- a way consistent with best practices employed by your project or
- organization. Within the Maven project we use archetypes to try and get
- our users up and running as quickly as possible by providing a sample
- project that demonstrates many of the features of Maven while
- introducing new users to the best practices employed by Maven. In a
- matter of seconds a new user can have a working Maven project to use as
- a jumping board for investigating more of the features in Maven. We have
- also tried to make the Archetype mechanism additive and by that we mean
- allowing portions of a project to be captured in an archetype so that
- pieces or aspects of a project can be added to existing projects. A good
- example of this is the Maven site archetype. If, for example, you have
- used the quick start archetype to generate a working project you can
- then quickly create a site for that project by using the site archetype
- within that existing project. You can do anything like this with
- archetypes. </p>
-
- <p>You may want to standardize J2EE development within your organization
- so you may want to provide archetypes for EJBs, or WARs, or for your web
- services. Once these archetypes are created and deployed in your
- organization's repository they are available for use by all developers
- within your organization.</p>
- </answer>
- </faq>
- <faq id="What makes up an Archetype?">
- <question>
- What makes up an Archetype?
- </question>
- <answer>
- <p>Archetypes are packaged up in a JAR and they consist of the archetype
- metadata which describes the contents of archetype and a set of
- <a href = "http://jakarta.apache.org/velocity">Velocity </a> templates
- which make up the prototype project. If you would like to know how to
- make your own archetypes please refer to our <a href =
- "http://maven.apache.org/guides/mini/guide-creating-archetypes.html">
- Guide to creating archetypes</a>.</p>
- </answer>
- </faq>
- </part>
-</faqs>
diff --git a/maven-archetype/maven-archetype-plugin/src/site/site.xml b/maven-archetype/maven-archetype-plugin/src/site/site.xml
deleted file mode 100644
index aa70aad..0000000
--- a/maven-archetype/maven-archetype-plugin/src/site/site.xml
+++ /dev/null
@@ -1,65 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-
-<!--
- ~ Copyright 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 name="Maven Archetype Plugin">
- <bannerLeft>
- <name>Maven Archetype Plugin</name>
- <src>http://maven.apache.org/images/apache-maven-project-2.png</src>
- <href>http://maven.apache.org/</href>
- </bannerLeft>
- <bannerRight>
- <src>http://maven.apache.org/images/maven-logo-2.gif</src>
- </bannerRight>
- <skin>
- <groupId>org.apache.maven.skins</groupId>
- <artifactId>maven-stylus-skin</artifactId>
- </skin>
- <publishDate format="dd MMM yyyy" position="left" />
- <version position="left" />
- <body>
- <links>
- <item name="Apache" href="http://www.apache.org/"/>
- <item name="Maven 1.x" href="http://maven.apache.org/maven-1.x"/>
- <item name="Maven 2.x" href="http://maven.apache.org/"/>
- <item name="Maven 2.x Plugins" href="http://maven.apache.org/plugins/"/>
- <item name="Continuum" href="http://maven.apache.org/continuum"/>
- <item name="SCM" href="http://maven.apache.org/scm"/>
- <item name="Wagon" href="http://maven.apache.org/wagon"/>
- <item name="JXR" href="http://maven.apache.org/jxr"/>
- <item name="Doxia" href="http://maven.apache.org/doxia"/>
- </links>
-
- <menu name="Overview">
- <item name="Introduction" href="index.html"/>
- <item name="Usage" href="usage.html"/>
- <item name="Goals" href="plugin-info.html"/>
- <item name="FAQ" href="faq.html"/>
- </menu>
- <menu name="Examples">
- <item name="Specifying the Remote Repositories" href="/examples/remote-repositories.html"/>
- <item name="Creating a Simple Java Application" href="/examples/simple.html"/>
- <item name="Creating a Site" href="/examples/site.html"/>
- <item name="Creating a Simple j2ee Project" href="/examples/j2ee-simple.html"/>
- <item name="Creating a Webapp" href="/examples/webapp.html"/>
- <item name="Creating a Portlet" href="/examples/portlet.html"/>
- <item name="Creating a Mojo" href="/examples/mojo.html"/>
- <item name="Creating your own Archetype" href="/examples/archetype.html"/>
- </menu>
- ${reports}
- </body>
-</project>
diff --git a/maven-archetype/pom.xml b/maven-archetype/pom.xml
deleted file mode 100644
index 7c1ed1e..0000000
--- a/maven-archetype/pom.xml
+++ /dev/null
@@ -1,87 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.maven.archetype</groupId>
- <artifactId>maven-archetype-parent</artifactId>
- <version>1</version>
- </parent>
- <groupId>org.apache.maven.archetype</groupId>
- <artifactId>maven-archetype</artifactId>
- <packaging>pom</packaging>
- <version>1.0-SNAPSHOT</version>
- <name>Maven Archetype</name>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.apache.maven.archetype</groupId>
- <artifactId>maven-archetype-model</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven.archetype</groupId>
- <artifactId>maven-archetype-core</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven.archetype</groupId>
- <artifactId>maven-archetype-creator</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
- </dependencyManagement>
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-maven-plugin</artifactId>
- <version>1.1</version>
- <executions>
- <execution>
- <goals>
- <goal>descriptor</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- <pluginManagement>
- <plugins>
- <plugin>
- <artifactId>maven-release-plugin</artifactId>
- <configuration>
- <arguments>-Prelease</arguments>
- </configuration>
- </plugin>
- </plugins>
- </pluginManagement>
- </build>
- <modules>
- <module>maven-archetype-core</module>
- <module>maven-archetype-creator</module>
- <module>maven-archetype-plugin</module>
- <module>maven-archetype-model</module>
- </modules>
-</project>