You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by jd...@apache.org on 2006/09/04 14:12:43 UTC
svn commit: r440047 - in
/geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src:
main/java/org/apache/geronimo/mavenplugins/geronimo/ site/apt/
Author: jdillon
Date: Mon Sep 4 05:12:43 2006
New Revision: 440047
URL: http://svn.apache.org/viewvc?view=rev&rev=440047
Log:
Renamed installDir to geronimoHome
When using assemblyArchive detect the value for geronimoHome
Changed outputDirectory to installDirectory, which can be set on the command-line
Chmod bin/*.sh to be executable
Updated site usage docs
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/StartServerMojo.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=440047&r1=440046&r2=440047
==============================================================================
--- 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 Mon Sep 4 05:12:43 2006
@@ -20,8 +20,12 @@
package org.apache.geronimo.mavenplugins.geronimo;
import java.io.File;
+import java.io.IOException;
import java.util.Map;
import java.util.HashMap;
+import java.util.Enumeration;
+import java.util.zip.ZipFile;
+import java.util.zip.ZipEntry;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.resolver.ArtifactResolver;
@@ -34,6 +38,7 @@
import org.codehaus.plexus.util.FileUtils;
import org.apache.tools.ant.taskdefs.Expand;
+import org.apache.tools.ant.taskdefs.Chmod;
/**
* Common assembly install support.
@@ -81,17 +86,13 @@
*/
protected File assemblyArchive = null;
- //
- // TODO: change this to installDir, add geronimoHome which is the dir under the installDir
- //
-
/**
- * Directory to extract the assembly into.
+ * Directory to install the assembly into.
*
- * @parameter expression="${project.build.directory}"
+ * @parameter expression="${installDirectory}" default-value="${project.build.directory}"
* @required
*/
- protected File outputDirectory = null;
+ protected File installDirectory = null;
//
// MojoSupport Hooks
@@ -144,7 +145,7 @@
/**
* The directory where the assembly has been installed to.
*/
- protected File installDir;
+ protected File geronimoHome;
protected void init() throws MojoExecutionException, MojoFailureException {
super.init();
@@ -156,10 +157,31 @@
installArchive = assemblyArchive;
//
- // TODO: This probably will not work... might use a scanner to search for bin/server.jar
+ // NOTE: This is obviously only going to work with ZIP archives
//
+
+ log.debug("Attempting to discover geronimoHome...");
+ try {
+ ZipFile zipFile = new ZipFile(installArchive);
+ Enumeration enum = zipFile.entries();
+ while (enum.hasMoreElements()) {
+ ZipEntry entry = (ZipEntry)enum.nextElement();
+ if (entry.getName().endsWith("bin/server.jar")) {
+ File file = new File(installDirectory, entry.getName());
+ geronimoHome = file.getParentFile().getParentFile();
+ log.info("Discovered geronimoHome: " + geronimoHome);
+ break;
+ }
+ }
+ zipFile.close();
+ }
+ catch (IOException e) {
+ log.debug("Failed to scan archive for 'bin/server.jar'", e);
+ }
- installDir = new File(outputDirectory, "assembly-archive");
+ if (geronimoHome == null) {
+ throw new MojoExecutionException("Failed to determine geronimoHome from archive: " + installArchive);
+ }
}
else {
Artifact artifact = getAssemblyArtifact();
@@ -169,7 +191,7 @@
}
installArchive = artifact.getFile();
- installDir = new File(outputDirectory, artifact.getArtifactId() + "-" + artifact.getVersion());
+ geronimoHome = new File(installDirectory, artifact.getArtifactId() + "-" + artifact.getVersion());
}
}
@@ -229,7 +251,7 @@
protected void doInstall() throws Exception {
// Check if there is a newer archive or missing marker to trigger assembly install
- File installMarker = new File(installDir, ".installed");
+ File installMarker = new File(geronimoHome, ".installed");
boolean refresh = this.refresh; // don't override config state with local state
if (!refresh) {
@@ -246,9 +268,9 @@
}
if (refresh) {
- if (installDir.exists()) {
- log.debug("Removing: " + installDir);
- FileUtils.forceDelete(installDir);
+ if (geronimoHome.exists()) {
+ log.debug("Removing: " + geronimoHome);
+ FileUtils.forceDelete(geronimoHome);
}
}
@@ -256,10 +278,23 @@
if (!installMarker.exists()) {
log.info("Installing assembly...");
+ FileUtils.forceMkdir(geronimoHome);
+
+ //
+ // TODO: Maybe consider supporting untar + gz/bz ?
+ //
+
Expand unzip = (Expand)createTask("unzip");
unzip.setSrc(installArchive);
- unzip.setDest(outputDirectory);
+ unzip.setDest(installDirectory);
unzip.execute();
+
+ // Make scripts executable, since Java unzip ignores perms
+ Chmod chmod = (Chmod)createTask("chmod");
+ chmod.setPerm("ugo+rx");
+ chmod.setDir(geronimoHome);
+ chmod.setIncludes("bin/*.sh");
+ chmod.execute();
installMarker.createNewFile();
}
Modified: geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/StartServerMojo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/StartServerMojo.java?view=diff&rev=440047&r1=440046&r2=440047
==============================================================================
--- geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/StartServerMojo.java (original)
+++ geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/StartServerMojo.java Mon Sep 4 05:12:43 2006
@@ -121,8 +121,8 @@
// Setup the JVM to start the server with
final Java java = (Java)createTask("java");
- java.setJar(new File(installDir, "bin/server.jar"));
- java.setDir(installDir);
+ java.setJar(new File(geronimoHome, "bin/server.jar"));
+ java.setDir(geronimoHome);
java.setFailonerror(true);
java.setFork(true);
java.setLogError(true);
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=440047&r1=440046&r2=440047
==============================================================================
--- 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 Mon Sep 4 05:12:43 2006
@@ -10,10 +10,12 @@
* Assembly Artifact Configuration
Before the plugin can start or stop a server, it needs to know about the
- assembly (or asemblies) which it will install.
+ assembly (or assemblies) which it will install.
This example shows one assembly, which will be used to install unless the
- <<<assemblyArchive>>> parameter has been set.
+ <<<assemblyArchive>>> parameter has been set (see below section on <Installing an Assembly>).
+
+ <<NOTE:>> Archive files <<MUST>> be a <<<ZIP>>> files (or be in the same format, like a <<<JAR>>>).
+----------+
<plugin>
@@ -34,7 +36,7 @@
</plugin>
+----------+
- Multipule assemblies may be specified. Each must have a unique id, and either
+ Multiple assemblies may be specified. Each must have a unique id, and either
<<<defaultAssemblyId>>> or <<<assemblyId>>> must be configured to inform the
plugin which assembly to use.
@@ -89,32 +91,55 @@
* Starting Geronimo Server
- If you have configured an assembly (or assemblies with a default), then
- simply:
+ Once you have configured an assembly (or assemblies with a default), then you can simply start the server.
+
+ The assembly archive will be installed if it does not already exist, or if
+ the plugin detects that the current archive is newer than the last installation.
+----------+
mvn geronimo:start
+----------+
- The assembly archive will be installed if it does not already exist, or if
- the plugin detects that the current archive is newer than the last installation.
-
- Some additional flags may be passed in to alter the startup behavor. For example
+ Some additional flags may be passed in to alter the startup behavior. For example
to enable verbose mode:
+----------+
mvn geronimo:start -Dverbose=true
+----------+
+ Optional JVM debug arguments may be configured.
+
++----------+
+<plugin>
+ <groupId>org.apache.geronimo.plugins</groupId>
+ <artifactId>geronimo-maven-plugin</artifactId>
+
+ <configuration>
+ <debugArguments>
+ <argument>-Xdebug</argument>
+ <argument>-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n</argument>
+ </debugArguments>
+ </configuration>
+</plugin>
++----------+
+
+ By setting the <<<debug>>> parameter the JVM will be started in debug mode.
+
++----------+
+mvn geronimo:start -Ddebug=true
++----------+
+
* Stopping Geronimo Server
- To stop the server, simply:
+ To stop a server using the defaults, which is probably fine in most cases, just invoke the {{stop}} goal.
+
+ Stopping a server does not require an assembly to be installed.
+----------+
mvn geronimo:stop
+----------+
- Additonal parameters may be passed in on the command-line:
+ Additional parameters may be passed in on the command-line:
+----------+
mvn geronimo:stop -Dusername=system -Dpassword=manager -Dport=1099
@@ -160,4 +185,32 @@
</execution>
</executions>
</plugin>
++----------+
+
+* Installing an Assembly
+
+ To just run the installation of the assembly:
+
++----------+
+mvn geronimo:install -DassemblyId=tomcat
++----------+
+
+ To install a specific assembly archive, which need not be in the repository:
+
++----------+
+mvn geronimo:install -DassemblyArchive=/path/to/assembly.zip
++----------+
+
+ For this to work, the file <<MUST>> be a <<<ZIP>>> (or be in the same format, like a <<<JAR>>>)
+ and the archive should contain a full server assembly, specifically it needs to have a
+ <<<bin/server.jar>>> entry. This entry is used to discover <<<geronimoHome>>>.
+
+ You can also change the base directory where the assembly is extracted to by setting
+ the <<<installDirectory>>> parameter. This is useful for a certain operating system
+ that has a horribly small limit on the maximum size of a path name.
+
+ <<NOTE:>> The directory structure of the archive is still preserved when it is extracted.
+
++----------+
+mvn geronimo:install -DinstallDirectory=c:\
+----------+