Index: m2-plugins/geronimo-assembly-plugin/pom.xml
===================================================================
--- m2-plugins/geronimo-assembly-plugin/pom.xml	(revision 0)
+++ m2-plugins/geronimo-assembly-plugin/pom.xml	(revision 0)
@@ -0,0 +1,144 @@
+<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.geronimo.plugins</groupId>
+        <artifactId>plugins-parent</artifactId>
+        <version>1.2-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>geronimo-assembly-plugin</artifactId>
+    <packaging>maven-plugin</packaging>
+    <version>${geronimoAssemblyPluginVersion}</version>
+    <name>Geronimo :: Maven2 Assembly Plugin</name>
+    <url>http://geronimo.apache.org</url>
+
+    <issueManagement>
+        <system>jira</system>
+        <url>http://issues.apache.org/jira/secure/BrowseProject.jspa?id=10220</url>
+    </issueManagement>
+
+    <ciManagement>
+        <system>continuum</system>
+        <notifiers>
+            <notifier>
+                <type>mail</type>
+                <sendOnError />
+                <sendOnFailure />
+                <address>dev@geronimo.org</address>
+            </notifier>
+        </notifiers>
+    </ciManagement>
+
+    <mailingLists>
+        <mailingList>
+            <name>Geronimo User List</name>
+            <subscribe>users-subscribe@geronimo.apache.org</subscribe>
+            <unsubscribe>users-unsubscribe@geronimo.apache.org</unsubscribe>
+            <archive>http://mail-archives.apache.org/mod_mbox/geronimo-user/</archive>
+        </mailingList>
+
+        <mailingList>
+            <name>Geronimo Developer List</name>
+            <subscribe>dev-subscribe@geronimo.apache.org</subscribe>
+            <unsubscribe>dev-unsubscribe@geronimo.apache.org</unsubscribe>
+            <archive>http://mail-archives.apache.org/mod_mbox/geronimo-dev/</archive>
+        </mailingList>
+
+        <mailingList>
+            <name>Source Control List</name>
+            <subscribe>scm-subscribe@geronimo.apache.org</subscribe>
+            <unsubscribe>scm-unsubscribe@geronimo.apache.org</unsubscribe>
+            <archive>http://mail-archives.apache.org/mod_mbox/geronimo-scm/</archive>
+        </mailingList>
+    </mailingLists>
+
+    <developers>
+        <developer>
+        </developer>
+    </developers>
+
+    <contributors>
+        <contributor>
+        </contributor>
+    </contributors>
+
+    <licenses>
+        <license>
+            <name>The Apache Software License, Version 2.0</name>
+            <url>http://www.apache.org/licenses/LICENSE-2.0</url>
+            <distribution>repo</distribution>
+        </license>
+    </licenses>
+
+    <scm>
+        <connection>scm:svn:https://svn.apache.org/repos/asf/geronimo/</connection>
+        <developerConnection>scm:svn:https://${maven.username}@svn.apache.org/repos/asf/geronimo/</developerConnection>
+        <url>https://svn.apache.org/repos/asf/geronimo/</url>
+    </scm>
+
+    <organization>
+        <name>Geronimo</name>
+        <url>http://geronimo.apache.org/</url>
+    </organization>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-plugin-api</artifactId>
+            <version>2.0.4</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-project</artifactId>
+            <version>2.0.4</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-artifact</artifactId>
+            <version>2.0.4</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.geronimo.modules</groupId>
+            <artifactId>geronimo-kernel</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.geronimo.modules</groupId>
+            <artifactId>geronimo-system</artifactId>
+        </dependency>
+
+    </dependencies>
+        
+
+    <build>
+        <plugins>
+            <plugin>
+                <artifactId>maven-plugin-plugin</artifactId>
+                <version>2.1</version>
+                <configuration>
+                    <goalPrefix>assembly</goalPrefix>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+    <!--
+    <reporting>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-project-info-reports-plugin</artifactId>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-plugin-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </reporting> -->
+</project>
+

Property changes on: m2-plugins\geronimo-assembly-plugin\pom.xml
___________________________________________________________________
Name: svn:mime-type
   + text/xml
Name: svn:keywords
   + Date Revision
Name: svn:eol-style
   + native

Index: m2-plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/AbstractAssemblyMojo.java
===================================================================
--- m2-plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/AbstractAssemblyMojo.java	(revision 0)
+++ m2-plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/AbstractAssemblyMojo.java	(revision 0)
@@ -0,0 +1,55 @@
+/**
+ *
+ * Copyright 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.
+ */
+ 
+ 
+package org.apache.geronimo.plugin.assembly;
+
+import java.io.PrintStream;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+
+public abstract class AbstractAssemblyMojo extends AbstractMojo {
+
+	protected final String lineSep = "===========================================";
+
+	private PrintStream logStream = System.out;
+
+	private boolean failOnError = true;
+
+	public abstract void execute() throws MojoExecutionException;
+
+	protected void handleError(Exception e) throws MojoExecutionException {
+		// seeLog();
+		e.printStackTrace(logStream);
+		logStream.println(lineSep);
+		if (failOnError) {
+			throw (MojoExecutionException) new MojoExecutionException(e
+					.toString(), e);
+		} else {
+			try {
+				throw (MojoFailureException) new MojoFailureException(e, e
+						.toString(), e.getMessage());
+			} catch (MojoFailureException e1) {
+				e1.printStackTrace(logStream);
+				logStream.println(lineSep);
+			}
+		}
+	}
+
+}

Property changes on: m2-plugins\geronimo-assembly-plugin\src\java\org\apache\geronimo\plugin\assembly\AbstractAssemblyMojo.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Date Revision
Name: svn:eol-style
   + native

Index: m2-plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/ConfigInstallerMojo.java
===================================================================
--- m2-plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/ConfigInstallerMojo.java	(revision 0)
+++ m2-plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/ConfigInstallerMojo.java	(revision 0)
@@ -0,0 +1,253 @@
+/**
+ *
+ * Copyright 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.
+ */
+
+ 
+package org.apache.geronimo.plugin.assembly;
+
+import org.apache.geronimo.kernel.config.InvalidConfigException;
+import org.apache.geronimo.kernel.config.NoSuchConfigException;
+import org.apache.geronimo.kernel.config.ConfigurationData;
+import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.kernel.repository.ArtifactManager;
+import org.apache.geronimo.kernel.repository.ArtifactResolver;
+import org.apache.geronimo.kernel.repository.DefaultArtifactManager;
+import org.apache.geronimo.kernel.repository.Environment;
+import org.apache.geronimo.kernel.repository.FileWriteMonitor;
+import org.apache.geronimo.kernel.repository.MissingDependencyException;
+import org.apache.geronimo.kernel.repository.Dependency;
+import org.apache.geronimo.kernel.repository.WritableListableRepository;
+import org.apache.geronimo.system.repository.Maven2Repository;
+import org.apache.geronimo.system.configuration.RepositoryConfigurationStore;
+import org.apache.geronimo.system.resolver.ExplicitDefaultArtifactResolver;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.plugin.MojoExecutionException;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Iterator;
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.Set;
+import java.util.Collections;
+
+/**
+ * @goal installConfig
+ * 
+ * @version $Rev$ $Date$
+ */
+public class ConfigInstallerMojo extends AbstractAssemblyMojo {
+    public static final FileWriteMonitor LOG_COPY_START = new StartFileWriteMonitor();
+
+    /**
+     * The Maven Project.
+     *
+     * @parameter expression="${project}"
+     * @required
+     * @readonly
+     */
+    protected MavenProject project;
+
+
+    /**
+     * root file of the TargetRepository.
+     * @parameter expression="${project.build.directory}"
+     */
+    private String targetRoot;
+
+
+    /**
+     * location of the target repository relative to targetRoot.
+     * @parameter default-value="archive-tmp/repository"
+     */
+    private String targetRepository;
+
+    /**
+     * configuration to be installed specified as groupId/artifactId/version/type
+     * if none specified, plugin will install all dependencies of type "car"
+     * @parameter
+     * @optional
+     */
+    private String artifact;
+
+    /**
+     * location of the source repository for the dependencies
+     * @parameter expression="${localRepository}"
+     */
+    private ArtifactRepository sourceRepository;
+
+    /**
+     * @parameter expression="${basedir}/../../etc/explicit_versions.properties"
+     */
+    private String explicitResolutionLocation;
+
+    private ArtifactResolver artifactResolver;
+
+    private WritableListableRepository targetRepo;
+    private RepositoryConfigurationStore targetStore;
+
+    private WritableListableRepository sourceRepo;
+    private RepositoryConfigurationStore sourceStore;
+
+    
+
+    public void execute() throws MojoExecutionException {
+        sourceRepo = new Maven2Repository(new File(sourceRepository.getBasedir() ));
+        sourceStore = new RepositoryConfigurationStore(sourceRepo);
+
+        File targetRepoFile = new File(targetRoot, targetRepository);
+        if (  !targetRepoFile.exists() ) {
+            targetRepoFile.mkdirs();
+        }
+        targetRepo = new Maven2Repository(targetRepoFile);
+        targetStore = new RepositoryConfigurationStore(targetRepo);
+
+        Artifact configId;
+        try {
+            ArtifactManager artifactManager = new DefaultArtifactManager();
+            artifactResolver = new ExplicitDefaultArtifactResolver(explicitResolutionLocation,
+                    artifactManager, Collections.singleton(sourceRepo), null);
+
+            if ( artifact != null ) {
+                configId = Artifact.create(artifact);
+                execute(configId);
+            }
+            else {
+                for ( Iterator itr = getDependencies().iterator(); itr.hasNext(); ) {
+                    org.apache.maven.artifact.Artifact  mavenArtifact = (org.apache.maven.artifact.Artifact) itr.next();
+                    if ( "car".equals(mavenArtifact.getType()) ) {
+                        configId = new Artifact(mavenArtifact.getGroupId(), mavenArtifact.getArtifactId(), mavenArtifact.getVersion(), "car");
+                        execute(configId);
+                    }
+                }
+            }
+        }
+        catch (Exception e) {
+            throw new MojoExecutionException("Configuration install failed ", e );
+        }
+    }
+
+    /**
+     * Retrieves all artifact dependencies.
+     *
+     * @return A HashSet of artifacts
+     */
+    protected Set getDependencies()
+    {
+        Set dependenciesSet = new HashSet();
+
+        if ( project.getArtifact() != null && project.getArtifact().getFile() != null )
+        {
+            dependenciesSet.add( project.getArtifact() );
+        }
+
+        Set projectArtifacts = project.getArtifacts();
+        if ( projectArtifacts != null )
+        {
+            dependenciesSet.addAll( projectArtifacts );
+        }
+
+        return dependenciesSet;
+    }
+
+
+
+    private void execute(Artifact configId) throws IOException, InvalidConfigException, MissingDependencyException, NoSuchConfigException {
+
+        LinkedHashSet dependencies;
+
+        // does this configuration exist?
+        if (!sourceRepo.contains(configId)) {
+            throw new NoSuchConfigException(configId);
+        }
+
+        // is this config already installed?
+        if (targetStore.containsConfiguration(configId)) {
+            System.out.println("Configuration " + configId + " already present in configuration store");
+            return;
+        }
+
+        if (sourceStore.containsConfiguration(configId)) {
+            // Copy the configuration into the target configuration store
+            if (!targetStore.containsConfiguration(configId)) {
+                File sourceFile = sourceRepo.getLocation(configId);
+                InputStream in = new FileInputStream(sourceFile);
+                try {
+                    targetStore.install(in, (int)sourceFile.length(), configId, LOG_COPY_START);
+                } finally {
+                    in.close();
+                }
+            }
+
+            // Determine the dependencies of this configuration
+            try {
+                ConfigurationData configurationData = targetStore.loadConfiguration(configId);
+                Environment environment = configurationData.getEnvironment();
+                dependencies = new LinkedHashSet();
+                for (Iterator iterator = environment.getDependencies().iterator(); iterator.hasNext();) {
+                    Dependency dependency = (Dependency) iterator.next();
+                    dependencies.add(dependency.getArtifact());
+                }
+
+                System.out.println("Installed configuration " + configId);
+            } catch (IOException e) {
+                throw new InvalidConfigException("Unable to load configuration: " + configId, e);
+            } catch (NoSuchConfigException e) {
+                throw new InvalidConfigException("Unable to load configuration: " + configId, e);
+            }
+        } else {
+            if (!sourceRepo.contains(configId)) {
+                throw new RuntimeException("Dependency: " + configId + " not found in local maven repo: for configuration: " + artifact);
+            }
+
+            // Copy the artifact into the target repo
+            if (!targetRepo.contains(configId)) {
+                File sourceFile = sourceRepo.getLocation(configId);
+                InputStream in = new FileInputStream(sourceFile);
+                try {
+                    targetRepo.copyToRepository(in, (int)sourceFile.length(), configId, LOG_COPY_START);
+                } finally {
+                    in.close();
+                }
+            }
+
+            // Determine the dependencies of this artifact
+            dependencies = sourceRepo.getDependencies(configId);
+        }
+        dependencies = artifactResolver.resolveInClassLoader(dependencies);
+        for (Iterator iterator = dependencies.iterator(); iterator.hasNext();) {
+            Artifact artifact = (Artifact) iterator.next();
+            execute(artifact);
+        }
+    }
+
+    private static class StartFileWriteMonitor implements FileWriteMonitor {
+        public void writeStarted(String fileDescription, int fileSize) {
+            System.out.println("Copying " + fileDescription);
+        }
+
+        public void writeProgress(int bytes) {
+
+        }
+
+        public void writeComplete(int bytes) {
+
+        }
+    }
+}

Property changes on: m2-plugins\geronimo-assembly-plugin\src\java\org\apache\geronimo\plugin\assembly\ConfigInstallerMojo.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Date Revision
Name: svn:eol-style
   + native

