geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r439884 - in /geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src: main/java/org/apache/geronimo/mavenplugins/geronimo/ site/apt/
Date Mon, 04 Sep 2006 00:28:24 GMT
Author: jdillon
Date: Sun Sep  3 17:28:23 2006
New Revision: 439884

URL: http://svn.apache.org/viewvc?view=rev&rev=439884
Log:
Moved assembly config and helpers to InstallerMojoSupport

Modified:
    geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/InstallerMojoSupport.java
    geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/ServerMojoSupport.java
    geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/site/apt/usage.apt

Modified: geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/InstallerMojoSupport.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/InstallerMojoSupport.java?view=diff&rev=439884&r1=439883&r2=439884
==============================================================================
--- geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/InstallerMojoSupport.java
(original)
+++ geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/InstallerMojoSupport.java
Sun Sep  3 17:28:23 2006
@@ -17,8 +17,17 @@
 package org.apache.geronimo.mavenplugins.geronimo;
 
 import java.io.File;
+import java.util.Map;
+import java.util.HashMap;
 
 import org.apache.tools.ant.taskdefs.Expand;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.artifact.factory.ArtifactFactory;
+import org.apache.maven.artifact.resolver.ArtifactResolver;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
 
 import org.codehaus.plexus.util.FileUtils;
 
@@ -36,6 +45,179 @@
      * @parameter expression="${refresh}" default-value="false"
      */
     protected boolean refresh = false;
+
+    /**
+     * List of assembly artifact configurations.  Artifacts need to point to ZIP archives.
+     *
+     * @parameter
+     * @required
+     */
+    protected AssemblyConfig[] assemblies = null;
+
+    /**
+     * Identifer of the assembly configuration to use.
+     *
+     * @parameter expression="${assemblyId}"
+     */
+    protected String assemblyId = null;
+
+    /**
+     * The default assemblyId to use when no assemblyId configured.
+     *
+     * @parameter
+     */
+    protected String defaultAssemblyId = null;
+
+    /**
+     * A file which points to a specific assembly ZIP archive.
+     * If this parameter is set, then it will be used instead of from the
+     * assemblies configuration.
+     *
+     * @parameter expression="${assemblyArchive}"
+     */
+    protected File assemblyArchive = null;
+
+    /**
+     * Directory to extract the assembly into.
+     *
+     * @parameter expression="${project.build.directory}"
+     * @required
+     */
+    protected File outputDirectory = null;
+
+    //
+    // MojoSupport Hooks
+    //
+
+    /**
+     * ???
+     *
+     * @component
+     * @required
+     * @readonly
+     */
+    protected ArtifactFactory artifactFactory = null;
+
+    protected ArtifactFactory getArtifactFactory() {
+        return artifactFactory;
+    }
+
+    /**
+     * ???
+     *
+     * @component
+     * @required
+     * @readonly
+     */
+    protected ArtifactResolver artifactResolver = null;
+
+    protected ArtifactResolver getArtifactResolver() {
+        return artifactResolver;
+    }
+
+    /**
+     * ???
+     *
+     * @parameter expression="${localRepository}"
+     * @readonly
+     * @required
+     */
+    protected ArtifactRepository artifactRepository = null;
+
+    protected ArtifactRepository getArtifactRepository() {
+        return artifactRepository;
+    }
+
+    /**
+     * The assembly archive to use when installing.
+     */
+    protected File installArchive;
+
+    /**
+     * The directory where the assembly has been installed to.
+     */
+    protected File installDir;
+
+    protected void init() throws MojoExecutionException, MojoFailureException {
+        super.init();
+
+        // Determine which archive and directory to use... either manual or from artifacts
+        if (assemblyArchive != null) {
+            log.debug("Using non-artifact based assembly archive: " + installArchive);
+
+            installArchive = assemblyArchive;
+
+            //
+            // FIXME: This probably will not work...
+            //
+
+            installDir = new File(outputDirectory, "assembly-archive");
+        }
+        else {
+            Artifact artifact = getAssemblyArtifact();
+
+            if (!"zip".equals(artifact.getType())) {
+                throw new MojoExecutionException("Assembly file does not look like a ZIP
archive");
+            }
+
+            installArchive = artifact.getFile();
+            installDir = new File(outputDirectory, artifact.getArtifactId() + "-" + artifact.getVersion());
+        }
+    }
+
+    protected Artifact getAssemblyArtifact() throws MojoExecutionException {
+        assert assemblies != null;
+
+        AssemblyConfig config;
+
+        if (assemblies.length == 0) {
+            throw new MojoExecutionException("At least one assembly configuration must be
specified");
+        }
+        else if (assemblies.length > 1 && assemblyId == null && defaultAssemblyId
== null) {
+            throw new MojoExecutionException("Must specify assemblyId (or defaultAssemblyId)
when more than on assembly configuration is given");
+        }
+        else if (assemblies.length == 1) {
+            config = assemblies[0];
+        }
+        else {
+            if (assemblyId == null) {
+                assemblyId = defaultAssemblyId;
+            }
+
+            log.debug("Searching for assembly config for id: " + assemblyId);
+
+            // Make sure there are no duplicate ids
+            Map idMap = new HashMap();
+
+            for (int i=0; i < assemblies.length; i++) {
+                String id = assemblies[i].getId();
+
+                if (id == null) {
+                    throw new MojoExecutionException("Missing id for assembly configuration:
" + assemblies[i]);
+                }
+
+                if (idMap.containsKey(id)) {
+                    throw new MojoExecutionException("Duplicate assembly id: " + id);
+                }
+
+                idMap.put(id, assemblies[i]);
+            }
+
+            config = (AssemblyConfig) idMap.get(assemblyId);
+            if (config == null) {
+                throw new MojoExecutionException("Missing assembly configuration for id:
" + assemblyId);
+            }
+        }
+
+        log.info("Using assembly configuration: " + config);
+        Artifact artifact = getArtifact(config);
+
+        if (artifact.getFile() == null) {
+            throw new MojoExecutionException("Assembly artifact does not have an attached
file: " + artifact);
+        }
+
+        return artifact;
+    }
 
     protected void doInstall() throws Exception {
         // Check if there is a newer archive or missing marker to trigger assembly install

Modified: geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/ServerMojoSupport.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/ServerMojoSupport.java?view=diff&rev=439884&r1=439883&r2=439884
==============================================================================
--- geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/ServerMojoSupport.java
(original)
+++ geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/ServerMojoSupport.java
Sun Sep  3 17:28:23 2006
@@ -16,22 +16,11 @@
 
 package org.apache.geronimo.mavenplugins.geronimo;
 
-import org.apache.maven.project.MavenProject;
-import org.apache.maven.artifact.resolver.ArtifactResolver;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.factory.ArtifactFactory;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-
-import java.util.Map;
-import java.util.HashMap;
-import java.io.File;
-
 import org.apache.geronimo.genesis.AntMojoSupport;
+import org.apache.maven.project.MavenProject;
 
 /**
- * Support for Geronimo {start, stop} server mojos.
+ * Support for Geronimo server mojos.
  *
  * @version $Rev$ $Date$
  */
@@ -60,49 +49,6 @@
     protected String password = null;
 
     //
-    // TODO: Move assembly bits to InstallerMojoSupport
-    //
-    
-    /**
-     * List of assembly artifact configurations.  Artifacts need to point to ZIP archives.
-     *
-     * @parameter
-     * @required
-     */
-    protected AssemblyConfig[] assemblies = null;
-
-    /**
-     * Identifer of the assembly configuration to use.
-     *
-     * @parameter expression="${assemblyId}"
-     */
-    protected String assemblyId = null;
-
-    /**
-     * The default assemblyId to use when no assemblyId configured.
-     *
-     * @parameter
-     */
-    protected String defaultAssemblyId = null;
-
-    /**
-     * A file which points to a specific assembly ZIP archive.
-     * If this parameter is set, then it will be used instead of from the
-     * assemblies configuration.
-     *
-     * @parameter expression="${assemblyArchive}"
-     */
-    protected File assemblyArchive = null;
-
-    /**
-     * Directory to extract the assembly into.
-     *
-     * @parameter expression="${project.build.directory}"
-     * @required
-     */
-    protected File outputDirectory = null;
-
-    //
     // MojoSupport Hooks
     //
 
@@ -117,135 +63,5 @@
 
     protected MavenProject getProject() {
         return project;
-    }
-
-    /**
-     * ???
-     *
-     * @component
-     * @required
-     * @readonly
-     */
-    protected ArtifactFactory artifactFactory = null;
-
-    protected ArtifactFactory getArtifactFactory() {
-        return artifactFactory;
-    }
-
-    /**
-     * ???
-     *
-     * @component
-     * @required
-     * @readonly
-     */
-    protected ArtifactResolver artifactResolver = null;
-
-    protected ArtifactResolver getArtifactResolver() {
-        return artifactResolver;
-    }
-
-    /**
-     * ???
-     *
-     * @parameter expression="${localRepository}"
-     * @readonly
-     * @required
-     */
-    protected ArtifactRepository artifactRepository = null;
-
-    protected ArtifactRepository getArtifactRepository() {
-        return artifactRepository;
-    }
-
-    /**
-     * The assembly archive to use when installing.
-     */
-    protected File installArchive;
-
-    /**
-     * The directory where the assembly has been installed to.
-     */
-    protected File installDir;
-
-    protected void init() throws MojoExecutionException, MojoFailureException {
-        super.init();
-
-        // Determine which archive and directory to use... either manual or from artifacts
-        if (assemblyArchive != null) {
-            log.debug("Using non-artifact based assembly archive: " + installArchive);
-
-            installArchive = assemblyArchive;
-
-            //
-            // FIXME: This probably will not work...
-            //
-
-            installDir = new File(outputDirectory, "assembly-archive");
-        }
-        else {
-            Artifact artifact = getAssemblyArtifact();
-
-            if (!"zip".equals(artifact.getType())) {
-                throw new MojoExecutionException("Assembly file does not look like a ZIP
archive");
-            }
-
-            installArchive = artifact.getFile();
-            installDir = new File(outputDirectory, artifact.getArtifactId() + "-" + artifact.getVersion());
-        }
-    }
-
-    protected Artifact getAssemblyArtifact() throws MojoExecutionException {
-        assert assemblies != null;
-
-        AssemblyConfig config;
-
-        if (assemblies.length == 0) {
-            throw new MojoExecutionException("At least one assembly configuration must be
specified");
-        }
-        else if (assemblies.length > 1 && assemblyId == null && defaultAssemblyId
== null) {
-            throw new MojoExecutionException("Must specify assemblyId (or defaultAssemblyId)
when more than on assembly configuration is given");
-        }
-        else if (assemblies.length == 1) {
-            config = assemblies[0];
-        }
-        else {
-            if (assemblyId == null) {
-                assemblyId = defaultAssemblyId;
-            }
-
-            log.debug("Searching for assembly config for id: " + assemblyId);
-
-            // Make sure there are no duplicate ids
-            Map idMap = new HashMap();
-
-            for (int i=0; i < assemblies.length; i++) {
-                String id = assemblies[i].getId();
-
-                if (id == null) {
-                    throw new MojoExecutionException("Missing id for assembly configuration:
" + assemblies[i]);
-                }
-
-                if (idMap.containsKey(id)) {
-                    throw new MojoExecutionException("Duplicate assembly id: " + id);
-                }
-
-                idMap.put(id, assemblies[i]);
-            }
-
-            config = (AssemblyConfig) idMap.get(assemblyId);
-            if (config == null) {
-                throw new MojoExecutionException("Missing assembly configuration for id:
" + assemblyId);
-            }
-        }
-
-        log.info("Using assembly configuration: " + config);
-        Artifact artifact = getArtifact(config);
-
-        if (artifact.getFile() == null) {
-            throw new MojoExecutionException("Assembly artifact does not have an attached
file: " + artifact);
-        }
-
-        return artifact;
     }
 }

Modified: geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/site/apt/usage.apt
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/site/apt/usage.apt?view=diff&rev=439884&r1=439883&r2=439884
==============================================================================
--- geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/site/apt/usage.apt (original)
+++ geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/site/apt/usage.apt Sun Sep
 3 17:28:23 2006
@@ -129,12 +129,6 @@
 mvn geronimo:start -DassemblyId=tomcat
 +----------+
 
- Currently you need to specify the assemblyId for <<<geronimo:stop>>> too.
-
-+----------+
-mvn geronimo:stop -DassemblyId=tomcat
-+----------+
-
 * Start/Stop for Integration Testing
 
  For inline integration testing, you can set the <<<background>>> parameter



Mime
View raw message