geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r450613 - in /geronimo/server/trunk: maven-plugins/geronimo-maven-plugin/ maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/ maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mav...
Date Wed, 27 Sep 2006 22:45:47 GMT
Author: jdillon
Date: Wed Sep 27 15:45:46 2006
New Revision: 450613

URL: http://svn.apache.org/viewvc?view=rev&rev=450613
Log:
(GERONIMO-2419) Enabling logging for start-server, hooked up reporters API for exception handling,
Adding a Surefire reporter which will output reports in a surefire manner, so we can re-use
the surefire html report fluff to visualize
Massaged from reporters.patch by Prasad

Added:
    geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/reporting/
    geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/reporting/Reportable.java
  (with props)
    geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/reporting/Reporter.java
  (with props)
    geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/reporting/ReportingMojoSupport.java
  (with props)
    geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/reporting/SurefireReporter.java
  (with props)
Modified:
    geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/pom.xml
    geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/GeronimoMojoSupport.java
    geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/DeployModuleMojo.java
    geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/ListModulesMojo.java
    geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/ModuleMojoSupport.java
    geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/StartModuleMojo.java
    geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/StartStopUndeployMojoSupport.java
    geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/StopModuleMojo.java
    geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/UndeployModuleMojo.java
    geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/server/InstallAssemblyMojo.java
    geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/server/InstallerMojoSupport.java
    geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/server/StartServerMojo.java
    geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/server/StopServerMojo.java
    geronimo/server/trunk/testsuite/deployment-testsuite/pom.xml

Modified: geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/pom.xml?view=diff&rev=450613&r1=450612&r2=450613
==============================================================================
--- geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/pom.xml (original)
+++ geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/pom.xml Wed Sep 27 15:45:46
2006
@@ -41,7 +41,8 @@
     </description>
 
     <dependencies>
-      <dependency>
+
+        <dependency>
             <groupId>org.apache.geronimo.modules</groupId>
             <artifactId>geronimo-deploy-jsr88</artifactId>
             <version>${pom.version}</version>
@@ -57,6 +58,20 @@
             <groupId>mx4j</groupId>
             <artifactId>mx4j-remote</artifactId>
         </dependency>
+
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-plugin-descriptor</artifactId>
+            <version>2.0.4</version>
+        </dependency>
+        
+        <!-- Support for SurefireReporter -->
+        <dependency>
+            <groupId>org.apache.maven.surefire</groupId>
+            <artifactId>surefire-api</artifactId>
+            <version>2.1-SNAPSHOT</version>
+        </dependency>
+
     </dependencies>
 
     <build>

Modified: geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/GeronimoMojoSupport.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/GeronimoMojoSupport.java?view=diff&rev=450613&r1=450612&r2=450613
==============================================================================
--- geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/GeronimoMojoSupport.java
(original)
+++ geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/GeronimoMojoSupport.java
Wed Sep 27 15:45:46 2006
@@ -32,7 +32,7 @@
  * @version $Rev$ $Date$
  */
 public abstract class GeronimoMojoSupport
-        extends AntMojoSupport
+    extends AntMojoSupport
 {
     //
     // NOTE: Not all mojos need Ant support, but due to the inability of Maven to inject
custom components
@@ -129,5 +129,4 @@
     protected ArtifactRepository getArtifactRepository() {
         return artifactRepository;
     }
-
 }

Modified: geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/DeployModuleMojo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/DeployModuleMojo.java?view=diff&rev=450613&r1=450612&r2=450613
==============================================================================
--- geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/DeployModuleMojo.java
(original)
+++ geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/DeployModuleMojo.java
Wed Sep 27 15:45:46 2006
@@ -85,7 +85,8 @@
         else if (modules == null || modules.length == 0) {
             throw new MojoExecutionException("At least one module configuration (or moduleArchive)
must be specified");
         }
-        else {
+
+        if (modules != null && modules.length != 0) {
             log.info("Using artifact based module archive(s)...");
 
             for (int i=0; i<modules.length; i++) {
@@ -155,5 +156,12 @@
         }
 
         return progress.getResultTargetModuleIDs();
+    }
+
+    protected String getGoalName() {
+        //
+        // FIXME: There has to be way this can be computed instead of hardcoded absolutely.
+        //
+        return "deploy-module";
     }
 }

Modified: geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/ListModulesMojo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/ListModulesMojo.java?view=diff&rev=450613&r1=450612&r2=450613
==============================================================================
--- geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/ListModulesMojo.java
(original)
+++ geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/ListModulesMojo.java
Wed Sep 27 15:45:46 2006
@@ -49,4 +49,8 @@
 
         logModules(manager.getNonRunningModules(null, targets));
     }
+
+    protected String getGoalName() {
+        return "list-modules";
+    }
 }

Modified: geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/ModuleMojoSupport.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/ModuleMojoSupport.java?view=diff&rev=450613&r1=450612&r2=450613
==============================================================================
--- geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/ModuleMojoSupport.java
(original)
+++ geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/ModuleMojoSupport.java
Wed Sep 27 15:45:46 2006
@@ -34,8 +34,8 @@
 import javax.enterprise.deploy.shared.factories.DeploymentFactoryManager;
 
 import org.apache.geronimo.deployment.plugin.factories.DeploymentFactoryImpl;
-import org.apache.geronimo.mavenplugins.geronimo.GeronimoMojoSupport;
 import org.apache.geronimo.mavenplugins.geronimo.ModuleConfig;
+import org.apache.geronimo.mavenplugins.geronimo.reporting.ReportingMojoSupport;
 
 import org.apache.geronimo.genesis.ArtifactItem;
 
@@ -47,7 +47,7 @@
  * @version $Rev$ $Date$
  */
 public abstract class ModuleMojoSupport
-    extends GeronimoMojoSupport
+    extends ReportingMojoSupport
 {
     private static final String URI_PREFIX = "deployer:geronimo:jmx";
 
@@ -304,4 +304,5 @@
             }
         }
     }
+
 }

Modified: geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/StartModuleMojo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/StartModuleMojo.java?view=diff&rev=450613&r1=450612&r2=450613
==============================================================================
--- geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/StartModuleMojo.java
(original)
+++ geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/StartModuleMojo.java
Wed Sep 27 15:45:46 2006
@@ -36,4 +36,11 @@
     protected void doExecute() throws Exception {
         startModule();
     }
+
+    protected String getGoalName() {
+        //
+        // FIXME: There has to be way this can be computed instead of hardcoded absolutely.
+        //
+        return "start-module";
+    }
 }

Modified: geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/StartStopUndeployMojoSupport.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/StartStopUndeployMojoSupport.java?view=diff&rev=450613&r1=450612&r2=450613
==============================================================================
--- geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/StartStopUndeployMojoSupport.java
(original)
+++ geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/StartStopUndeployMojoSupport.java
Wed Sep 27 15:45:46 2006
@@ -19,6 +19,9 @@
 
 package org.apache.geronimo.mavenplugins.geronimo.module;
 
+import java.util.Arrays;
+import java.util.ArrayList;
+
 import org.apache.geronimo.mavenplugins.geronimo.ModuleConfig;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
@@ -50,9 +53,16 @@
 
             // Add the single module to the list
             ModuleConfig moduleConfig = createModuleConfigFromId(moduleId);
-            modules = new ModuleConfig[] {
-                moduleConfig
-            };
+            if (modules == null) {
+                modules = new ModuleConfig[] {
+                    moduleConfig
+                };
+            }
+            else {
+                ArrayList list = (ArrayList) Arrays.asList(modules);
+                list.add(moduleConfig);
+                modules = (ModuleConfig[]) list.toArray(new ModuleConfig[list.size()]);
+            }
         }
         else if (modules == null || modules.length == 0) {
             throw new MojoExecutionException("At least one module configuration (or moduleId)
must be specified");

Modified: geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/StopModuleMojo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/StopModuleMojo.java?view=diff&rev=450613&r1=450612&r2=450613
==============================================================================
--- geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/StopModuleMojo.java
(original)
+++ geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/StopModuleMojo.java
Wed Sep 27 15:45:46 2006
@@ -36,4 +36,11 @@
     protected void doExecute() throws Exception {
         stopModule();
     }
+
+    protected String getGoalName() {
+        //
+        // FIXME: There has to be way this can be computed instead of hardcoded absolutely.
+        //
+        return "stop-module";
+    } 
 }

Modified: geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/UndeployModuleMojo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/UndeployModuleMojo.java?view=diff&rev=450613&r1=450612&r2=450613
==============================================================================
--- geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/UndeployModuleMojo.java
(original)
+++ geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/UndeployModuleMojo.java
Wed Sep 27 15:45:46 2006
@@ -36,4 +36,11 @@
     protected void doExecute() throws Exception {
         undeployModule();
     }
+
+    protected String getGoalName() {
+        //
+        // FIXME: There has to be way this can be computed instead of hardcoded absolutely.
+        //
+        return "undeploy-module";
+    }
 }

Added: geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/reporting/Reportable.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/reporting/Reportable.java?view=auto&rev=450613
==============================================================================
--- geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/reporting/Reportable.java
(added)
+++ geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/reporting/Reportable.java
Wed Sep 27 15:45:46 2006
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.mavenplugins.geronimo.reporting;
+
+import java.io.File;
+import java.util.Date;
+
+/**
+ * Provides the details of the report to a {@link Reporter}.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Reportable
+{
+    /**
+     * Returns the date at which the goal was started.
+     *
+     * @return  The date when the goal was started.
+     */
+    Date getStartTime();
+
+    /**
+     * Returns the name of the goal.
+     *
+     * @return  Goal name.
+     */
+    String getName();
+
+    /**
+     * Returns the log file which the goal may or may not output logs to.
+     *
+     * @return  The log file; or null of the goal does not log to a file.
+     */
+    File getLogFile();
+}

Propchange: geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/reporting/Reportable.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/reporting/Reportable.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/reporting/Reportable.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/reporting/Reporter.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/reporting/Reporter.java?view=auto&rev=450613
==============================================================================
--- geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/reporting/Reporter.java
(added)
+++ geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/reporting/Reporter.java
Wed Sep 27 15:45:46 2006
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.mavenplugins.geronimo.reporting;
+
+/**
+ * Provides an asbtraction to allow pluggable report handling.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Reporter
+{
+    /**
+     * Signals the start of a reporting run.  This method should collect the required information.
+     *
+     * @param source    The source of the report; must not be null.
+     */
+    void reportBegin(Reportable source);
+
+    /**
+     * Called when a failure has occured while executing a goal.
+     *
+     * @param cause     The cause of the error; must not be null.
+     */
+    void reportError(Throwable cause);
+
+    /**
+     * Called after the goal has run (with or with-out errors).
+     */
+    void reportEnd();
+}

Propchange: geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/reporting/Reporter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/reporting/Reporter.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/reporting/Reporter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/reporting/ReportingMojoSupport.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/reporting/ReportingMojoSupport.java?view=auto&rev=450613
==============================================================================
--- geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/reporting/ReportingMojoSupport.java
(added)
+++ geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/reporting/ReportingMojoSupport.java
Wed Sep 27 15:45:46 2006
@@ -0,0 +1,174 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.mavenplugins.geronimo.reporting;
+
+import org.apache.geronimo.mavenplugins.geronimo.GeronimoMojoSupport;
+
+import java.io.File;
+import java.util.Date;
+import java.util.Arrays;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+
+/**
+ * Support for Geronimo mojos which can be processed by a set of {@link Reporter}s.
+ * 
+ * @version $Rev$ $Date$
+ */
+public abstract class ReportingMojoSupport
+    extends GeronimoMojoSupport
+{
+    /**
+     * Enable logging mode.
+     *
+     * @parameter expression="${logOutput}" default-value="false"
+     */
+    protected boolean logOutput = false;
+
+    //
+    // TODO: Figure out how to inject the mojo's goal name
+    //
+
+    /**
+     * The directory where log files will be put under.
+     * 
+     * @parameter expression="${logOutputDirectory}" default-value="${project.build.directory}/geronimo-logs"
+     */
+    protected File logOutputDirectory;
+
+    /**
+     * When logOutput is enabled, the output is logged to the file location specified here.
 If this
+     * value is not present, then ${logOutputDirectory}/<goal-name>.log will be used.
+     *
+     * @parameter
+     */
+    protected File logFile = null;
+
+    /**
+     * A set of reporters which will do something interesting with the execution results.
+     *
+     * @parameter
+     */
+    protected Reporter[] reporters = null;
+
+    /**
+     * Provides hooks into the reporting interface to allow for customized reports to be
generated
+     * for goal executions.
+     */
+    public void execute() throws MojoExecutionException, MojoFailureException {
+        init();
+
+        if (log.isDebugEnabled()) {
+            log.debug("Reporters: " + Arrays.asList(reporters));
+        }
+        
+        reportBegin();
+
+        try {
+            doExecute();
+        }
+        catch(Exception e) {
+            reportError(e);
+
+            if (e instanceof MojoExecutionException) {
+                throw new MojoExecutionException(e.getMessage(), e);
+            }
+            else if (e instanceof MojoFailureException) {
+                MojoFailureException x = new MojoFailureException(e.getMessage());
+                x.initCause(e);
+                throw x;
+            }
+            else {
+                throw new MojoExecutionException(e.getMessage(), e);
+            }
+        }
+        finally {
+            reportEnd();
+        }
+    }
+
+    protected File getLogFile() {
+        if (logFile == null) {
+            return new File(logOutputDirectory, getGoalName() + ".log");
+        }
+
+        return logFile;
+    }
+
+    /**
+     * Sub-class must override to provide the goal name.
+     *
+     * @return  The name of the goal.
+     */
+    protected abstract String getGoalName();
+
+    //
+    // Reporter
+    //
+
+    private void reportBegin() {
+        if (reporters == null) {
+            return;
+        }
+
+        final Reportable source = new Reportable() {
+            final Date start = new Date();
+
+            public Date getStartTime() {
+                return start;
+            }
+
+            public String getName() {
+                return getGoalName();
+            }
+
+            public File getLogFile() {
+                return ReportingMojoSupport.this.getLogFile();
+            }
+        };
+
+        for (int i =0; i < reporters.length; i++) {
+            reporters[i].reportBegin(source);
+        }
+    }
+    
+    private void reportError(final Throwable cause) {
+        assert cause != null;
+
+        if (reporters == null) {
+            return;
+        }
+
+        for (int i=0; i < reporters.length; i++) {
+            reporters[i].reportError(cause);
+        }
+    }
+
+    private void reportEnd() {
+        if (reporters == null) {
+            return;
+        }
+
+        for (int i=0; i < reporters.length; i++) {
+            reporters[i].reportEnd();
+        }
+    }
+}

Propchange: geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/reporting/ReportingMojoSupport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/reporting/ReportingMojoSupport.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/reporting/ReportingMojoSupport.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/reporting/SurefireReporter.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/reporting/SurefireReporter.java?view=auto&rev=450613
==============================================================================
--- geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/reporting/SurefireReporter.java
(added)
+++ geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/reporting/SurefireReporter.java
Wed Sep 27 15:45:46 2006
@@ -0,0 +1,356 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.mavenplugins.geronimo.reporting;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.io.UnsupportedEncodingException;
+import java.io.FileWriter;
+import java.text.NumberFormat;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Properties;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.maven.surefire.report.ReporterException;
+import org.apache.maven.surefire.util.PrettyPrintXMLWriter;
+
+import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.StringUtils;
+import org.codehaus.plexus.util.xml.Xpp3Dom;
+import org.codehaus.plexus.util.xml.Xpp3DomWriter;
+
+/**
+ * A reporter that generates Surefire result data, so the Surefire report can be used.
+ *
+ * @version $Rev$ $Date$
+ */
+public class SurefireReporter
+    implements Reporter
+{
+    private static final Log log = LogFactory.getLog(SurefireReporter.class);
+
+    private static final String LS = System.getProperty("line.separator");
+
+    /**
+     * The name of the test (goal name).
+     */
+    private String testName;
+
+    /**
+     * The input log file, may or may not exist.
+     */
+    private File logFile;
+
+    /**
+     * The failure cause.
+     */
+    private Throwable failureCause;
+
+    /**
+     * @parameter expression="${project.build.directory}/surefire-reports"
+     */
+    private File reportsDirectory = null;
+    
+    /**
+     * The file where the test output text will be written.
+     */
+    private File outputFile;
+
+    /**
+     * The file where the text result xml will be written.
+     */
+    private File reportFile;
+
+    /**
+     * The time when the test started.
+     */
+    private long startTime;
+
+    /**
+     * The number of errors.
+     */
+    private int numErrors = 0;
+
+    private static final int MS_PER_SEC = 1000;
+
+    private NumberFormat numberFormat = NumberFormat.getInstance(Locale.ENGLISH);
+
+    private List results = Collections.synchronizedList(new ArrayList());
+
+    //
+    // Reporter
+    //
+
+    public void reportBegin(final Reportable source) {
+        assert source != null;
+
+        logFile = source.getLogFile();
+        testName = source.getName();
+        startTime = source.getStartTime().getTime();
+
+        try {
+            FileUtils.forceMkdir(reportsDirectory);
+        }
+        catch (IOException e) {
+            //
+            // HACK: Maybe need to add a throws to beginReport() ?
+            //
+            
+            log.error("Failed to make reports directory: " + reportsDirectory, e);
+        }
+
+        outputFile = new File(reportsDirectory, testName + ".txt");
+        reportFile = new File(reportsDirectory, "TEST-" + testName + ".xml");
+        if (reportFile.exists()) {
+            reportFile.delete();
+        }
+    }
+
+    public void reportError(final Throwable cause) {
+        assert cause != null;
+
+        log.debug("Capturing failed report from cause", cause);
+        
+        this.failureCause = cause;
+    }
+
+    public void reportEnd() {
+        try {
+            if (logFile.exists()) {
+                FileUtils.copyFile(logFile, outputFile);
+            }
+        }
+        catch (Exception e) {
+            log.warn("Failed to update outputFile", e);
+        }
+        
+        if (failureCause != null) {
+            try {
+                boolean append = outputFile.exists();
+                PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter(outputFile,
append)));
+                try {
+                    writer.println("Exception Detail");
+                    writer.println("================");
+                    failureCause.printStackTrace(writer);
+                    writer.flush();
+                }
+                finally {
+                    writer.close();
+                }
+            }
+            catch (Exception e) {
+                log.warn("Failed to append error detail to outputFile", e);    
+            }
+
+            testFailed();
+        }
+        else {
+            testSucceeded();
+        }
+
+        try {
+            testSetCompleted();
+        }
+        catch (ReporterException e) {
+            log.warn("Failed to set test completed", e);
+        }
+    }
+
+    //
+    // Surefire Support
+    //
+
+    private void testSetCompleted() throws ReporterException {
+        long runTime = System.currentTimeMillis() - this.startTime;
+
+        Xpp3Dom testSuite = createTestElement("testsuite", testName, runTime);
+
+        showProperties(testSuite);
+
+        testSuite.setAttribute("tests", "1");
+        testSuite.setAttribute("errors", String.valueOf(numErrors));
+        testSuite.setAttribute("skipped", "0");
+        testSuite.setAttribute("failures", "0");
+
+        for (Iterator i = results.iterator(); i.hasNext();) {
+            Xpp3Dom testcase = (Xpp3Dom) i.next();
+            testSuite.addChild(testcase);
+        }
+
+        PrintWriter writer = null;
+
+        try {
+            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(reportFile),
"UTF-8")));
+            writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" + LS);
+            Xpp3DomWriter.write(new PrettyPrintXMLWriter(writer), testSuite);
+        }
+        catch (UnsupportedEncodingException e) {
+            throw new ReporterException("Unable to use UTF-8 encoding", e);
+        }
+        catch (FileNotFoundException e) {
+            throw new ReporterException("Unable to create file: " + e.getMessage(), e);
+        }
+        finally {
+            IOUtil.close(writer);
+        }
+    }
+
+    private Xpp3Dom createTestElement(String element, String testName, long runTime) {
+        Xpp3Dom testCase = new Xpp3Dom(element);
+        testCase.setAttribute("name", testName);
+        testCase.setAttribute("time", elapsedTimeAsString(runTime));
+
+        return testCase;
+    }
+
+    private Xpp3Dom createElement(Xpp3Dom element, String testName) {
+        Xpp3Dom component = new Xpp3Dom(testName);
+        element.addChild(component);
+
+        return component;
+    }
+
+    private void testSucceeded() {
+        long runTime = System.currentTimeMillis() - this.startTime;
+        Xpp3Dom testCase = createTestElement("testcase", testName, runTime);
+        results.add(testCase);
+    }
+
+    private void testFailed() {
+        ++numErrors;
+
+        try {
+            InputStream input = new BufferedInputStream(new FileInputStream(outputFile));
+            int length = input.available();
+            byte[] b = new byte[length];
+            input.read(b, 0, length);
+            writeTestProblems(testName, new String(b));
+        }
+        catch (IOException e) {
+            log.error("Failed to write test problems", e);
+        }
+    }
+
+    private void writeTestProblems(String testName, String stdErr) {
+        long runTime = System.currentTimeMillis() - this.startTime;
+
+        Xpp3Dom testCase = createTestElement("testcase", testName, runTime);
+        Xpp3Dom element = createElement(testCase, "failure");
+
+        element.setAttribute("message", escapeAttribute(getMessage(stdErr)));
+        element.setAttribute("type", getType(stdErr));
+        element.setValue(stdErr);
+
+        results.add(testCase);
+    }
+
+    /**
+     * Adds system properties to the XML report.
+     */
+    private void showProperties(Xpp3Dom testSuite) {
+        Xpp3Dom properties = createElement(testSuite, "properties");
+
+        Properties systemProperties = System.getProperties();
+
+        if (systemProperties != null) {
+            Enumeration propertyKeys = systemProperties.propertyNames();
+
+            while (propertyKeys.hasMoreElements()) {
+                String key = (String) propertyKeys.nextElement();
+                String value = systemProperties.getProperty(key);
+
+                if (value == null) {
+                    value = "null";
+                }
+
+                Xpp3Dom property = createElement(properties, "property");
+
+                property.setAttribute("name", key);
+                property.setAttribute("value", escapeAttribute(value));
+            }
+        }
+    }
+
+    private static String escapeAttribute(String attribute) {
+        // Shouldn't Xpp3Dom do this itself?
+        String s = StringUtils.replace(attribute, "<", "&lt;");
+        return StringUtils.replace(s, ">", "&gt;");
+    }
+
+    private Iterator getResults() {
+        return results.iterator();
+    }
+
+    private String elapsedTimeAsString(long runTime) {
+        return numberFormat.format((double) runTime / MS_PER_SEC);
+    }
+
+    /**
+     * Gets the messages following the exception type.
+     */
+    private String getMessage(String stdErr) {
+        int beginMarker = stdErr.indexOf("Exception:") + 10;
+        int endMarker = stdErr.indexOf("\n", beginMarker);
+        return stdErr.substring(beginMarker, endMarker);
+    }
+
+    /**
+     * Gets the type of exception from the stacktrace.
+     */
+    private String getType(String stdErr) {
+        int endMarker = stdErr.indexOf("Exception:") + 9;
+        int beginMarker = stdErr.lastIndexOf("\n", endMarker) + 1;
+        return stdErr.substring(beginMarker, endMarker);
+    }
+
+    /** 
+     * The generated reports xml file for surefire..
+     * 
+     * @return generated reports xml file
+     */
+    public File getReportsFile() {
+        return this.reportFile;
+    }
+
+    /**
+     * The text file which holds the stdout or stderr.
+     *
+     * @return File
+     */
+    public File getOutputFile() {
+        return this.outputFile;
+    }
+}

Propchange: geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/reporting/SurefireReporter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/reporting/SurefireReporter.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/reporting/SurefireReporter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/server/InstallAssemblyMojo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/server/InstallAssemblyMojo.java?view=diff&rev=450613&r1=450612&r2=450613
==============================================================================
--- geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/server/InstallAssemblyMojo.java
(original)
+++ geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/server/InstallAssemblyMojo.java
Wed Sep 27 15:45:46 2006
@@ -32,4 +32,8 @@
     protected void doExecute() throws Exception {
         installAssembly();
     }
+
+    protected String getGoalName() {
+        return "install-assembly";
+    }
 }

Modified: geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/server/InstallerMojoSupport.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/server/InstallerMojoSupport.java?view=diff&rev=450613&r1=450612&r2=450613
==============================================================================
--- geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/server/InstallerMojoSupport.java
(original)
+++ geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/server/InstallerMojoSupport.java
Wed Sep 27 15:45:46 2006
@@ -36,8 +36,9 @@
 
 import org.apache.tools.ant.taskdefs.Expand;
 import org.apache.tools.ant.taskdefs.Chmod;
-import org.apache.geronimo.mavenplugins.geronimo.GeronimoMojoSupport;
+
 import org.apache.geronimo.mavenplugins.geronimo.AssemblyConfig;
+import org.apache.geronimo.mavenplugins.geronimo.reporting.ReportingMojoSupport;
 
 /**
  * Common assembly install support.
@@ -45,7 +46,7 @@
  * @version $Rev$ $Date$
  */
 public abstract class InstallerMojoSupport
-    extends GeronimoMojoSupport
+    extends ReportingMojoSupport
 {
     /**
      * Enable forced install refresh.

Modified: geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/server/StartServerMojo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/server/StartServerMojo.java?view=diff&rev=450613&r1=450612&r2=450613
==============================================================================
--- geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/server/StartServerMojo.java
(original)
+++ geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/server/StartServerMojo.java
Wed Sep 27 15:45:46 2006
@@ -29,6 +29,7 @@
 
 import org.apache.geronimo.genesis.ObjectHolder;
 import org.apache.geronimo.mavenplugins.geronimo.ServerProxy;
+import org.codehaus.plexus.util.FileUtils;
 
 /**
  * Start the Geronimo server.
@@ -181,6 +182,16 @@
             }
         }
         
+        if (logOutput) {
+            File file = getLogFile();
+            FileUtils.forceMkdir(file.getParentFile());
+
+            log.info("Redirecting output to: " + file);
+            
+            java.setLogError(true);
+            java.setOutput(file);
+        }
+
         // Holds any exception that was thrown during startup
         final ObjectHolder errorHolder = new ObjectHolder();
 
@@ -207,8 +218,6 @@
         // Setup a callback to time out verification
         final ObjectHolder verifyTimedOut = new ObjectHolder();
 
-        log.debug("Starting verify timeout task; triggers in: " + verifyTimeout + "s");
-
         TimerTask timeoutTask = new TimerTask() {
             public void run() {
                 verifyTimedOut.set(Boolean.TRUE);
@@ -216,6 +225,7 @@
         };
 
         if (verifyTimeout > 0) {
+            log.debug("Starting verify timeout task; triggers in: " + verifyTimeout + "s");
             timer.schedule(timeoutTask, verifyTimeout * 1000);
         }
 
@@ -253,5 +263,12 @@
 
             t.join();
         }
+    }
+
+    protected String getGoalName() {
+        //
+        //FIXME: There has to be way this can be computed instead of hardcoded absolutely.
+        //
+        return "start-server";
     }
 }

Modified: geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/server/StopServerMojo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/server/StopServerMojo.java?view=diff&rev=450613&r1=450612&r2=450613
==============================================================================
--- geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/server/StopServerMojo.java
(original)
+++ geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/server/StopServerMojo.java
Wed Sep 27 15:45:46 2006
@@ -21,8 +21,8 @@
 
 import org.apache.maven.plugin.MojoExecutionException;
 
-import org.apache.geronimo.mavenplugins.geronimo.GeronimoMojoSupport;
 import org.apache.geronimo.mavenplugins.geronimo.ServerProxy;
+import org.apache.geronimo.mavenplugins.geronimo.reporting.ReportingMojoSupport;
 
 /**
  * Stop the Geronimo server.
@@ -32,7 +32,7 @@
  * @version $Rev$ $Date$
  */
 public class StopServerMojo
-    extends GeronimoMojoSupport
+    extends ReportingMojoSupport
 {
     protected void doExecute() throws Exception {
         ServerProxy server = new ServerProxy(hostname, port, username, password);
@@ -53,5 +53,9 @@
             // TODO: Verify its down?
             //
         }
+    }
+
+    protected String getGoalName() {
+        return "stop-server";
     }
 }

Modified: geronimo/server/trunk/testsuite/deployment-testsuite/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/deployment-testsuite/pom.xml?view=diff&rev=450613&r1=450612&r2=450613
==============================================================================
--- geronimo/server/trunk/testsuite/deployment-testsuite/pom.xml (original)
+++ geronimo/server/trunk/testsuite/deployment-testsuite/pom.xml Wed Sep 27 15:45:46 2006
@@ -85,6 +85,16 @@
                         <groupId>org.apache.geronimo.plugins</groupId>
                         <artifactId>geronimo-maven-plugin</artifactId>
                         
+                        <configuration>
+                            <logOutput>true</logOutput>
+                            
+                            <reporters>
+                                <reporter implementation="org.apache.geronimo.mavenplugins.geronimo.reporting.SurefireReporter">
+                                    <reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
+                                </reporter>
+                            </reporters>
+                        </configuration>
+                        
                         <executions>
                             <execution>
                                 <id>start-server</id>



Mime
View raw message