All pastes #189139 Raw Edit

Stuff

public text v1 · immutable
·published 2006-10-02 21:18 UTC
rendered paste body
Index: src/main/java/org/apache/maven/archetype/DefaultArchetype.java
===================================================================
--- src/main/java/org/apache/maven/archetype/DefaultArchetype.java	(revision 452174)
+++ src/main/java/org/apache/maven/archetype/DefaultArchetype.java	(working copy)
@@ -69,852 +69,781 @@
  * @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";
+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_TEST_SOURCE_DIR = "/src/test/java";
 
-    private static final String DEFAULT_RESOURCE_DIR = "/src/main/resources";
+	private static final String DEFAULT_RESOURCE_DIR = "/src/main/resources";
 
-    private static final String DEFAULT_SOURCE_DIR = "/src/main/java";
+	private static final String DEFAULT_SOURCE_DIR = "/src/main/java";
 
-    // ----------------------------------------------------------------------
-    // Components
-    // ----------------------------------------------------------------------
+	// ----------------------------------------------------------------------
+	// Components
+	// ----------------------------------------------------------------------
 
-    private VelocityComponent velocity;
+	private VelocityComponent velocity;
 
-    private ArtifactResolver artifactResolver;
+	private ArtifactResolver artifactResolver;
 
-    // ----------------------------------------------------------------------
-    // Implementation
-    // ----------------------------------------------------------------------
+	// ----------------------------------------------------------------------
+	// Implementation
+	// ----------------------------------------------------------------------
 
-    private ArtifactFactory artifactFactory;
+	private ArtifactFactory artifactFactory;
 
-    // groupId = maven
-    // artifactId = maven-foo-archetype
-    // version = latest
+	// 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
-        // ----------------------------------------------------------------------
+	public void createArchetype(String archetypeGroupId,
+			String archetypeArtifactId, String archetypeVersion,
+			ArtifactRepository localRepository, List remoteRepositories,
+			Map parameters) throws ArchetypeNotFoundException,
+			ArchetypeDescriptorException, ArchetypeTemplateProcessingException {
+		// ----------------------------------------------------------------------
+		// Download the archetype
+		// ----------------------------------------------------------------------
 
-        Artifact archetypeArtifact = artifactFactory.createArtifact( archetypeGroupId, archetypeArtifactId,
-                                                                     archetypeVersion, Artifact.SCOPE_RUNTIME, "jar" );
+		Artifact archetypeArtifact = artifactFactory.createArtifact(
+				archetypeGroupId, archetypeArtifactId, archetypeVersion,
+				Artifact.SCOPE_RUNTIME, "jar");
 
-        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 );
-        }
+		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);
+		}
 
-        // ---------------------------------------------------------------------
-        // Get Logger and display all parameters used
-        // ---------------------------------------------------------------------
-        if ( getLogger().isInfoEnabled() )
-        {
-            if ( !parameters.isEmpty() )
-            {
-                getLogger().info( "----------------------------------------------------------------------------" );
+		// ---------------------------------------------------------------------
+		// 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(
+						"Using following parameters for creating Archetype: "
+								+ archetypeArtifactId + ":" + archetypeVersion);
 
-                getLogger().info( "----------------------------------------------------------------------------" );
+				getLogger()
+						.info(
+								"----------------------------------------------------------------------------");
 
-                Set keys = parameters.keySet();
+				Set keys = parameters.keySet();
 
-                Iterator it = keys.iterator();
+				Iterator it = keys.iterator();
 
-                while ( it.hasNext() )
-                {
-                    String parameterName = (String) it.next();
+				while (it.hasNext()) {
+					String parameterName = (String) it.next();
 
-                    String parameterValue = (String) parameters.get( parameterName );
+					String parameterValue = (String) parameters
+							.get(parameterName);
 
-                    getLogger().info( "Parameter: " + parameterName + ", Value: " + parameterValue );
-                }
-            }
-            else
-            {
-                getLogger().info( "No Parameters found for creating Archetype" );
-            }
-        }
+					getLogger().info(
+							"Parameter: " + parameterName + ", Value: "
+									+ parameterValue);
+				}
+			} else {
+				getLogger().info("No Parameters found for creating Archetype");
+			}
+		}
 
-        // ----------------------------------------------------------------------
-        // Load the descriptor
-        // ----------------------------------------------------------------------
+		// ----------------------------------------------------------------------
+		// Load the descriptor
+		// ----------------------------------------------------------------------
 
-        ArchetypeDescriptorBuilder builder = new ArchetypeDescriptorBuilder();
+		ArchetypeDescriptorBuilder builder = new ArchetypeDescriptorBuilder();
 
-        ArchetypeDescriptor descriptor;
+		ArchetypeDescriptor descriptor;
 
-        URLClassLoader archetypeJarLoader;
+		URLClassLoader archetypeJarLoader;
 
-        try
-        {
-            URL[] urls = new URL[1];
+		try {
+			URL[] urls = new URL[1];
 
-            urls[0] = archetypeArtifact.getFile().toURL();
+			urls[0] = archetypeArtifact.getFile().toURL();
 
-            archetypeJarLoader = new URLClassLoader( urls );
+			archetypeJarLoader = new URLClassLoader(urls);
 
-            InputStream is = getStream( ARCHETYPE_DESCRIPTOR, archetypeJarLoader );
+			InputStream is = getStream(ARCHETYPE_DESCRIPTOR, archetypeJarLoader);
 
-            if ( is == null )
-            {
-                is = getStream( ARCHETYPE_OLD_DESCRIPTOR, archetypeJarLoader );
+			if (is == null) {
+				is = getStream(ARCHETYPE_OLD_DESCRIPTOR, archetypeJarLoader);
 
-                if ( is == null )
-                {
-                    throw new ArchetypeDescriptorException(
-                        "The " + ARCHETYPE_DESCRIPTOR + " descriptor cannot be found." );
-                }
-            }
+				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 );
-        }
+			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 basedir = (String) parameters.get("basedir");
 
-        String artifactId = (String) parameters.get( "artifactId" );
+		String artifactId = (String) parameters.get("artifactId");
 
-        File parentPomFile = new File( basedir, ARCHETYPE_POM );
+		File parentPomFile = new File(basedir, ARCHETYPE_POM);
 
-        File outputDirectoryFile;
+		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." );
-            }
+		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;
+			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" );
-                }
-            }
+			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 );
-        }
+			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 (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." );
-            }
-        }
+			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 outputDirectory = outputDirectoryFile.getAbsolutePath();
 
-        String packageName = (String) parameters.get( "package" );
+		String packageName = (String) parameters.get("package");
 
-        // ----------------------------------------------------------------------
-        // Set up the Velocity context
-        // ----------------------------------------------------------------------
+		// ----------------------------------------------------------------------
+		// Set up the Velocity context
+		// ----------------------------------------------------------------------
 
-        Context context = new VelocityContext();
+		Context context = new VelocityContext();
 
-        context.put( "package", packageName );
+		context.put("package", packageName);
 
-        for ( Iterator iterator = parameters.keySet().iterator(); iterator.hasNext(); )
-        {
-            String key = (String) iterator.next();
+		for (Iterator iterator = parameters.keySet().iterator(); iterator
+				.hasNext();) {
+			String key = (String) iterator.next();
 
-            Object value = parameters.get( key );
+			Object value = parameters.get(key);
 
-            context.put( key, value );
-        }
+			context.put(key, value);
+		}
 
-        // ----------------------------------------------------------------------
-        // Process the templates
-        // ----------------------------------------------------------------------
+		// Pick up the ContextProperties from the Descriptor
+		for (Iterator iterator = descriptor.getContextProperties().keySet()
+				.iterator(); iterator.hasNext();) {
+			String key = (String) iterator.next();
+			Object value = descriptor.getContextProperties().get(key);
+			if (System.getProperties().containsKey(key)) {
+				value = System.getProperties().get(key);
+			}
+			context.put(key, value);
 
-        ClassLoader old = Thread.currentThread().getContextClassLoader();
+			getLogger().info(
+					"Adding Context Parameter: " + key + ", Value: " + value);
+		}
 
-        Thread.currentThread().setContextClassLoader( archetypeJarLoader );
+		// ----------------------------------------------------------------------
+		// Process the templates
+		// ----------------------------------------------------------------------
 
-        Model parentModel = null;
-        if ( creating )
-        {
-            if ( parentPomFile.exists() )
-            {
-                FileReader fileReader = null;
+		ClassLoader old = Thread.currentThread().getContextClassLoader();
 
-                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 );
-                }
+		Thread.currentThread().setContextClassLoader(archetypeJarLoader);
 
-                parentModel.getModules().add( artifactId );
-            }
-        }
+		Model parentModel = null;
+		if (creating) {
+			if (parentPomFile.exists()) {
+				FileReader fileReader = null;
 
-        try
-        {
-            processTemplates( pomFile, outputDirectory, context, descriptor, packageName, parentModel );
-        }
-        finally
-        {
-            Thread.currentThread().setContextClassLoader( old );
-        }
+				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);
+				}
 
-        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;
+				parentModel.getModules().add(artifactId);
+			}
+		}
 
-            try
-            {
-                fileWriter = new FileWriter( parentPomFile );
+		try {
+			processTemplates(pomFile, outputDirectory, context, descriptor,
+					packageName, parentModel);
+		} finally {
+			Thread.currentThread().setContextClassLoader(old);
+		}
 
-                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 (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 );
-                }
-            }
-        }
+			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 );
-        }
+		// ----------------------------------------------------------------------
+		// 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();
+	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'" );
-        }
+		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;
-                }
-            }
+		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 );
-            }
+			if (lastTextNode != null) {
+				modules.remove(lastTextNode);
+			}
 
-            modules.addText( "\n    " );
-            modules.addElement( "module" ).setText( artifactId );
-            modules.addText( "\n  " );
+			modules.addText("\n    ");
+			modules.addElement("module").setText(artifactId);
+			modules.addText("\n  ");
 
-            XMLWriter writer = new XMLWriter( fileWriter );
-            writer.write( document );
-        }
-        return !found;
-    }
+			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 );
-        }
+	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 generated for the new archetype, so process it now
+		// ---------------------------------------------------------------------
 
-        Model generatedModel;
-        FileReader pomReader = null;
-        try
-        {
-            pomReader = new FileReader( pomFile );
+		Model generatedModel;
+		FileReader pomReader = null;
+		try {
+			pomReader = new FileReader(pomFile);
 
-            MavenXpp3Reader reader = new MavenXpp3Reader();
+			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 );
-        }
+			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 );
+		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 );
+			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 );
-            }
-        }
+				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();
+		// 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 overrideSrcDir = false;
 
-        boolean overrideResourceDir = false;
+		boolean overrideResourceDir = false;
 
-        boolean overrideTestSrcDir = false;
+		boolean overrideTestSrcDir = false;
 
-        boolean overrideTestResourceDir = false;
+		boolean overrideTestResourceDir = false;
 
-        boolean foundBuildElement = build != null;
+		boolean foundBuildElement = build != null;
 
-        if ( getLogger().isDebugEnabled() )
-        {
-            getLogger().debug(
-                "********************* Debug info for resources created from generated Model ***********************" );
-        }
+		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 );
-        }
+		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 " );
-            }
+		// create source directory if specified in POM
+		if (foundBuildElement && null != build.getSourceDirectory()) {
+			if (getLogger().isDebugEnabled()) {
+				getLogger().debug("Overriding default source directory ");
+			}
 
-            overrideSrcDir = true;
+			overrideSrcDir = true;
 
-            String srcDirectory = build.getSourceDirectory();
+			String srcDirectory = build.getSourceDirectory();
 
-            srcDirectory = StringUtils.replace( srcDirectory, "\\", "/" );
+			srcDirectory = StringUtils.replace(srcDirectory, "\\", "/");
 
-            FileUtils.mkdir( getOutputDirectory( outputDirectory, 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 " );
-            }
+		// 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();
+			String scriptSourceDirectory = build.getScriptSourceDirectory();
 
-            scriptSourceDirectory = StringUtils.replace( scriptSourceDirectory, "\\", "/" );
+			scriptSourceDirectory = StringUtils.replace(scriptSourceDirectory,
+					"\\", "/");
 
-            FileUtils.mkdir( getOutputDirectory( outputDirectory, 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 " );
-            }
+		// 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;
+			overrideResourceDir = true;
 
-            Iterator resourceItr = build.getResources().iterator();
+			Iterator resourceItr = build.getResources().iterator();
 
-            while ( resourceItr.hasNext() )
-            {
-                Resource resource = (Resource) resourceItr.next();
+			while (resourceItr.hasNext()) {
+				Resource resource = (Resource) resourceItr.next();
 
-                String resourceDirectory = resource.getDirectory();
+				String resourceDirectory = resource.getDirectory();
 
-                resourceDirectory = StringUtils.replace( resourceDirectory, "\\", "/" );
+				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 " );
-            }
+				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;
+			overrideTestSrcDir = true;
 
-            String testDirectory = build.getTestSourceDirectory();
+			String testDirectory = build.getTestSourceDirectory();
 
-            testDirectory = StringUtils.replace( testDirectory, "\\", "/" );
+			testDirectory = StringUtils.replace(testDirectory, "\\", "/");
 
-            FileUtils.mkdir( getOutputDirectory( outputDirectory, 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 " );
-            }
+		// 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;
+			overrideTestResourceDir = true;
 
-            Iterator testResourceItr = build.getTestResources().iterator();
+			Iterator testResourceItr = build.getTestResources().iterator();
 
-            while ( testResourceItr.hasNext() )
-            {
-                Resource resource = (Resource) testResourceItr.next();
+			while (testResourceItr.hasNext()) {
+				Resource resource = (Resource) testResourceItr.next();
 
-                String testResourceDirectory = resource.getDirectory();
+				String testResourceDirectory = resource.getDirectory();
 
-                testResourceDirectory = StringUtils.replace( testResourceDirectory, "\\", "/" );
+				testResourceDirectory = StringUtils.replace(
+						testResourceDirectory, "\\", "/");
 
-                FileUtils.mkdir( getOutputDirectory( outputDirectory, testResourceDirectory ) );
-            }
-        }
+				FileUtils.mkdir(getOutputDirectory(outputDirectory,
+						testResourceDirectory));
+			}
+		}
 
-        getLogger().info(
-            "********************* End of debug info from resources from generated POM ***********************" );
+		getLogger()
+				.info(
+						"********************* End of debug info from resources from generated POM ***********************");
 
-        // ----------------------------------------------------------------------
-        // Main
-        // ----------------------------------------------------------------------
+		// ----------------------------------------------------------------------
+		// 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.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 );
-        }
+		if (descriptor.getResources().size() > 0) {
+			if (!overrideResourceDir) {
+				FileUtils.mkdir(outputDirectory + DEFAULT_RESOURCE_DIR);
+			}
+			processResources(outputDirectory, context, descriptor, packageName);
+		}
 
-        // ----------------------------------------------------------------------
-        // Test
-        // ----------------------------------------------------------------------
+		// ----------------------------------------------------------------------
+		// 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.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 );
-        }
+		if (descriptor.getTestResources().size() > 0) {
+			if (!overrideTestResourceDir) {
+				FileUtils.mkdir(outputDirectory + DEFAULT_TEST_RESOURCE_DIR);
+			}
+			processTestResources(outputDirectory, context, descriptor,
+					packageName);
+		}
 
-        // ----------------------------------------------------------------------
-        // Site
-        // ----------------------------------------------------------------------
+		// ----------------------------------------------------------------------
+		// Site
+		// ----------------------------------------------------------------------
 
-        if ( descriptor.getSiteResources().size() > 0 )
-        {
-            processSiteResources( outputDirectory, context, descriptor, packageName );
-        }
-    }
+		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 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 );
-    }
+	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();
+	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 );
-        }
-    }
+			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();
+	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 );
-        }
-    }
+			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();
+	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 );
-        }
-    }
+			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();
+	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 );
-        }
-    }
+			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();
+	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 );
-        }
-    }
+			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;
+	protected void processTemplate(String outputDirectory, Context context,
+			String template, TemplateDescriptor descriptor,
+			boolean packageInFileName, String packageName,
+			String sourceDirectory) throws ArchetypeTemplateProcessingException {
+		if (descriptor.getCondition() != null
+				&& descriptor.getCondition().isIncluded(context)) {
+			File f;
 
-        template = StringUtils.replace( template, "\\", "/" );
+			template = StringUtils.replace(template, "\\", "/");
 
-        if ( packageInFileName && packageName != null )
-        {
-            String templateFileName = StringUtils.replace( template, "/", File.separator );
+			if (packageInFileName && packageName != null) {
+				String templateFileName = StringUtils.replace(template, "/",
+						File.separator);
 
-            String path = packageName.replace( '.', '/' );
+				String path = packageName.replace('.', '/');
 
-            String filename = FileUtils.filename( templateFileName );
+				String filename = FileUtils.filename(templateFileName);
 
-            String dirname = FileUtils.dirname( templateFileName ).replace( '\\', '/' );
+				String dirname = FileUtils.dirname(templateFileName).replace(
+						'\\', '/');
 
-            sourceDirectory = sourceDirectory.replace( '\\', '/' );
-            if ( sourceDirectory.startsWith( "/" ) )
-            {
-                sourceDirectory = sourceDirectory.substring( 1 );
-            }
+				sourceDirectory = sourceDirectory.replace('\\', '/');
+				if (sourceDirectory.startsWith("/")) {
+					sourceDirectory = sourceDirectory.substring(1);
+				}
 
-            if ( !dirname.startsWith( sourceDirectory ) )
-            {
-                throw new ArchetypeTemplateProcessingException(
-                    "Template '" + template + "' not in directory '" + sourceDirectory + "'" );
-            }
+				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;
-            }
+				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 );
-        }
+				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 (!f.getParentFile().exists()) {
+				f.getParentFile().mkdirs();
+			}
 
-        if ( descriptor.isFiltered() )
-        {
-            Writer writer = null;
-            try
-            {
-                writer = new OutputStreamWriter( new FileOutputStream( f ), descriptor.getEncoding() );
+			if (descriptor.isFiltered()) {
+				Writer writer = null;
+				try {
+					writer = new OutputStreamWriter(new FileOutputStream(f),
+							descriptor.getEncoding());
 
-                template = ARCHETYPE_RESOURCES + "/" + template;
+					template = ARCHETYPE_RESOURCES + "/" + template;
 
-                velocity.getEngine().mergeTemplate( template, descriptor.getEncoding(), context, writer );
+					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 );
+					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;
+				OutputStream fos = null;
 
-            try
-            {
-                fos = new FileOutputStream( f );
+				try {
+					fos = new FileOutputStream(f);
 
-                IOUtil.copy( is, fos );
-            }
-            catch ( Exception e )
-            {
-                throw new ArchetypeTemplateProcessingException( "Error copying file", e );
-            }
-            finally
-            {
-                IOUtil.close( fos );
+					IOUtil.copy(is, fos);
+				} catch (Exception e) {
+					throw new ArchetypeTemplateProcessingException(
+							"Error copying file", e);
+				} finally {
+					IOUtil.close(fos);
 
-                IOUtil.close( is );
-            }
-        }
-    }
+					IOUtil.close(is);
+				}
+			}
+		}
+	}
 
-    protected void createProjectDirectoryStructure( String outputDirectory )
-    {
-    }
+	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 );
-    }
+	private InputStream getStream(String name, ClassLoader loader) {
+		if (loader == null) {
+			return Thread.currentThread().getContextClassLoader()
+					.getResourceAsStream(name);
+		}
+		return loader.getResourceAsStream(name);
+	}
 }
Index: src/main/java/org/apache/maven/archetype/descriptor/ArchetypeDescriptor.java
===================================================================
--- src/main/java/org/apache/maven/archetype/descriptor/ArchetypeDescriptor.java	(revision 452174)
+++ src/main/java/org/apache/maven/archetype/descriptor/ArchetypeDescriptor.java	(working copy)
@@ -20,242 +20,230 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Properties;
 
-public class ArchetypeDescriptor
-{
-    private String id;
+public class ArchetypeDescriptor {
+	private String id;
 
-    private List sources;
+	private List sources;
 
-    private List testSources;
+	private List testSources;
 
-    private List resources;
+	private List resources;
 
-    private List testResources;
+	private List testResources;
 
-    private List siteResources;
+	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;
+	private Properties contextProperties = new Properties();
 
-    /**
-     * <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>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>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>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>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>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>siteResources</code> with their attributes (instances of
-     * <code>TemplateDescriptor</code>.
-     */
-    private Map siteResourcesDescriptors;
+	/**
+	 * <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;
 
-    /**
-     * 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;
+	/**
+	 * <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;
 
-    public ArchetypeDescriptor()
-    {
-        sources = new ArrayList();
+	/**
+	 * 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;
 
-        resources = new ArrayList();
+	public ArchetypeDescriptor() {
+		sources = new ArrayList();
 
-        testSources = new ArrayList();
+		resources = new ArrayList();
 
-        testResources = new ArrayList();
+		testSources = new ArrayList();
 
-        siteResources = new ArrayList();
+		testResources = new ArrayList();
 
-        sourcesDescriptors = new HashMap();
+		siteResources = new ArrayList();
 
-        testSourcesDescriptors = new HashMap();
+		sourcesDescriptors = new HashMap();
 
-        resourcesDescriptors = new HashMap();
+		testSourcesDescriptors = new HashMap();
 
-        testResourcesDescriptors = new HashMap();
+		resourcesDescriptors = new HashMap();
 
-        siteResourcesDescriptors = new HashMap();
-    }
+		testResourcesDescriptors = new HashMap();
 
-    // ----------------------------------------------------------------------
-    //
-    // ----------------------------------------------------------------------
+		siteResourcesDescriptors = new HashMap();
+	}
 
-    public String getId()
-    {
-        return id;
-    }
+	// ----------------------------------------------------------------------
+	//
+	// ----------------------------------------------------------------------
 
-    public void setId( String id )
-    {
-        this.id = id;
-    }
+	public String getId() {
+		return id;
+	}
 
-    public void addSource( String source )
-    {
-        sources.add( source );
+	public void setId(String id) {
+		this.id = id;
+	}
 
-        putSourceDescriptor( source, new TemplateDescriptor() );
-    }
+	public void addSource(String source) {
+		sources.add(source);
 
-    public List getSources()
-    {
-        return sources;
-    }
+		putSourceDescriptor(source, new TemplateDescriptor());
+	}
 
-    public void putSourceDescriptor( String source, TemplateDescriptor descriptor )
-    {
-        sourcesDescriptors.put( source, descriptor );
-    }
+	public List getSources() {
+		return sources;
+	}
 
-    public TemplateDescriptor getSourceDescriptor( String source )
-    {
-        return (TemplateDescriptor) sourcesDescriptors.get( source );
-    }
+	public void putSourceDescriptor(String source, TemplateDescriptor descriptor) {
+		sourcesDescriptors.put(source, descriptor);
+	}
 
-    public Map getSourcesDescriptors()
-    {
-        return sourcesDescriptors;
-    }
+	public TemplateDescriptor getSourceDescriptor(String source) {
+		return (TemplateDescriptor) sourcesDescriptors.get(source);
+	}
 
-    public void addTestSource( String testSource )
-    {
-        testSources.add( testSource );
+	public Map getSourcesDescriptors() {
+		return sourcesDescriptors;
+	}
 
-        putTestSourceDescriptor( testSource, new TemplateDescriptor() );
-    }
+	public void addTestSource(String testSource) {
+		testSources.add(testSource);
 
-    public List getTestSources()
-    {
-        return testSources;
-    }
+		putTestSourceDescriptor(testSource, new TemplateDescriptor());
+	}
 
-    public void putTestSourceDescriptor( String testSource, TemplateDescriptor descriptor )
-    {
-        testSourcesDescriptors.put( testSource, descriptor );
-    }
+	public List getTestSources() {
+		return testSources;
+	}
 
-    public TemplateDescriptor getTestSourceDescriptor( String testSource )
-    {
-        return (TemplateDescriptor) testSourcesDescriptors.get( testSource );
-    }
+	public void putTestSourceDescriptor(String testSource,
+			TemplateDescriptor descriptor) {
+		testSourcesDescriptors.put(testSource, descriptor);
+	}
 
-    public Map getTestSourcesDescriptors()
-    {
-        return testSourcesDescriptors;
-    }
+	public TemplateDescriptor getTestSourceDescriptor(String testSource) {
+		return (TemplateDescriptor) testSourcesDescriptors.get(testSource);
+	}
 
-    public void addResource( String resource )
-    {
-        resources.add( resource );
+	public Map getTestSourcesDescriptors() {
+		return testSourcesDescriptors;
+	}
 
-        putResourceDescriptor( resource, new TemplateDescriptor() );
-    }
+	public void addResource(String resource) {
+		resources.add(resource);
 
-    public List getResources()
-    {
-        return resources;
-    }
+		putResourceDescriptor(resource, new TemplateDescriptor());
+	}
 
-    public void putResourceDescriptor( String resource, TemplateDescriptor descriptor )
-    {
-        resourcesDescriptors.put( resource, descriptor );
-    }
+	public List getResources() {
+		return resources;
+	}
 
-    public TemplateDescriptor getResourceDescriptor( String resource )
-    {
-        return (TemplateDescriptor) resourcesDescriptors.get( resource );
-    }
+	public void putResourceDescriptor(String resource,
+			TemplateDescriptor descriptor) {
+		resourcesDescriptors.put(resource, descriptor);
+	}
 
-    public Map getReourcesDescriptors()
-    {
-        return resourcesDescriptors;
-    }
+	public TemplateDescriptor getResourceDescriptor(String resource) {
+		return (TemplateDescriptor) resourcesDescriptors.get(resource);
+	}
 
-    public void addTestResource( String testResource )
-    {
-        testResources.add( testResource );
-        putTestResourceDescriptor( testResource, new TemplateDescriptor() );
-    }
+	public Map getReourcesDescriptors() {
+		return resourcesDescriptors;
+	}
 
-    public List getTestResources()
-    {
-        return testResources;
-    }
+	public void addTestResource(String testResource) {
+		testResources.add(testResource);
+		putTestResourceDescriptor(testResource, new TemplateDescriptor());
+	}
 
-    public void putTestResourceDescriptor( String testResource, TemplateDescriptor descriptor )
-    {
-        testResourcesDescriptors.put( testResource, descriptor );
-    }
+	public List getTestResources() {
+		return testResources;
+	}
 
-    public TemplateDescriptor getTestResourceDescriptor( String testResource )
-    {
-        return (TemplateDescriptor) testResourcesDescriptors.get( testResource );
-    }
+	public void putTestResourceDescriptor(String testResource,
+			TemplateDescriptor descriptor) {
+		testResourcesDescriptors.put(testResource, descriptor);
+	}
 
-    public Map getTestReourcesDescriptors()
-    {
-        return testResourcesDescriptors;
-    }
+	public TemplateDescriptor getTestResourceDescriptor(String testResource) {
+		return (TemplateDescriptor) testResourcesDescriptors.get(testResource);
+	}
 
-    public void addSiteResource( String siteResource )
-    {
-        siteResources.add( siteResource );
+	public Map getTestReourcesDescriptors() {
+		return testResourcesDescriptors;
+	}
 
-        putSiteResourceDescriptor( siteResource, new TemplateDescriptor() );
-    }
+	public void addSiteResource(String siteResource) {
+		siteResources.add(siteResource);
 
-    public List getSiteResources()
-    {
-        return siteResources;
-    }
+		putSiteResourceDescriptor(siteResource, new TemplateDescriptor());
+	}
 
-    public void putSiteResourceDescriptor( String siteResource, TemplateDescriptor descriptor )
-    {
-        siteResourcesDescriptors.put( siteResource, descriptor );
-    }
+	public List getSiteResources() {
+		return siteResources;
+	}
 
-    public TemplateDescriptor getSiteResourceDescriptor( String siteResource )
-    {
-        return (TemplateDescriptor) siteResourcesDescriptors.get( siteResource );
-    }
+	public void putSiteResourceDescriptor(String siteResource,
+			TemplateDescriptor descriptor) {
+		siteResourcesDescriptors.put(siteResource, descriptor);
+	}
 
-    public Map getSiteReourcesDescriptors()
-    {
-        return siteResourcesDescriptors;
-    }
+	public TemplateDescriptor getSiteResourceDescriptor(String siteResource) {
+		return (TemplateDescriptor) siteResourcesDescriptors.get(siteResource);
+	}
 
-    public boolean isAllowPartial()
-    {
-        return allowPartial;
-    }
+	public Map getSiteReourcesDescriptors() {
+		return siteResourcesDescriptors;
+	}
 
-    public void setAllowPartial( boolean allowPartial )
-    {
-        this.allowPartial = allowPartial;
-    }
+	public boolean isAllowPartial() {
+		return allowPartial;
+	}
+
+	public void setAllowPartial(boolean allowPartial) {
+		this.allowPartial = allowPartial;
+	}
+
+	public Properties getContextProperties() {
+		return contextProperties;
+	}
+
+	public void setContextProperties(Properties contextProperties) {
+		this.contextProperties = contextProperties;
+	}
+	
+	public void addContextProperty(String name,String value) {
+		this.contextProperties.put(name, value);
+	}
 }
Index: src/main/java/org/apache/maven/archetype/descriptor/ArchetypeDescriptorBuilder.java
===================================================================
--- src/main/java/org/apache/maven/archetype/descriptor/ArchetypeDescriptorBuilder.java	(revision 452174)
+++ src/main/java/org/apache/maven/archetype/descriptor/ArchetypeDescriptorBuilder.java	(working copy)
@@ -123,11 +123,39 @@
                 addSiteResourceToDescriptor( siteResourceList[i], descriptor );
             }
         }
+        
+        // ----------------------------------------------------------------------
+        // Context Properties for Velocity
+        // ----------------------------------------------------------------------
 
+        Xpp3Dom contextProperties = dom.getChild( "contextProperties" );
+
+        if ( contextProperties != null )
+        {
+            Xpp3Dom[] contextPropertiesList = contextProperties.getChildren( "property" );
+
+            for ( int i = 0; i < contextPropertiesList.length; i++ )
+            {
+                addContextPropertyToDescriptor( contextPropertiesList[i], descriptor );
+            }
+        }
+
         return descriptor;
     }
 
-    /**
+    private void addContextPropertyToDescriptor(Xpp3Dom contextProperty, ArchetypeDescriptor descriptor) {    	
+        
+    	String name =  contextProperty.getAttribute( "name");
+    	
+    	String value =  contextProperty.getAttribute( "value");
+       
+    	if (name==null || value==null)
+    		throw new RuntimeException("A context property must have the name and value attributes specified");
+		
+    	descriptor.addContextProperty(name, value);
+	}
+
+	/**
      * 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>
@@ -143,7 +171,7 @@
         descriptor.addSource( source.getValue() );
 
         TemplateDescriptor sourceDesc = descriptor.getSourceDescriptor( source.getValue() );
-
+        sourceDesc.setCondition(TemplateConditionFactory.getCondition(source));
         sourceDesc.setFiltered( true );
 
         if ( source.getAttribute( "encoding" ) != null )
@@ -187,7 +215,7 @@
         if ( resource.getAttribute( "filtered" ) != null )
         {
             TemplateDescriptor resourceDesc = descriptor.getResourceDescriptor( resource.getValue() );
-
+            resourceDesc.setCondition(TemplateConditionFactory.getCondition(resource));
             try
             {
                 resourceDesc.setFiltered( getValueFilteredAttribute( resource.getAttribute( "filtered" ) ) );
@@ -240,6 +268,7 @@
     {
         descriptor.addTestSource( testSource.getValue() );
         TemplateDescriptor testSourceDesc = descriptor.getTestSourceDescriptor( testSource.getValue() );
+        testSourceDesc.setCondition(TemplateConditionFactory.getCondition(testSource));
         testSourceDesc.setFiltered( true );
         if ( testSource.getAttribute( "encoding" ) != null )
         {
@@ -283,7 +312,7 @@
         if ( testResource.getAttribute( "filtered" ) != null )
         {
             TemplateDescriptor testResourceDesc = descriptor.getTestResourceDescriptor( testResource.getValue() );
-
+            testResourceDesc.setCondition(TemplateConditionFactory.getCondition(testResource));
             try
             {
                 testResourceDesc.setFiltered( getValueFilteredAttribute( testResource.getAttribute( "filtered" ) ) );
@@ -297,7 +326,7 @@
         if ( testResource.getAttribute( "encoding" ) != null )
         {
             TemplateDescriptor testResourceDesc = descriptor.getTestResourceDescriptor( testResource.getValue() );
-
+            testResourceDesc.setCondition(TemplateConditionFactory.getCondition(testResource));
             try
             {
                 testResourceDesc.setEncoding( testResource.getAttribute( "encoding" ) );
@@ -347,7 +376,7 @@
         if ( siteResource.getAttribute( "filtered" ) != null )
         {
             TemplateDescriptor siteResourceDesc = descriptor.getSiteResourceDescriptor( siteResource.getValue() );
-
+            siteResourceDesc.setCondition(TemplateConditionFactory.getCondition(siteResource));
             try
             {
                 siteResourceDesc.setFiltered( getValueFilteredAttribute( siteResource.getAttribute( "filtered" ) ) );
@@ -360,7 +389,7 @@
         if ( siteResource.getAttribute( "encoding" ) != null )
         {
             TemplateDescriptor siteResourceDesc = descriptor.getSiteResourceDescriptor( siteResource.getValue() );
-
+            siteResourceDesc.setCondition(TemplateConditionFactory.getCondition(siteResource));
             try
             {
                 siteResourceDesc.setEncoding( siteResource.getAttribute( "encoding" ) );
@@ -379,7 +408,7 @@
         if ( siteResource.getValue().endsWith( ".properties" ) )
         {
             TemplateDescriptor siteResourceDesc = descriptor.getSiteResourceDescriptor( siteResource.getValue() );
-
+            siteResourceDesc.setCondition(TemplateConditionFactory.getCondition(siteResource));
             siteResourceDesc.setEncoding( "iso-8859-1" );
         }
     }
Index: src/main/java/org/apache/maven/archetype/descriptor/PropertyEqualCondition.java
===================================================================
--- src/main/java/org/apache/maven/archetype/descriptor/PropertyEqualCondition.java	(revision 0)
+++ src/main/java/org/apache/maven/archetype/descriptor/PropertyEqualCondition.java	(revision 0)
@@ -0,0 +1,45 @@
+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.apache.velocity.context.Context;
+
+/**
+ * A property based condition can be used to test a property value to 
+ * determine whether to include it
+ * 
+ */
+public class PropertyEqualCondition implements TemplateCondition {
+
+	private String parameter;
+	private String value;
+
+	public PropertyEqualCondition(String parameter, String value) {
+		this.parameter = parameter;
+		this.value = value;
+	}
+
+	public boolean isIncluded(Context context) {
+		if (context.get(parameter)!=null) {
+			return context.get(parameter).equals(value);
+		}
+		return false;
+	}
+	
+	
+
+}
Index: src/main/java/org/apache/maven/archetype/descriptor/TemplateCondition.java
===================================================================
--- src/main/java/org/apache/maven/archetype/descriptor/TemplateCondition.java	(revision 0)
+++ src/main/java/org/apache/maven/archetype/descriptor/TemplateCondition.java	(revision 0)
@@ -0,0 +1,30 @@
+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.apache.velocity.context.Context;
+
+/**
+ * 
+ * Basic interface that can allow people to add new types of condition which 
+ * can be used to determine whether a template should be included
+ *
+ */
+public interface TemplateCondition {
+
+	public boolean isIncluded(Context context);
+}
Index: src/main/java/org/apache/maven/archetype/descriptor/TemplateConditionFactory.java
===================================================================
--- src/main/java/org/apache/maven/archetype/descriptor/TemplateConditionFactory.java	(revision 0)
+++ src/main/java/org/apache/maven/archetype/descriptor/TemplateConditionFactory.java	(revision 0)
@@ -0,0 +1,37 @@
+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;
+
+/**
+ * Provides a abstract factory that can be used to get TemplateConditions back
+ *
+ *
+ */
+public class TemplateConditionFactory {
+
+	public static TemplateCondition getCondition(Xpp3Dom templateNode) {
+		if (templateNode.getChild("equalCondition")!=null) {
+			String parameter = templateNode.getChild("equalCondition").getAttribute("parameter");
+			String value = templateNode.getChild("equalCondition").getAttribute("value");
+			return new PropertyEqualCondition(parameter,value);
+		}
+		return null;
+	}
+
+}
Index: src/main/java/org/apache/maven/archetype/descriptor/TemplateDescriptor.java
===================================================================
--- src/main/java/org/apache/maven/archetype/descriptor/TemplateDescriptor.java	(revision 452174)
+++ src/main/java/org/apache/maven/archetype/descriptor/TemplateDescriptor.java	(working copy)
@@ -37,6 +37,12 @@
      * Determines the template's encoding.
      */
     private String encoding;
+    
+    /**
+     * A template condition that can be attached under the resource to determine
+     * whether to include it
+     */
+    private TemplateCondition condition = null;
 
     /**
      * Creates a new instance of <code>TemplateDescriptor<code> that should be filtered
@@ -122,4 +128,12 @@
         this.encoding = encoding;
     }
 
+	public TemplateCondition getCondition() {
+		return condition;
+	}
+
+	public void setCondition(TemplateCondition condition) {
+		this.condition = condition;
+	}    
+
 }