geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r419837 - in /geronimo/sandbox/svkmerge/m2migration/m2-plugins: ./ geronimo-assembly-plugin/ geronimo-assembly-plugin/src/ geronimo-assembly-plugin/src/java/ geronimo-assembly-plugin/src/java/org/ geronimo-assembly-plugin/src/java/org/apach...
Date Fri, 07 Jul 2006 08:06:38 GMT
Author: jdillon
Date: Fri Jul  7 01:06:37 2006
New Revision: 419837

URL: http://svn.apache.org/viewvc?rev=419837&view=rev
Log:
Adding assembly plugin from patch in GERONIMO-1737; augmented to use MojoSupport and improved
error handling

Added:
    geronimo/sandbox/svkmerge/m2migration/m2-plugins/geronimo-assembly-plugin/
    geronimo/sandbox/svkmerge/m2migration/m2-plugins/geronimo-assembly-plugin/pom.xml   (with
props)
    geronimo/sandbox/svkmerge/m2migration/m2-plugins/geronimo-assembly-plugin/src/
    geronimo/sandbox/svkmerge/m2migration/m2-plugins/geronimo-assembly-plugin/src/java/
    geronimo/sandbox/svkmerge/m2migration/m2-plugins/geronimo-assembly-plugin/src/java/org/
    geronimo/sandbox/svkmerge/m2migration/m2-plugins/geronimo-assembly-plugin/src/java/org/apache/
    geronimo/sandbox/svkmerge/m2migration/m2-plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/
    geronimo/sandbox/svkmerge/m2migration/m2-plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/
    geronimo/sandbox/svkmerge/m2migration/m2-plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/
    geronimo/sandbox/svkmerge/m2migration/m2-plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/ConfigInstallerMojo.java
  (with props)
Modified:
    geronimo/sandbox/svkmerge/m2migration/m2-plugins/geronimo-packaging-plugin/pom.xml
    geronimo/sandbox/svkmerge/m2migration/m2-plugins/pom.xml

Added: geronimo/sandbox/svkmerge/m2migration/m2-plugins/geronimo-assembly-plugin/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/svkmerge/m2migration/m2-plugins/geronimo-assembly-plugin/pom.xml?rev=419837&view=auto
==============================================================================
--- geronimo/sandbox/svkmerge/m2migration/m2-plugins/geronimo-assembly-plugin/pom.xml (added)
+++ geronimo/sandbox/svkmerge/m2migration/m2-plugins/geronimo-assembly-plugin/pom.xml Fri
Jul  7 01:06:37 2006
@@ -0,0 +1,72 @@
+<?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-parent</artifactId>
+        <version>1.2-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+    
+    <artifactId>geronimo-assembly-plugin</artifactId>
+    <name>Geronimo Plugins :: Assembly</name>
+    <packaging>maven-plugin</packaging>
+    
+    <dependencies>
+        
+        <dependency>
+            <groupId>${pom.groupId}</groupId>
+            <artifactId>plugin-support</artifactId>
+            <version>${pom.version}</version>
+        </dependency>
+        
+        <dependency>
+            <groupId>org.apache.geronimo.modules</groupId>
+            <artifactId>geronimo-kernel</artifactId>
+            <version>${pom.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.geronimo.modules</groupId>
+            <artifactId>geronimo-system</artifactId>
+            <version>${pom.version}</version>
+        </dependency>
+
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <artifactId>maven-plugin-plugin</artifactId>
+                <configuration>
+                    <goalPrefix>assembly</goalPrefix>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
+

Propchange: geronimo/sandbox/svkmerge/m2migration/m2-plugins/geronimo-assembly-plugin/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/svkmerge/m2migration/m2-plugins/geronimo-assembly-plugin/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/svkmerge/m2migration/m2-plugins/geronimo-assembly-plugin/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: geronimo/sandbox/svkmerge/m2migration/m2-plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/ConfigInstallerMojo.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/svkmerge/m2migration/m2-plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/ConfigInstallerMojo.java?rev=419837&view=auto
==============================================================================
--- geronimo/sandbox/svkmerge/m2migration/m2-plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/ConfigInstallerMojo.java
(added)
+++ geronimo/sandbox/svkmerge/m2migration/m2-plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/ConfigInstallerMojo.java
Fri Jul  7 01:06:37 2006
@@ -0,0 +1,262 @@
+/*
+ *  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.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;
+
+//
+// TODO: Rename to InstallConfigMojo
+//
+
+/**
+ * @goal installConfig
+ * 
+ * @version $Rev$ $Date$
+ */
+public class ConfigInstallerMojo
+    extends MojoSupport
+{
+    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;
+
+    /**
+     * The 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;
+
+    protected void doExecute() throws Exception {
+        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(explicitResolutionLocation,
+                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/sandbox/svkmerge/m2migration/m2-plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/ConfigInstallerMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/svkmerge/m2migration/m2-plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/ConfigInstallerMojo.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/svkmerge/m2migration/m2-plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/ConfigInstallerMojo.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/sandbox/svkmerge/m2migration/m2-plugins/geronimo-packaging-plugin/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/svkmerge/m2migration/m2-plugins/geronimo-packaging-plugin/pom.xml?rev=419837&r1=419836&r2=419837&view=diff
==============================================================================
--- geronimo/sandbox/svkmerge/m2migration/m2-plugins/geronimo-packaging-plugin/pom.xml (original)
+++ geronimo/sandbox/svkmerge/m2migration/m2-plugins/geronimo-packaging-plugin/pom.xml Fri
Jul  7 01:06:37 2006
@@ -141,12 +141,10 @@
         </dependency> 
     </dependencies>
 
-    <!-- bind jmxDistribute to deploy -->
     <build>
         <plugins>
             <plugin>
                 <artifactId>maven-plugin-plugin</artifactId>
-                <version>2.1</version>
                 <configuration>
                     <goalPrefix>car</goalPrefix>
                 </configuration>

Modified: geronimo/sandbox/svkmerge/m2migration/m2-plugins/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/svkmerge/m2migration/m2-plugins/pom.xml?rev=419837&r1=419836&r2=419837&view=diff
==============================================================================
--- geronimo/sandbox/svkmerge/m2migration/m2-plugins/pom.xml (original)
+++ geronimo/sandbox/svkmerge/m2migration/m2-plugins/pom.xml Fri Jul  7 01:06:37 2006
@@ -64,7 +64,20 @@
     <modules>
         <module>plugin-support</module>
         <module>geronimo-packaging-plugin</module>
+        <module>geronimo-assembly-plugin</module>
     </modules>
+    
+    <build>
+        <pluginManagement>
+            <plugins>
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-plugin-plugin</artifactId>
+                    <version>2.1</version>
+                </plugin>
+            </plugins>
+        </pluginManagement>
+    </build>
     
 </project>
 



Mime
View raw message