geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r428888 [7/11] - in /geronimo/trunk: ./ applications/ applications/console/ applications/console/console-core/ applications/console/console-ear/ applications/console/console-framework/ applications/console/console-framework/src/ application...
Date Fri, 04 Aug 2006 21:22:06 GMT
Added: geronimo/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/InstallConfigMojo.java
URL: http://svn.apache.org/viewvc/geronimo/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/InstallConfigMojo.java?rev=428888&view=auto
==============================================================================
--- geronimo/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/InstallConfigMojo.java (added)
+++ geronimo/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/InstallConfigMojo.java Fri Aug  4 14:21:54 2006
@@ -0,0 +1,261 @@
+/*
+ *  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.car;
+
+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.geronimo.plugin.MojoSupport;
+
+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;
+
+/**
+ * Installs CAR files into a target repository to support assembly.
+ *
+ * @goal installConfig
+ * 
+ * @version $Rev$ $Date$
+ */
+public class InstallConfigMojo
+    extends AbstractCarMojo
+{
+    public static final FileWriteMonitor LOG_COPY_START = new StartFileWriteMonitor();
+
+    /**
+     * Root file of the TargetRepository.
+     *
+     * @parameter expression="${project.build.directory}"
+     */
+    private String targetRoot;
+
+    /**
+     * The location of the target repository relative to targetRoot.
+     * 
+     * @parameter default-value="archive-tmp/repository"
+     * @required
+     */
+    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}"
+     * @required
+     */
+    private ArtifactRepository sourceRepository;
+    
+    /**
+     * The location where the properties mapping will be generated.
+     *
+     * @parameter expression="${project.build.directory}/explicit-versions.properties"
+     * @required
+     */
+    private File explicitResolutionProperties;
+
+    private ArtifactResolver artifactResolver;
+
+    private WritableListableRepository targetRepo;
+    private RepositoryConfigurationStore targetStore;
+
+    private WritableListableRepository sourceRepo;
+    private RepositoryConfigurationStore sourceStore;
+
+    protected void doExecute() throws Exception {
+        generateExplicitVersionProperties(explicitResolutionProperties);
+        
+        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;
+        ArtifactManager artifactManager = new DefaultArtifactManager();
+        artifactResolver = new ExplicitDefaultArtifactResolver(
+            explicitResolutionProperties.getPath(),
+            artifactManager,
+            Collections.singleton(sourceRepo),
+            null);
+
+        if ( artifact != null ) {
+            configId = Artifact.create(artifact);
+            execute(configId);
+        }
+        else {
+            Iterator itr = getDependencies().iterator();
+            while (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);
+                }
+            }
+        }
+    }
+
+    /**
+     * 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 Exception {
+        LinkedHashSet dependencies;
+
+        // does this configuration exist?
+        if (!sourceRepo.contains(configId)) {
+            throw new NoSuchConfigException(configId);
+        }
+
+        // is this config already installed?
+        if (targetStore.containsConfiguration(configId)) {
+            log.info("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());
+                }
+
+                log.info("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) {
+            //
+            // FIXME: Using logging?
+            //
+            
+            System.out.println("Copying " + fileDescription);
+        }
+
+        public void writeProgress(int bytes) {
+            // ???
+        }
+
+        public void writeComplete(int bytes) {
+            // ???
+        }
+    }
+}

Propchange: geronimo/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/InstallConfigMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/InstallConfigMojo.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/InstallConfigMojo.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/InstallMojo.java
URL: http://svn.apache.org/viewvc/geronimo/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/InstallMojo.java?rev=428888&view=auto
==============================================================================
--- geronimo/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/InstallMojo.java (added)
+++ geronimo/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/InstallMojo.java Fri Aug  4 14:21:54 2006
@@ -0,0 +1,114 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.plugin.car;
+
+import java.io.File;
+import java.util.Iterator;
+
+import org.apache.geronimo.kernel.config.ConfigurationData;
+import org.apache.geronimo.kernel.config.ConfigurationStore;
+import org.apache.geronimo.kernel.config.ConfigurationInfo;
+import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.kernel.repository.WritableListableRepository;
+
+/**
+ * Copies all the configurations out of source config store into target config store.
+ *
+ * @goal install
+ *
+ * @version $Rev$ $Date$
+ */
+public class InstallMojo extends AbstractCarMojo {
+
+    private static final Class[] REPO_ARGS = { File.class };
+
+    private static final Class[] STORE_ARGS = { WritableListableRepository.class };
+
+    /**
+     * @parameter default-value="org.apache.geronimo.system.repository.Maven2Repository"
+     * @required
+     */
+    private String sourceRepositoryClass;
+
+    /**
+     * @parameter default-value="org.apache.geronimo.system.repository.Maven2Repository"
+     * @required
+     */
+    private String targetRepositoryClass;
+
+    /**
+     * @parameter default-value="org.apache.geronimo.system.configuration.RepositoryConfigurationStore"
+     * @required
+     */
+    private String sourceConfigurationStoreClass;
+
+    /**
+     * @parameter default-value="org.apache.geronimo.plugin.car.MavenConfigStore"
+     * @required
+     */
+    private String targetConfigurationStoreClass;
+
+    /**
+     * @parameter expression="${project.build.directory}/repository"
+     * @required
+     */
+    private File sourceRepositoryLocation;
+
+    /**
+     * @parameter expression="${settings.LocalRepository}"
+     * @required
+     */
+    private File targetRepositoryLocation;
+
+    protected void doExecute() throws Exception {
+        // copy artifact(s) to maven repository
+
+        ClassLoader cl = this.getClass().getClassLoader();
+
+        Class sourceRepoClass = cl.loadClass(sourceRepositoryClass);
+        WritableListableRepository sourceRepository = (WritableListableRepository)
+                sourceRepoClass.getDeclaredConstructor(REPO_ARGS).newInstance(new Object[]{ sourceRepositoryLocation });
+
+        Class sourceConfigStoreClass = cl.loadClass(sourceConfigurationStoreClass);
+        ConfigurationStore sourceConfigStore = (ConfigurationStore)
+                sourceConfigStoreClass.getDeclaredConstructor(STORE_ARGS).newInstance(new Object[]{ sourceRepository });
+
+        Class targetRepoClass = cl.loadClass(targetRepositoryClass);
+        WritableListableRepository targetRepository = (WritableListableRepository)
+                targetRepoClass.getDeclaredConstructor(REPO_ARGS).newInstance(new Object[]{ targetRepositoryLocation });
+        Class targetConfigStoreClass = cl.loadClass(targetConfigurationStoreClass);
+
+        ConfigurationStore targetConfigStore = (ConfigurationStore)
+                targetConfigStoreClass.getDeclaredConstructor(STORE_ARGS).newInstance(new Object[]{ targetRepository });
+
+        Iterator iterator = sourceConfigStore.listConfigurations().iterator();
+        while (iterator.hasNext()) {
+            ConfigurationInfo configInfo = (ConfigurationInfo) iterator.next();
+            Artifact configId = configInfo.getConfigID();
+            ConfigurationData configData = sourceConfigStore.loadConfiguration(configId);
+
+            log.info("Copying artifact: " + configId);
+
+            if (targetConfigStore.containsConfiguration(configId)) {
+                targetConfigStore.uninstall(configId);
+            }
+
+            targetConfigStore.install(configData);
+        }
+    }
+}

Propchange: geronimo/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/InstallMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/InstallMojo.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/InstallMojo.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/MavenAttributeStore.java
URL: http://svn.apache.org/viewvc/geronimo/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/MavenAttributeStore.java?rev=428888&view=auto
==============================================================================
--- geronimo/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/MavenAttributeStore.java (added)
+++ geronimo/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/MavenAttributeStore.java Fri Aug  4 14:21:54 2006
@@ -0,0 +1,72 @@
+/**
+ *
+ * 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.car;
+
+import org.apache.geronimo.gbean.GAttributeInfo;
+import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.gbean.GReferenceInfo;
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.ReferencePatterns;
+import org.apache.geronimo.kernel.config.ManageableAttributeStore;
+import org.apache.geronimo.kernel.repository.Artifact;
+
+import java.io.IOException;
+import java.util.Collection;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class MavenAttributeStore
+    implements ManageableAttributeStore
+{
+    public MavenAttributeStore() {
+    }
+
+    public Collection applyOverrides(Artifact configurationName, Collection datas, ClassLoader classLoader) {
+        return datas;
+    }
+
+    public void setValue(Artifact configurationName, AbstractName gbean, GAttributeInfo attribute, Object value) {
+    }
+
+    public void setReferencePatterns(Artifact configurationName, AbstractName gbean, GReferenceInfo reference, ReferencePatterns patterns) {
+    }
+
+    public void setShouldLoad(Artifact configurationName, AbstractName gbean, boolean load) {
+    }
+
+    public void addGBean(Artifact configurationName, GBeanData gbeanData) {
+    }
+
+    public void save() throws IOException {
+    }
+
+    public static final GBeanInfo GBEAN_INFO;
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+
+    static {
+        GBeanInfoBuilder builder = GBeanInfoBuilder.createStatic(MavenAttributeStore.class);
+        builder.addInterface(ManageableAttributeStore.class);
+        GBEAN_INFO = builder.getBeanInfo();
+    }
+}

Propchange: geronimo/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/MavenAttributeStore.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/MavenAttributeStore.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/MavenAttributeStore.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/MavenConfigStore.java
URL: http://svn.apache.org/viewvc/geronimo/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/MavenConfigStore.java?rev=428888&view=auto
==============================================================================
--- geronimo/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/MavenConfigStore.java (added)
+++ geronimo/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/MavenConfigStore.java Fri Aug  4 14:21:54 2006
@@ -0,0 +1,105 @@
+/**
+ *
+ * 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.car;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.kernel.config.ConfigurationData;
+import org.apache.geronimo.kernel.config.InvalidConfigException;
+import org.apache.geronimo.kernel.config.NoSuchConfigException;
+import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.kernel.repository.WritableListableRepository;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.system.configuration.ExecutableConfigurationUtil;
+import org.apache.geronimo.system.configuration.RepositoryConfigurationStore;
+
+/**
+ * Implementation of ConfigurationStore that loads Configurations from a repository.
+ * This implementation is read-only on the assumption that a separate maven task will
+ * handle installation of a built package into the repository.
+ *
+ * @version $Rev$ $Date$
+ */
+public class MavenConfigStore
+    extends RepositoryConfigurationStore
+{
+    public MavenConfigStore(Kernel kernel, String objectName, WritableListableRepository repository) {
+        super(kernel, objectName, repository);
+    }
+
+    public MavenConfigStore(WritableListableRepository repository) {
+        super(repository);
+    }
+
+    public File createNewConfigurationDir(Artifact configId) {
+        try {
+            File tmpFile = File.createTempFile("package", ".tmpdir");
+            tmpFile.delete();
+            tmpFile.mkdir();
+            if (!tmpFile.isDirectory()) {
+                return null;
+            }
+            // create the meta-inf dir
+            File metaInf = new File(tmpFile, "META-INF");
+            metaInf.mkdirs();
+            return tmpFile;
+        }
+        catch (IOException e) {
+            // doh why can't I throw this?
+            return null;
+        }
+    }
+
+    public void install(ConfigurationData configurationData) throws IOException, InvalidConfigException {
+        File source = configurationData.getConfigurationDir();
+        if (!source.isDirectory()) {
+            throw new InvalidConfigException("Source must be a directory: source=" + source);
+        }
+        Artifact configId = configurationData.getId();
+        File targetFile = repository.getLocation(configId);
+        ExecutableConfigurationUtil.createExecutableConfiguration(configurationData, null, targetFile);
+    }
+
+    public void uninstall(Artifact configID) throws NoSuchConfigException, IOException {
+        File targetFile = repository.getLocation(configID);
+        targetFile.delete();
+    }
+
+    public List listConfigurations() {
+        throw new UnsupportedOperationException();
+    }
+
+    public static final GBeanInfo GBEAN_INFO;
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+
+    static {
+        GBeanInfoBuilder builder = GBeanInfoBuilder.createStatic(MavenConfigStore.class, "ConfigurationStore");
+        builder.addAttribute("kernel", Kernel.class, false);
+        builder.addAttribute("objectName", String.class, false);
+        builder.addReference("Repository", WritableListableRepository.class, "Repository");
+        builder.setConstructor(new String[]{"kernel", "objectName", "Repository"});
+        GBEAN_INFO = builder.getBeanInfo();
+    }
+}

Propchange: geronimo/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/MavenConfigStore.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/MavenConfigStore.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/MavenConfigStore.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/PackageBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/PackageBuilder.java?rev=428888&view=auto
==============================================================================
--- geronimo/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/PackageBuilder.java (added)
+++ geronimo/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/PackageBuilder.java Fri Aug  4 14:21:54 2006
@@ -0,0 +1,512 @@
+/**
+ *
+ * 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.car;
+
+import java.io.File;
+import java.net.URI;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.AbstractNameQuery;
+import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.ReferencePatterns;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.KernelFactory;
+import org.apache.geronimo.kernel.KernelRegistry;
+import org.apache.geronimo.kernel.Naming;
+import org.apache.geronimo.kernel.config.ConfigurationData;
+import org.apache.geronimo.kernel.config.ConfigurationManager;
+import org.apache.geronimo.kernel.config.ConfigurationUtil;
+import org.apache.geronimo.kernel.config.KernelConfigurationManager;
+import org.apache.geronimo.kernel.log.GeronimoLogging;
+import org.apache.geronimo.kernel.management.State;
+import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.kernel.repository.DefaultArtifactManager;
+import org.apache.geronimo.system.resolver.ExplicitDefaultArtifactResolver;
+import org.apache.geronimo.plugin.car.MavenAttributeStore;
+
+/**
+ * Builds a Geronimo Configuration using the local Maven infrastructure.
+ *
+ * @version $Rev:385659 $ $Date$
+ */
+public class PackageBuilder
+{
+    private static Log log = LogFactory.getLog(PackageBuilder.class);
+
+    private static final String KERNEL_NAME = "geronimo.maven";
+
+    private static final String[] ARG_TYPES = {
+        boolean.class.getName(),
+        File.class.getName(),
+        File.class.getName(),
+        File.class.getName(),
+        Boolean.TYPE.getName(),
+        String.class.getName(),
+        String.class.getName(),
+        String.class.getName(),
+        String.class.getName(),
+        String.class.getName(),
+        String.class.getName(),
+        String.class.getName(),
+        String.class.getName(),
+    };
+
+    /**
+     * Reference to the kernel that will last the lifetime of this classloader.
+     * The KernelRegistry keeps soft references that may be garbage collected.
+     */
+    private static Kernel kernel;
+
+    private static AbstractName targetConfigStoreAName;
+
+    private static AbstractName targetRepositoryAName;
+
+    private String repositoryClass;
+
+    private String configurationStoreClass;
+
+    private String targetRepositoryClass;
+
+    private String targetConfigurationStoreClass;
+
+    private File repository;
+
+    private File targetRepository;
+
+    private Collection deploymentConfigs;
+
+    private AbstractName deployerName;
+
+    private File planFile;
+
+    private File moduleFile;
+
+    private File packageFile;
+
+    private String mainClass;
+
+    private String mainGBean;
+
+    private String mainMethod;
+
+    private String configurations;
+
+    private String classPath;
+
+    private String endorsedDirs;
+
+    private String extensionDirs;
+
+    private String explicitResolutionLocation;
+
+    private String logLevel;
+
+    private boolean targetSet;
+
+    private boolean singleArtifact = true;
+
+    public String getRepositoryClass() {
+        return repositoryClass;
+    }
+
+    public void setRepositoryClass(final String repositoryClass) {
+        this.repositoryClass = repositoryClass;
+    }
+
+    public String getConfigurationStoreClass() {
+        return configurationStoreClass;
+    }
+
+    public void setConfigurationStoreClass(final String configurationStoreClass) {
+        this.configurationStoreClass = configurationStoreClass;
+    }
+
+    public File getRepository() {
+        return repository;
+    }
+
+    public void setRepository(final File repository) {
+        this.repository = repository;
+    }
+
+    public String getTargetRepositoryClass() {
+        return targetRepositoryClass;
+    }
+
+    public void setTargetRepositoryClass(final String targetRepositoryClass) {
+        this.targetRepositoryClass = targetRepositoryClass;
+    }
+
+    public String getTargetConfigurationStoreClass() {
+        return targetConfigurationStoreClass;
+    }
+
+    public void setTargetConfigurationStoreClass(final String targetConfigurationStoreClass) {
+        this.targetConfigurationStoreClass = targetConfigurationStoreClass;
+    }
+
+    public File getTargetRepository() {
+        return targetRepository;
+    }
+
+    public void setTargetRepository(final File targetRepository) {
+        this.targetRepository = targetRepository;
+    }
+
+    public Collection getDeploymentConfig() {
+        return deploymentConfigs;
+    }
+
+    /**
+     * Set the id of the Configuration to use to perform the packaging.
+     *
+     * @param deploymentConfigString comma-separated list of the ids of the Configurations performing the deployment
+     */
+    public void setDeploymentConfig(final Collection deploymentConfigString) {
+        this.deploymentConfigs = deploymentConfigString;
+    }
+
+    public String getDeployerName() {
+        return deployerName.toString();
+    }
+
+    /**
+     * Set the name of the GBean that is the Deployer.
+     *
+     * @param deployerName the name of the Deployer GBean
+     */
+    public void setDeployerName(final String deployerName) {
+        this.deployerName = new AbstractName(URI.create(deployerName));
+    }
+
+    public File getPlanFile() {
+        return planFile;
+    }
+
+    /**
+     * Set the File that is the deployment plan.
+     *
+     * @param planFile the deployment plan
+     */
+    public void setPlanFile(final File planFile) {
+        this.planFile = planFile;
+    }
+
+    public File getModuleFile() {
+        return moduleFile;
+    }
+
+    /**
+     * Set the File that is the module being deployed.
+     *
+     * @param moduleFile the module to deploy
+     */
+    public void setModuleFile(final File moduleFile) {
+        this.moduleFile = moduleFile;
+    }
+
+    public File getPackageFile() {
+        return packageFile;
+    }
+
+    /**
+     * Set the File where the Configuration will be stored; normally the artifact being produced.
+     *
+     * @param packageFile the package file to produce
+     */
+    public void setPackageFile(final File packageFile) {
+        this.packageFile = packageFile;
+    }
+
+    public String getMainClass() {
+        return mainClass;
+    }
+
+    /**
+     * Set the name of the class containing the main method for a executable configuration.
+     *
+     * @param mainClass
+     */
+    public void setMainClass(final String mainClass) {
+        this.mainClass = mainClass;
+    }
+
+    public String getMainGBean() {
+        return mainGBean;
+    }
+
+    public void setMainGBean(final String mainGBean) {
+        this.mainGBean = mainGBean;
+    }
+
+    public String getMainMethod() {
+        return mainMethod;
+    }
+
+    public void setMainMethod(final String mainMethod) {
+        this.mainMethod = mainMethod;
+    }
+
+    public String getConfigurations() {
+        return configurations;
+    }
+
+    public void setConfigurations(final String configurations) {
+        this.configurations = configurations;
+    }
+
+    public String getClassPath() {
+        return classPath;
+    }
+
+    public void setClassPath(final String classPath) {
+        this.classPath = classPath;
+    }
+
+    public String getEndorsedDirs() {
+        return endorsedDirs;
+    }
+
+    public void setEndorsedDirs(final String endorsedDirs) {
+        this.endorsedDirs = endorsedDirs;
+    }
+
+    public String getExtensionDirs() {
+        return extensionDirs;
+    }
+
+    public void setExtensionDirs(final String extensionDirs) {
+        this.extensionDirs = extensionDirs;
+    }
+
+    public String getExplicitResolutionLocation() {
+        return explicitResolutionLocation;
+    }
+
+    public void setExplicitResolutionLocation(final String explicitResolutionLocation) {
+        this.explicitResolutionLocation = explicitResolutionLocation;
+    }
+
+    public String getLogLevel() {
+        return logLevel;
+    }
+
+    public void setLogLevel(String logLevel) {
+        this.logLevel = logLevel;
+    }
+
+    public void execute() throws Exception {
+        System.out.println("Packaging configuration " + planFile);
+
+        try {
+            Kernel kernel = createKernel();
+            if (!targetSet) {
+                setTargetConfigStore();
+            }
+
+            // start the Configuration we're going to use for this deployment
+            ConfigurationManager configurationManager = ConfigurationUtil.getConfigurationManager(kernel);
+            try {
+                for (Iterator iterator = deploymentConfigs.iterator(); iterator.hasNext();) {
+                    String artifactName = (String) iterator.next();
+                    Artifact configName = Artifact.create(artifactName);
+                    if (!configurationManager.isLoaded(configName)) {
+                        configurationManager.loadConfiguration(configName);
+                        configurationManager.startConfiguration(configName);
+                    }
+                }
+            } finally {
+                ConfigurationUtil.releaseConfigurationManager(kernel, configurationManager);
+            }
+
+            AbstractName deployer = locateDeployer(kernel);
+            invokeDeployer(kernel, deployer, targetConfigStoreAName.toString());
+
+            System.out.println("Generated package " + packageFile);
+        }
+        catch (Exception e) {
+            log.error(e.getClass().getName() + ": " + e.getMessage(), e);
+            throw e;
+        }
+    }
+
+    private void setTargetConfigStore() throws Exception {
+        try {
+            kernel.stopGBean(targetRepositoryAName);
+            kernel.setAttribute(targetRepositoryAName, "root", targetRepository.toURI());
+            kernel.startGBean(targetRepositoryAName);
+            if (kernel.getGBeanState(targetConfigStoreAName) != State.RUNNING_INDEX) {
+                throw new IllegalStateException("After restarted repository then config store is not running");
+            }
+            targetSet = true;
+        }
+        catch (Exception e) {
+            log.error(e.toString(), e);
+            throw e;
+        }
+    }
+
+    /**
+     * Create a Geronimo Kernel to contain the deployment configurations.
+     */
+    private synchronized Kernel createKernel() throws Exception {
+        // first return our cached version
+        if (kernel != null) {
+            return kernel;
+        }
+
+        // check the registry in case someone else created one
+        kernel = KernelRegistry.getKernel(KERNEL_NAME);
+        if (kernel != null) {
+            return kernel;
+        }
+
+        GeronimoLogging geronimoLogging = GeronimoLogging.getGeronimoLogging(logLevel);
+        if (geronimoLogging == null) {
+            geronimoLogging = GeronimoLogging.DEBUG;
+        }
+        GeronimoLogging.initialize(geronimoLogging);
+
+        // boot one ourselves
+        kernel = KernelFactory.newInstance().createKernel(KERNEL_NAME);
+        kernel.boot();
+
+        bootDeployerSystem();
+
+        return kernel;
+    }
+
+    /**
+     * Boot the in-Maven deployment system.
+     *
+     * This contains Repository and ConfigurationStore GBeans that map to
+     * the local maven installation.
+     */
+    private void bootDeployerSystem() throws Exception {
+        Artifact baseId = new Artifact("geronimo", "packaging", "fixed", "car");
+        Naming naming = kernel.getNaming();
+        ConfigurationData bootstrap = new ConfigurationData(baseId, naming);
+        ClassLoader cl = PackageBuilder.class.getClassLoader();
+        Set repoNames = new HashSet();
+
+        // Source repo
+        GBeanData repoGBean = bootstrap.addGBean("SourceRepository", GBeanInfo.getGBeanInfo(repositoryClass, cl));
+        URI repositoryURI = repository.toURI();
+        repoGBean.setAttribute("root", repositoryURI);
+        repoNames.add(repoGBean.getAbstractName());
+
+        // Target repo
+        GBeanData targetRepoGBean = bootstrap.addGBean("TargetRepository", GBeanInfo.getGBeanInfo(targetRepositoryClass, cl));
+        URI targetRepositoryURI = targetRepository.toURI();
+        targetRepoGBean.setAttribute("root", targetRepositoryURI);
+        repoNames.add(targetRepoGBean.getAbstractName());
+        targetRepositoryAName = targetRepoGBean.getAbstractName();
+
+        GBeanData artifactManagerGBean = bootstrap.addGBean("ArtifactManager", DefaultArtifactManager.GBEAN_INFO);
+
+        GBeanData artifactResolverGBean = bootstrap.addGBean("ArtifactResolver", ExplicitDefaultArtifactResolver.GBEAN_INFO);
+        artifactResolverGBean.setAttribute("versionMapLocation", explicitResolutionLocation);
+        ReferencePatterns repoPatterns = new ReferencePatterns(repoNames);
+        artifactResolverGBean.setReferencePatterns("Repositories", repoPatterns);
+        artifactResolverGBean.setReferencePattern("ArtifactManager", artifactManagerGBean.getAbstractName());
+
+        Set storeNames = new HashSet();
+
+        // Source config store
+        GBeanInfo configStoreInfo = GBeanInfo.getGBeanInfo(configurationStoreClass, cl);
+        GBeanData storeGBean = bootstrap.addGBean("ConfigStore", configStoreInfo);
+        if (configStoreInfo.getReference("Repository") != null) {
+            storeGBean.setReferencePattern("Repository", repoGBean.getAbstractName());
+        }
+        storeNames.add(storeGBean.getAbstractName());
+
+        // Target config store
+        GBeanInfo targetConfigStoreInfo = GBeanInfo.getGBeanInfo(targetConfigurationStoreClass, cl);
+        GBeanData targetStoreGBean = bootstrap.addGBean("TargetConfigStore", targetConfigStoreInfo);
+        if (targetConfigStoreInfo.getReference("Repository") != null) {
+            targetStoreGBean.setReferencePattern("Repository", targetRepoGBean.getAbstractName());
+        }
+        storeNames.add(targetStoreGBean.getAbstractName());
+
+        targetConfigStoreAName = targetStoreGBean.getAbstractName();
+        targetSet = true;
+
+        GBeanData attrManagerGBean = bootstrap.addGBean("AttributeStore", MavenAttributeStore.GBEAN_INFO);
+
+        GBeanData configManagerGBean = bootstrap.addGBean("ConfigManager", KernelConfigurationManager.GBEAN_INFO);
+        configManagerGBean.setReferencePatterns("Stores", new ReferencePatterns(storeNames));
+        configManagerGBean.setReferencePattern("AttributeStore", attrManagerGBean.getAbstractName());
+        configManagerGBean.setReferencePattern("ArtifactManager", artifactManagerGBean.getAbstractName());
+        configManagerGBean.setReferencePattern("ArtifactResolver", artifactResolverGBean.getAbstractName());
+        configManagerGBean.setReferencePatterns("Repositories", repoPatterns);
+
+        ConfigurationUtil.loadBootstrapConfiguration(kernel, bootstrap, cl);
+    }
+
+    /**
+     * Locate a Deployer GBean matching the deployerName pattern.
+     *
+     * @param kernel the kernel to search.
+     * @return the ObjectName of the Deployer GBean
+     *
+     * @throws IllegalStateException if there is not exactly one GBean matching the deployerName pattern
+     */
+    private AbstractName locateDeployer(Kernel kernel) {
+        Iterator i = kernel.listGBeans(new AbstractNameQuery(deployerName)).iterator();
+        if (!i.hasNext()) {
+            throw new IllegalStateException("No deployer found matching deployerName: " + deployerName);
+        }
+
+        AbstractName deployer = (AbstractName) i.next();
+        if (i.hasNext()) {
+            throw new IllegalStateException("Multiple deployers found matching deployerName: " + deployerName);
+        }
+
+        return deployer;
+    }
+
+    private List invokeDeployer(Kernel kernel, AbstractName deployer, String targetConfigStore) throws Exception {
+        boolean isExecutable = mainClass != null;
+
+        Object[] args = {
+            Boolean.FALSE,
+            planFile,
+            moduleFile,
+            singleArtifact ? packageFile : null,
+            Boolean.valueOf(!isExecutable),
+            mainClass,
+            mainGBean,
+            mainMethod,
+            configurations,
+            classPath,
+            endorsedDirs,
+            extensionDirs,
+            targetConfigStore
+        };
+
+        return (List) kernel.invoke(deployer, "deploy", args, ARG_TYPES);
+    }
+}

Propchange: geronimo/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/PackageBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/PackageBuilder.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/PackageBuilder.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/PackageMojo.java
URL: http://svn.apache.org/viewvc/geronimo/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/PackageMojo.java?rev=428888&view=auto
==============================================================================
--- geronimo/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/PackageMojo.java (added)
+++ geronimo/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/PackageMojo.java Fri Aug  4 14:21:54 2006
@@ -0,0 +1,255 @@
+/**
+ *
+ * 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.car;
+
+import java.io.File;
+import java.io.BufferedOutputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Iterator;
+import java.util.Properties;
+
+import org.apache.geronimo.deployment.PluginBootstrap2;
+import org.apache.geronimo.system.configuration.RepositoryConfigurationStore;
+import org.apache.geronimo.system.repository.Maven2Repository;
+import org.apache.maven.artifact.Artifact;
+
+import org.codehaus.plexus.util.FileUtils;
+
+/**
+ * Build a Geronimo Configuration using the local Maven infrastructure.
+ *
+ * <p>
+ * <b>NOTE:</b> Calling pom.xml must have defined a ${geronimoVersion} property.
+ * </p>
+ *
+ * @goal package
+ * @requiresDependencyResolution runtime
+ *
+ * @version $Rev$ $Date$
+ */
+public class PackageMojo
+    extends AbstractCarMojo
+{
+    private List artifacts;
+
+    /**
+     * @parameter expression="${settings.localRepository}"
+     * @required
+     * @readonly
+     */
+    private File repository;
+
+    /**
+     * @parameter expression="${project.build.directory}/repository"
+     * @required
+     */
+    private File targetRepository;
+
+    /**
+     * @parameter expression="org.apache.geronimo.configs/geronimo-gbean-deployer/${geronimoVersion}/car"
+     * @required
+     * @readonly
+     */
+    private String deafultDeploymentConfig;
+
+    /**
+     * @parameter
+     */
+    private ArrayList deploymentConfigs;
+
+    /**
+     * @parameter expression="org.apache.geronimo.configs/geronimo-gbean-deployer/${geronimoVersion}/car?j2eeType=Deployer,name=Deployer"
+     * @required
+     */
+    private String deployerName;
+
+    /**
+     * @parameter expression="${project.build.directory}/plan/plan.xml"
+     * @required
+     */
+    private File planFile;
+
+    /**
+     * @parameter
+     */
+    private File moduleFile;
+
+    /**
+     * @parameter expression="${project.build.directory}/${project.artifactId}-${project.version}.car"
+     * @required
+     */
+    private File packageFile;
+
+    /**
+     * @parameter expression="${project.build.directory}"
+     * @required
+     */
+    private File buildDir;
+
+    /**
+     * @parameter
+     */
+    private String mainClass;
+
+    /**
+     * @parameter
+     */
+    private String mainMethod;
+
+    /**
+     * @parameter
+     */
+    private String mainGBean;
+
+    /**
+     * @parameter
+     */
+    private String configurations;
+
+    /**
+     * The classpath to be added to the generated manifest.
+     *
+     * @parameter
+     */
+    private ArrayList classPath;
+
+    /**
+     * @parameter default-value="lib/endorsed"
+     * @required
+     */
+    private String endorsedDirs;
+
+    /**
+     * @parameter default-value="lib/ext"
+     * @required
+     */
+    private String extensionDirs;
+
+    /**
+     * The location where the properties mapping will be generated.
+     *
+     * @parameter expression="${project.build.directory}/explicit-versions.properties"
+     */
+    private File explicitResolutionProperties;
+
+    /**
+     * @parameter default-value="WARN"
+     * @required
+     */
+    private String logLevel;
+
+    /**
+     * @parameter
+     */
+    private boolean boot = false;
+
+    protected void doExecute() throws Exception {
+        // We need to make sure to clean up any previous work first or this operation will fail
+        FileUtils.forceDelete(targetRepository);
+        FileUtils.forceMkdir(targetRepository);
+
+        // Use the default configs if none specified
+        if (deploymentConfigs == null) {
+            deploymentConfigs = new ArrayList();
+            deploymentConfigs.add(deafultDeploymentConfig);
+        }
+        log.debug("Deployment configs: " + deploymentConfigs);
+
+        generateExplicitVersionProperties(explicitResolutionProperties);
+
+        if (boot) {
+            executeBootShell();
+        }
+        else {
+            executePackageBuilderShell();
+        }
+
+        // copy configuration from target/repository to maven repo
+        project.getArtifact().setFile(packageFile);
+    }
+
+    public void executeBootShell() throws Exception {
+        PluginBootstrap2 boot = new PluginBootstrap2();
+
+        boot.setBuildDir(buildDir);
+        boot.setCarFile(packageFile);
+        boot.setLocalRepo(repository);
+        boot.setPlan(planFile);
+
+        boot.bootstrap();
+    }
+
+    private String getClassPath() {
+        if (classPath == null) {
+            return null;
+        }
+
+        log.debug("Creating classpath from: " + classPath);
+
+        StringBuffer buff = new StringBuffer();
+        Iterator iter = classPath.iterator();
+        while (iter.hasNext()) {
+            String element = (String)iter.next();
+            buff.append(element.trim());
+
+            if (iter.hasNext()) {
+                buff.append(" ");
+            }
+        }
+        
+        log.debug("Using classpath: " + buff);
+
+        return buff.toString();
+    }
+
+    public void executePackageBuilderShell() throws Exception {
+        PackageBuilder builder = new PackageBuilder();
+
+        //
+        // NOTE: May need to run this in a controlled classloader (w/reflection or a proxy)
+        //
+        //       http://www.nabble.com/PackageBuilderShellMojo-%28m2%29-and-classloaders-p5271991.html
+        //
+
+        builder.setClassPath(getClassPath());
+        builder.setDeployerName(deployerName);
+        builder.setDeploymentConfig(deploymentConfigs);
+        builder.setEndorsedDirs(endorsedDirs);
+        builder.setExtensionDirs(extensionDirs);
+        builder.setMainClass(mainClass);
+        builder.setMainMethod(mainMethod);
+        builder.setMainGBean(mainGBean);
+        builder.setConfigurations(configurations);
+        builder.setModuleFile(moduleFile);
+        builder.setPackageFile(packageFile);
+        builder.setPlanFile(planFile);
+        builder.setRepository(repository);
+        builder.setRepositoryClass(Maven2Repository.class.getName());
+        builder.setConfigurationStoreClass(MavenConfigStore.class.getName());
+        builder.setTargetRepository(targetRepository);
+        builder.setTargetRepositoryClass(Maven2Repository.class.getName());
+        builder.setTargetConfigurationStoreClass(RepositoryConfigurationStore.class.getName());
+        builder.setExplicitResolutionLocation(explicitResolutionProperties.getAbsolutePath());
+        builder.setLogLevel(logLevel);
+
+        builder.execute();
+    }
+}

Propchange: geronimo/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/PackageMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/PackageMojo.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/PackageMojo.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/PackagingCommandLine.java
URL: http://svn.apache.org/viewvc/geronimo/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/PackagingCommandLine.java?rev=428888&view=auto
==============================================================================
--- geronimo/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/PackagingCommandLine.java (added)
+++ geronimo/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/PackagingCommandLine.java Fri Aug  4 14:21:54 2006
@@ -0,0 +1,97 @@
+/**
+ *
+ * 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.car;
+
+import org.apache.geronimo.plugin.car.PackageBuilder;
+
+import java.io.File;
+import java.io.InputStream;
+import java.io.FileInputStream;
+import java.util.Properties;
+import java.util.Arrays;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class PackagingCommandLine {
+
+    public static void Main(String[] args) throws Exception {
+        File configFile = new File("packaging.properties");
+        Properties config = new Properties();
+        InputStream in = new FileInputStream(configFile);
+        try {
+            config.load(in);
+        } finally {
+            in.close();
+        }
+        mergeArgs(config, args);
+
+        new PackagingCommandLine(config).execute();
+    }
+
+    private static void mergeArgs(Properties config, String[] args) throws Exception {
+        if (args.length % 2 != 0) {
+            throw new Exception("There must be an even number of args, --<name> followed by value");
+        }
+
+        for (int i = 0; i < args.length; i++) {
+            String key = args[i++];
+            String value = args[i];
+
+            if (!key.startsWith("--")) {
+                throw new Exception("Keys must be preceded by '--'");
+            }
+
+            key = key.substring(2);
+            config.put(key, value);
+        }
+    }
+
+    private final Properties config;
+
+    public PackagingCommandLine(Properties config) {
+        this.config = config;
+    }
+
+    public void execute() throws Exception {
+        PackageBuilder builder = new PackageBuilder();
+
+        builder.setClassPath(config.getProperty("classPath"));
+        builder.setConfigurationStoreClass(config.getProperty("configurationStoreClass"));
+        builder.setDeployerName(config.getProperty("deployerName"));
+        String[] artifactNames = config.getProperty("deploymentConfig").split("/");
+        builder.setDeploymentConfig(Arrays.asList(artifactNames));
+        builder.setEndorsedDirs(config.getProperty("endorsedDirs"));
+        builder.setExtensionDirs(config.getProperty("extensionDirs"));
+        builder.setMainClass(config.getProperty("mainClass"));
+        builder.setModuleFile(getFile(config.getProperty("moduleFile")));
+        builder.setPackageFile(getFile(config.getProperty("packageFile")));
+        builder.setPlanFile(getFile(config.getProperty("planFile")));
+        builder.setRepository(getFile(config.getProperty("repository")));
+        builder.setRepositoryClass(config.getProperty("repositoryClass"));
+
+        builder.execute();
+    }
+
+    private File getFile(String fileName) {
+        if (fileName == null) {
+            return null;
+        }
+        return new File(fileName);
+    }
+}

Propchange: geronimo/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/PackagingCommandLine.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/PackagingCommandLine.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/PackagingCommandLine.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/PlanProcessorMojo.java
URL: http://svn.apache.org/viewvc/geronimo/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/PlanProcessorMojo.java?rev=428888&view=auto
==============================================================================
--- geronimo/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/PlanProcessorMojo.java (added)
+++ geronimo/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/PlanProcessorMojo.java Fri Aug  4 14:21:54 2006
@@ -0,0 +1,288 @@
+/**
+ *
+ * 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.car;
+
+import java.io.File;
+import java.io.StringWriter;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.xml.namespace.QName;
+
+import org.apache.geronimo.deployment.service.EnvironmentBuilder;
+import org.apache.geronimo.deployment.xbeans.ArtifactType;
+import org.apache.geronimo.deployment.xbeans.EnvironmentType;
+import org.apache.geronimo.kernel.repository.Environment;
+import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.kernel.repository.ImportType;
+
+import org.apache.maven.model.Dependency;
+
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.VelocityEngine;
+
+import org.apache.xmlbeans.XmlCursor;
+import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.XmlOptions;
+
+//
+// TODO: Rename to PreparePlanMojo
+//
+
+/**
+ * Add dependencies to a plan and process with velocity
+ * 
+ * @goal prepare-plan
+ *
+ * @version $Rev$ $Date$
+ */
+public class PlanProcessorMojo
+    extends AbstractCarMojo
+{
+    private static final String ENVIRONMENT_LOCAL_NAME = "environment";
+
+    private static final QName ENVIRONMENT_QNAME = new QName("http://geronimo.apache.org/xml/ns/deployment-1.1", "environment");
+
+    /**
+     * @parameter expression="${basedir}/src/plan"
+     * @required
+     */
+    private File sourceDir;
+
+    /**
+     * @parameter expression="${project.build.directory}/plan"
+     * @required
+     */
+    private File targetDir;
+
+    /**
+     * @parameter default-value="plan.xml"
+     * @required
+     */
+    private String planFileName;
+
+    /**
+     * @parameter expression="${project.build.directory}/plan/plan.xml"
+     * @required
+     */
+    private File targetFile;
+
+    //
+    // FIXME: Resolve what to do about this comment...
+    //
+    // This is needed for ${pom.currentVersion} and will be removed when
+    // we move to a full m2 build
+    //
+
+    private VelocityContext createContext() {
+        VelocityContext context = new VelocityContext();
+        Map pom = new HashMap();
+        pom.put("groupId", project.getGroupId());
+        pom.put("artifactId", project.getArtifactId());
+        pom.put("currentVersion", project.getVersion());
+        context.put("pom", pom);
+
+        // Load properties, It inherits them all!
+        Properties props = project.getProperties();
+        for (Iterator iter = props.keySet().iterator(); iter.hasNext();) {
+            String key = (String) iter.next();
+            String value = props.getProperty(key);
+
+            log.debug("Setting " + key + "=" + value);
+            context.put(key, value);
+        }
+
+        return context;
+    }
+
+    protected void doExecute() throws Exception {
+        //
+        // FIXME: Do not need velocity here, we only need to filter,
+        //        could use resources plugin to do this for us, or
+        //        implement what resources plugin does here
+        //
+        
+        VelocityContext context = createContext();
+
+        VelocityEngine velocity = new VelocityEngine();
+        velocity.setProperty(VelocityEngine.FILE_RESOURCE_LOADER_PATH, sourceDir.getAbsolutePath());
+        velocity.init();
+
+        Template template = velocity.getTemplate(planFileName);
+        StringWriter writer = new StringWriter();
+        template.merge(context, writer);
+
+        String plan = writer.toString();
+
+        XmlObject doc = XmlObject.Factory.parse(plan);
+        XmlCursor xmlCursor = doc.newCursor();
+        LinkedHashSet dependencies = toDependencies();
+        Artifact configId = new Artifact(project.getGroupId(), project.getArtifactId(), project.getVersion(), "car");
+
+        try {
+            mergeEnvironment(xmlCursor, configId, dependencies);
+            
+            if (targetDir.exists()) {
+                if (!targetDir.isDirectory()) {
+                    throw new RuntimeException("TargetDir: " + this.targetDir + " exists and is not a directory");
+                }
+            }
+            else {
+                targetDir.mkdirs();
+            }
+
+            XmlOptions xmlOptions = new XmlOptions();
+            xmlOptions.setSavePrettyPrint();
+            doc.save(targetFile, xmlOptions);
+            
+            log.info("Generated: " + targetFile);
+        }
+        finally {
+            xmlCursor.dispose();
+        }
+    }
+
+    void mergeEnvironment(final XmlCursor xmlCursor, final Artifact configId, final LinkedHashSet dependencies) {
+        xmlCursor.toFirstContentToken();
+        xmlCursor.toFirstChild();
+        QName childName = xmlCursor.getName();
+        Environment oldEnvironment;
+
+        if (childName != null && childName.getLocalPart().equals(ENVIRONMENT_LOCAL_NAME)) {
+            convertElement(xmlCursor, ENVIRONMENT_QNAME.getNamespaceURI());
+            XmlObject xmlObject = xmlCursor.getObject();
+            EnvironmentType environmentType = (EnvironmentType) xmlObject.copy().changeType(EnvironmentType.type);
+            oldEnvironment = EnvironmentBuilder.buildEnvironment(environmentType);
+            xmlCursor.removeXml();
+        }
+        else {
+            oldEnvironment = new Environment();
+        }
+
+        Environment newEnvironment = new Environment();
+        newEnvironment.setConfigId(configId);
+        newEnvironment.setDependencies(dependencies);
+
+        EnvironmentBuilder.mergeEnvironments(oldEnvironment, newEnvironment);
+        EnvironmentType environmentType = EnvironmentBuilder.buildEnvironmentType(oldEnvironment);
+
+        xmlCursor.beginElement(ENVIRONMENT_QNAME);
+        XmlCursor element = environmentType.newCursor();
+
+        try {
+            element.copyXmlContents(xmlCursor);
+        }
+        finally {
+            element.dispose();
+        }
+    }
+
+    private void convertElement(final XmlCursor cursor, final String namespace) {
+        cursor.push();
+        XmlCursor end = cursor.newCursor();
+
+        try {
+            end.toCursor(cursor);
+            end.toEndToken();
+
+            while (cursor.hasNextToken() && cursor.isLeftOf(end)) {
+                if (cursor.isStart()) {
+                    if (!namespace.equals(cursor.getName().getNamespaceURI())) {
+                        cursor.setName(new QName(namespace, cursor.getName().getLocalPart()));
+                    }
+                }
+
+                cursor.toNextToken();
+            }
+
+            cursor.pop();
+        }
+        finally {
+            end.dispose();
+        }
+    }
+
+    private LinkedHashSet toDependencies() {
+        List artifacts = project.getDependencies();
+        LinkedHashSet dependencies = new LinkedHashSet();
+
+        Iterator iterator = artifacts.iterator();
+        while (iterator.hasNext()) {
+            //Artifact artifact = (Artifact) iterator.next();
+            Dependency dependency = (Dependency) iterator.next();
+            //Dependency dependency = artifact.getDependency();
+            org.apache.geronimo.kernel.repository.Dependency geronimoDependency = toGeronimoDependency(dependency);
+
+            if (geronimoDependency != null) {
+                dependencies.add(geronimoDependency);
+            }
+        }
+
+        return dependencies;
+    }
+
+    private static org.apache.geronimo.kernel.repository.Dependency toGeronimoDependency(final Dependency dependency) {
+        Artifact artifact = toGeronimoArtifact(dependency);
+        String type = dependency.getType();
+        String scope = dependency.getScope();
+        String groupId = dependency.getGroupId();
+
+        //!"org.apache.geronimo.specs".equals(groupId) jacc spec needed in plan.xml
+        if ("jar".equalsIgnoreCase(type) && !"junit".equals(groupId)) {
+            if (dependency.getVersion() != null) {
+                artifact = new Artifact(
+                    artifact.getGroupId(),
+                    artifact.getArtifactId(),
+                    dependency.getVersion(),
+                    artifact.getType());
+            }
+            return new org.apache.geronimo.kernel.repository.Dependency(artifact, ImportType.CLASSES);
+        }
+        else if ("car".equalsIgnoreCase(type) && ("runtime").equalsIgnoreCase(type)) {
+            return new org.apache.geronimo.kernel.repository.Dependency(artifact, ImportType.SERVICES);
+        }
+        else if ("car".equalsIgnoreCase(type) && ("compile".equalsIgnoreCase(scope))) {
+            return new org.apache.geronimo.kernel.repository.Dependency(artifact, ImportType.CLASSES);
+        }
+        else if ("car".equalsIgnoreCase(type) && (scope == null)) { //parent
+            return new org.apache.geronimo.kernel.repository.Dependency(artifact, ImportType.ALL);
+        }
+        else {
+            // not one of ours
+            return null;
+        }
+    }
+
+    private static Artifact toGeronimoArtifact(final Dependency dependency) {
+        String groupId = dependency.getGroupId();
+        String artifactId = dependency.getArtifactId();
+        String version = null;
+        String type = dependency.getType();
+
+        return new Artifact(groupId, artifactId, version, type);
+    }
+
+    interface Inserter {
+        ArtifactType insert(EnvironmentType environmentType);
+    }
+}

Propchange: geronimo/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/PlanProcessorMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/PlanProcessorMojo.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/PlanProcessorMojo.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/trunk/m2-plugins/car-maven-plugin/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewvc/geronimo/trunk/m2-plugins/car-maven-plugin/src/main/resources/META-INF/plexus/components.xml?rev=428888&view=auto
==============================================================================
--- geronimo/trunk/m2-plugins/car-maven-plugin/src/main/resources/META-INF/plexus/components.xml (added)
+++ geronimo/trunk/m2-plugins/car-maven-plugin/src/main/resources/META-INF/plexus/components.xml Fri Aug  4 14:21:54 2006
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- $Rev$ $Date$ -->
+
+<component-set>
+    <components>
+        <component>
+            <role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role>
+            <role-hint>car</role-hint>
+            <implementation>org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping</implementation>
+            <configuration>
+                <phases>
+                    <process-resources>org.apache.maven.plugins:maven-resources-plugin:resources</process-resources>
+                    <compile>org.apache.geronimo.plugins:car-maven-plugin:prepare-plan</compile>
+                    <package>org.apache.geronimo.plugins:car-maven-plugin:package</package>
+                    <install>org.apache.maven.plugins:maven-install-plugin:install</install>
+                </phases>
+            </configuration>
+        </component>
+    </components>
+</component-set>
+

Propchange: geronimo/trunk/m2-plugins/car-maven-plugin/src/main/resources/META-INF/plexus/components.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/trunk/m2-plugins/car-maven-plugin/src/main/resources/META-INF/plexus/components.xml
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/trunk/m2-plugins/car-maven-plugin/src/main/resources/META-INF/plexus/components.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: geronimo/trunk/m2-plugins/car-maven-plugin/src/site/apt/usage.apt
URL: http://svn.apache.org/viewvc/geronimo/trunk/m2-plugins/car-maven-plugin/src/site/apt/usage.apt?rev=428888&view=auto
==============================================================================
--- geronimo/trunk/m2-plugins/car-maven-plugin/src/site/apt/usage.apt (added)
+++ geronimo/trunk/m2-plugins/car-maven-plugin/src/site/apt/usage.apt Fri Aug  4 14:21:54 2006
@@ -0,0 +1,118 @@
+ ------
+ Geronimo CAR Plugin for Maven 2
+ ------
+ ???
+ ------
+ ???
+
+Basic Usage
+
+* Setup Plugin Repository
+
++----------+
+<project>
+    ...
+    <pluginRepositories>
+        ...
+        <pluginRepository>
+            <id>apache</id>
+            <name>Apache Repository</name>
+            <url>http://people.apache.org/repo/m2-ibiblio-rsync-repository</url>
+            <layout>default</layout>
+            <snapshots>
+                <enabled>false</enabled>
+            </snapshots>
+            <releases>
+                <enabled>true</enabled>
+            </releases>
+        </pluginRepository>
+        
+        <pluginRepository>
+            <id>apache-snapshots</id>
+            <name>Apache Snapshots Repository</name>
+            <url>http://people.apache.org/repo/m2-snapshot-repository</url>
+            <layout>default</layout>
+            <snapshots>
+                <enabled>true</enabled>
+                <updatePolicy>daily</updatePolicy>
+                <checksumPolicy>ignore</checksumPolicy>
+            </snapshots>
+            <releases>
+                <enabled>false</enabled>
+            </releases>
+        </pluginRepository>
+        ...
+    </pluginRepositories>
+    ...
+</project>
++----------+
+
+* Define Dependency as Extention
+
++----------+
+<project>
+    ...
+    <packaging>car</packaging>
+    ...
+    <build>
+        ...
+        <plugins>
+            ...
+            <plugin>
+                <groupId>org.apache.geronimo.plugins</groupId>
+                <artifactId>car-maven-plugin</artifactId>
+                <!-- Install as extention to allow 'car' packaging to be used. -->
+                <extensions>true</extensions>
+            </plugin>
+        </plugins>
+        ...
+    </build>
+    ...
+</project>
++----------+
+
+* CAR with ClassPath and MainClass
+
++----------+
+<project>
+    ...
+    <packaging>car</packaging>
+    ...
+    <build>
+        ...
+        <plugins>
+            ...
+            <plugin>
+                <groupId>org.apache.geronimo.plugins</groupId>
+                <artifactId>car-maven-plugin</artifactId>
+                <extensions>true</extensions>
+                <configuration>
+                    <classPath>
+                        <element>../lib/geronimo-qname_1.1_spec-${geronimoSpecQnameVersion}.jar</element>
+                        <element>../lib/geronimo-common-${pom.version}.jar</element>
+                        <element>../lib/geronimo-kernel-${pom.version}.jar</element>
+                        <element>../lib/geronimo-system-${pom.version}.jar</element>
+                        <element>../lib/geronimo-util-${pom.version}.jar</element>
+                        <element>../lib/cglib-nodep-${cglibVersion}.jar</element>
+                        <element>../lib/concurrent-${concurrentVersion}.jar</element>
+                        <element>../lib/commons-cli-${commonsCliVersion}.jar</element>
+                        <element>../lib/commons-logging-${commonsLoggingVersion}.jar</element>
+                        <element>../lib/log4j-${log4jVersion}.jar</element>
+                        <element>../lib/mx4j-${mx4jVersion}.jar</element>
+                        <element>../lib/mx4j-remote-${mx4jVersion}.jar</element>
+                        <element>../lib/endorsed/xercesImpl-${xercesVersion}.jar</element>
+                        <element>../lib/endorsed/xmlParserAPIs-${xmlParserApisVersion}.jar</element>
+                        <element>../lib/xpp3-${xpp3Version}.jar</element>
+                        <element>../lib/xstream-${xstreamVersion}.jar</element>
+                    </classPath>
+                    <mainClass>org.apache.geronimo.system.main.Daemon</mainClass>
+                    <logLevel>DEBUG</logLevel>
+                </configuration>
+            </plugin>
+            ...
+        </plugins>
+        ...
+    </build>
+    ...
+<project>
++----------+

Added: geronimo/trunk/m2-plugins/car-maven-plugin/src/site/site.xml
URL: http://svn.apache.org/viewvc/geronimo/trunk/m2-plugins/car-maven-plugin/src/site/site.xml?rev=428888&view=auto
==============================================================================
--- geronimo/trunk/m2-plugins/car-maven-plugin/src/site/site.xml (added)
+++ geronimo/trunk/m2-plugins/car-maven-plugin/src/site/site.xml Fri Aug  4 14:21:54 2006
@@ -0,0 +1,38 @@
+<?xml version="1.0"?>
+
+<!-- $Id$ -->
+
+<project name="CAR Plugin">
+   <bannerLeft>
+      <name>Geronimo</name>
+      <src>http://geronimo.apache.org/images/topleft_logo_437x64.gif</src>
+      <href>http://geronimo.apache.org/</href>
+   </bannerLeft>
+   
+   <!--
+   <bannerRight>
+      <name>Codehaus</name>
+      <src>http://mojo.codehaus.org/images/codehaus-small.png</src>
+      <href>http://www.codehaus.org</href>
+   </bannerRight>
+   -->
+   
+   <body>
+      <links>
+         <item name="Geronimo" href="http://geronimo.apache.org/"/>
+         <item name="Apache" href="http://apache.org/"/>
+      </links>
+      
+      <menu name="Geronimo">
+         <item name="Maven2 Plugins" href="../index.html"/>
+      </menu>
+      
+      <menu name="CAR Plugin">
+         <item name="Overview" href="index.html"/>
+         <item name="Usage" href="usage.html"/>
+         <item name="Configuration" href="plugin-info.html"/>
+      </menu>
+      
+      ${reports}
+   </body>
+</project>

Propchange: geronimo/trunk/m2-plugins/car-maven-plugin/src/site/site.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/trunk/m2-plugins/car-maven-plugin/src/site/site.xml
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/trunk/m2-plugins/car-maven-plugin/src/site/site.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: geronimo/trunk/m2-plugins/geronimo-deployment-plugin/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/trunk/m2-plugins/geronimo-deployment-plugin/pom.xml?rev=428888&view=auto
==============================================================================
--- geronimo/trunk/m2-plugins/geronimo-deployment-plugin/pom.xml (added)
+++ geronimo/trunk/m2-plugins/geronimo-deployment-plugin/pom.xml Fri Aug  4 14:21:54 2006
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Copyright 2006 The Apache Software Foundation
+    
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+    
+       http://www.apache.org/licenses/LICENSE-2.0
+    
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+
+<!-- $Rev$ $Date$ -->
+
+<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</artifactId>
+        <version>1.2-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>geronimo-deployment-plugin</artifactId>
+    <name>Geronimo Maven2 Plugins :: Deployment</name>
+    <packaging>maven-plugin</packaging>
+
+    <dependencies>
+
+        <!-- Module Dependencies -->
+
+        <dependency>
+            <groupId>org.apache.geronimo.modules</groupId>
+            <artifactId>geronimo-deploy-jsr88</artifactId>
+            <version>${pom.version}</version>
+        </dependency>
+
+        <!-- Thirdparty Dependencies -->
+
+        <dependency>
+            <groupId>commons-lang</groupId>
+            <artifactId>commons-lang</artifactId>
+        </dependency>
+
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <artifactId>maven-plugin-plugin</artifactId>
+                <configuration>
+                    <goalPrefix>deploy</goalPrefix>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+    
+</project>

Propchange: geronimo/trunk/m2-plugins/geronimo-deployment-plugin/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/trunk/m2-plugins/geronimo-deployment-plugin/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/trunk/m2-plugins/geronimo-deployment-plugin/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: geronimo/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/AbstractModuleMojo.java
URL: http://svn.apache.org/viewvc/geronimo/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/AbstractModuleMojo.java?rev=428888&view=auto
==============================================================================
--- geronimo/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/AbstractModuleMojo.java (added)
+++ geronimo/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/AbstractModuleMojo.java Fri Aug  4 14:21:54 2006
@@ -0,0 +1,172 @@
+/**
+ *
+ * Copyright 2004-2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.plugins.deployment;
+
+import java.io.File;
+import java.io.IOException;
+
+import javax.enterprise.deploy.shared.factories.DeploymentFactoryManager;
+
+import javax.enterprise.deploy.spi.DeploymentManager;
+import javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException;
+
+import org.apache.geronimo.deployment.plugin.factories.DeploymentFactoryImpl;
+import org.apache.geronimo.plugin.MojoSupport;
+
+//
+// TODO: Rename to AbstractDeploymentMojo
+//
+
+/**
+ * Support for deployment Mojos.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class AbstractModuleMojo extends MojoSupport {
+    
+    /**
+     * The uri to look up the JMXConnector.
+     * 
+     * @parameter default-value="jmx:rmi://localhost/jndi/rmi:/JMXConnector"
+     */
+    private String uri;
+
+    /**
+     * @parameter
+     */
+    protected String id;
+
+    /**
+     * The uri to connect to the jmx connector with.
+     * 
+     * @parameter default-value="deployer:geronimo:jmx"
+     */
+    private String distributeURI;
+
+    /**
+     * The authentication user name.
+     * 
+     * @parameter default-value="system"
+     */
+    private String username;
+
+    /**
+     * The authentication password.
+     * 
+     * @parameter default-value="manager"
+     */
+    private String password;
+
+    /**
+     * The time between connect attempts.
+     * 
+     * @parameter default-value=0
+     */
+    private long sleepTimer;
+
+    /**
+     * @parameter default-value=100
+     */
+    private int maxTries;
+
+    /**
+     * @parameter default-value=2000
+     */
+    private int retryIntervalMilliseconds;
+
+    /**
+     * @parameter default-value=true
+     */
+    private boolean failOnError;
+
+    /**
+     * @parameter
+     */
+    private File outputDirectory;
+
+    /**
+     * @parameter default-value=null
+     */
+    private File resultsLog;
+
+    /**
+     * @return Returns the maxTries.
+     */
+    public int getMaxTries() {
+        return maxTries;
+    }
+
+    /**
+     * @return Returns the retryIntervalMilliseconds.
+     */
+    public int getRetryIntervalMilliseconds() {
+        return retryIntervalMilliseconds;
+    }
+
+    /**
+     * @return Returns the sleepTimer.
+     */
+    public long getSleepTimer() {
+        return sleepTimer;
+    }
+
+    public String getUri() {
+        return uri;
+    }
+
+    public String getDistributeURI() {
+        return distributeURI;
+    }
+
+    public String getUsername() {
+        return username;
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    public boolean isFailOnError() {
+        return failOnError;
+    }
+
+    public File getOutputDirectory() {
+        return outputDirectory;
+    }
+
+    protected DeploymentManager getDeploymentManager() throws IOException, DeploymentManagerCreationException {
+        //
+        // NOTE: username, password, and distributeURI will never be null
+        //
+
+        //
+        // TODO: Document why this is here... seems very odd
+        //
+        new DeploymentFactoryImpl();
+
+        ClassLoader oldcl = Thread.currentThread().getContextClassLoader();
+        try {
+            Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
+            DeploymentFactoryManager factoryManager = DeploymentFactoryManager.getInstance();
+            return factoryManager.getDeploymentManager(getDistributeURI(), getUsername(), getPassword());
+        }
+        finally {
+            Thread.currentThread().setContextClassLoader(oldcl);
+        }
+    }
+}

Propchange: geronimo/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/AbstractModuleMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/AbstractModuleMojo.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/AbstractModuleMojo.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/DistributeModuleMojo.java
URL: http://svn.apache.org/viewvc/geronimo/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/DistributeModuleMojo.java?rev=428888&view=auto
==============================================================================
--- geronimo/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/DistributeModuleMojo.java (added)
+++ geronimo/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/DistributeModuleMojo.java Fri Aug  4 14:21:54 2006
@@ -0,0 +1,58 @@
+/**
+ *
+ * Copyright 2004-2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.plugins.deployment;
+
+import java.io.File;
+
+import javax.enterprise.deploy.spi.DeploymentManager;
+import javax.enterprise.deploy.spi.Target;
+import javax.enterprise.deploy.spi.status.ProgressObject;
+
+import org.apache.geronimo.plugins.util.DeploymentClient;
+
+//
+// TODO: Rename to DistributeMojo
+//
+
+/**
+ * ???
+ *
+ * @goal distribute
+ * 
+ * @version $Rev$ $Date$
+ */
+public class DistributeModuleMojo extends AbstractModuleMojo {
+
+    /**
+     * @parameter
+     */
+    private File module;
+
+    /**
+     * @parameter
+     */
+    private File plan;
+
+    protected void doExecute() throws Exception {
+        DeploymentManager manager = getDeploymentManager();
+        Target[] targets = manager.getTargets();
+
+        ProgressObject progress = manager.distribute(targets, module, plan);
+        DeploymentClient.waitFor(progress);
+    }
+}

Propchange: geronimo/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/DistributeModuleMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/DistributeModuleMojo.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/DistributeModuleMojo.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message