The new plexus-utils version will not be used unless you bump the prerequisites for Maven to 2.0.6.

[EMAIL PROTECTED] wrote:
Author: vsiveton
Date: Wed Jan 30 15:36:28 2008
New Revision: 616959

URL: http://svn.apache.org/viewvc?rev=616959&view=rev
Log:
MPH-28: New goal to list platform details

o added the wanted goal
o updated the documentation

Added:
    
maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/SystemMojo.java
   (with props)
Modified:
    maven/plugins/trunk/maven-help-plugin/pom.xml
    maven/plugins/trunk/maven-help-plugin/src/site/apt/index.apt
    maven/plugins/trunk/maven-help-plugin/src/site/apt/usage.apt

Modified: maven/plugins/trunk/maven-help-plugin/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-help-plugin/pom.xml?rev=616959&r1=616958&r2=616959&view=diff
==============================================================================
--- maven/plugins/trunk/maven-help-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-help-plugin/pom.xml Wed Jan 30 15:36:28 2008
@@ -88,6 +88,11 @@
       <artifactId>plexus-container-default</artifactId>
       <version>1.0-alpha-9</version>
     </dependency>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-utils</artifactId>
+      <version>1.4.5</version>
+    </dependency>
   </dependencies>
   <reporting>
     <plugins>

Added: 
maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/SystemMojo.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/SystemMojo.java?rev=616959&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/SystemMojo.java
 (added)
+++ 
maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/SystemMojo.java
 Wed Jan 30 15:36:28 2008
@@ -0,0 +1,157 @@
+package org.apache.maven.plugins.help;
+
+/*
+ * 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.
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.Properties;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.codehaus.plexus.util.WriterFactory;
+import org.codehaus.plexus.util.cli.CommandLineUtils;
+
+/**
+ * Lists the platform details like system properties and environment variables.
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Vincent Siveton</a>
+ * @version $Id$
+ * @since 2.1
+ * @goal system
+ */
+public class SystemMojo
+    extends AbstractMojo
+{
+    /**
+     * Optional parameter for a file destination for the output of this mojo.
+     *
+     * @parameter expression="${output}"
+     */
+    private File output;
+
+    /** [EMAIL PROTECTED] */
+    public void execute()
+        throws MojoExecutionException
+    {
+        StringBuffer message = new StringBuffer();
+
+        message.append( "===== Platform Details =====" ).append( '\n' );
+        message.append( '\n' );
+        message.append( "===== System Properties =====" ).append( '\n' );
+
+        Properties systemProperties = System.getProperties();
+        for ( Iterator it = systemProperties.keySet().iterator(); 
it.hasNext(); )
+        {
+            String key = it.next().toString();
+            message.append( "\n" );
+            message.append( key ).append( "=" ).append( systemProperties.get( 
key ) );
+        }
+
+        message.append( '\n' ).append( '\n' );
+        message.append( "===== Environment Variables =====" ).append( '\n' );
+        try
+        {
+            Properties envVars = CommandLineUtils.getSystemEnvVars();
+            for ( Iterator it2 = envVars.keySet().iterator(); it2.hasNext(); )
+            {
+                String key = it2.next().toString();
+                message.append( "\n" );
+                message.append( key ).append( "=" ).append( envVars.get( key ) 
);
+            }
+        }
+        catch ( IOException e )
+        {
+            if ( getLog().isWarnEnabled() )
+            {
+                getLog().warn( "IOException: " + e.getMessage() );
+            }
+        }
+
+        message.append( "\n" );
+
+        if ( output != null )
+        {
+            writeFile( message );
+        }
+        else
+        {
+            if ( getLog().isInfoEnabled() )
+            {
+                getLog().info( message );
+            }
+        }
+    }
+
+    /**
+     * Method for writing the output file of the active profiles information.
+     *
+     * @param message the output to be written to the file
+     * @throws MojoExecutionException if any
+     */
+    private void writeFile( StringBuffer message )
+        throws MojoExecutionException
+    {
+        Writer writer = null;
+        try
+        {
+            File dir = output.getParentFile();
+            if ( !dir.exists() )
+            {
+                dir.mkdirs();
+            }
+
+            writer = WriterFactory.newPlatformWriter( output );
+
+            writer.write( "Created by: " + getClass().getName() + "\n" );
+            writer.write( "Created on: " + new Date() + "\n\n" );
+            writer.write( message.toString() );
+            writer.flush();
+
+            if ( getLog().isInfoEnabled() )
+            {
+                getLog().info( "System report written to: " + output );
+            }
+        }
+        catch ( IOException e )
+        {
+            throw new MojoExecutionException( "Cannot write output to file: " 
+ output, e );
+        }
+        finally
+        {
+            if ( writer != null )
+            {
+                try
+                {
+                    writer.close();
+                }
+                catch ( IOException e )
+                {
+                    if ( getLog().isDebugEnabled() )
+                    {
+                        getLog().debug( "Failed to close output file writer.", 
e );
+                    }
+                }
+            }
+        }
+    }
+}

Propchange: 
maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/SystemMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/SystemMojo.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Modified: maven/plugins/trunk/maven-help-plugin/src/site/apt/index.apt
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-help-plugin/src/site/apt/index.apt?rev=616959&r1=616958&r2=616959&view=diff
==============================================================================
--- maven/plugins/trunk/maven-help-plugin/src/site/apt/index.apt (original)
+++ maven/plugins/trunk/maven-help-plugin/src/site/apt/index.apt Wed Jan 30 
15:36:28 2008
@@ -3,7 +3,7 @@
  ------
  Maria Odea Ching
  ------
- 7 July 2006
+ January 2008
  ------
~~ Licensed to the Apache Software Foundation (ASF) under one
@@ -25,7 +25,7 @@
Maven 2 Help Plugin - The Maven 2 Help Plugin is used to get relative information about a project. It can be used to get a description
+ The Maven 2 Help Plugin is used to get relative information about a project 
or the system. It can be used to get a description
  of a particular plugin, including the plugin's mojos with their parameters 
and component requirements, the effective pom
  and effective settings of the current build, and the profiles applied to the 
current project being built.
@@ -44,6 +44,8 @@
   * {{{effective-settings-mojo.html}help:effective-settings}} prints out the 
calculated settings for the project, given any
     profile enhancement and the inheritance of the global settings into the 
user-level settings.
+ * {{{system-mojo.html}help:system}} displays the platform details like system properties and environment variables.
+
 * Usage
Instructions on how to use the Help Plugin can be found {{{usage.html}here}}.
@@ -54,6 +56,3 @@
    following example(s):
* {{{examples/describe-configuration.html}Configuring Describe Mojo}}
-
-
-

Modified: maven/plugins/trunk/maven-help-plugin/src/site/apt/usage.apt
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-help-plugin/src/site/apt/usage.apt?rev=616959&r1=616958&r2=616959&view=diff
==============================================================================
--- maven/plugins/trunk/maven-help-plugin/src/site/apt/usage.apt (original)
+++ maven/plugins/trunk/maven-help-plugin/src/site/apt/usage.apt Wed Jan 30 
15:36:28 2008
@@ -4,7 +4,7 @@
  John Casey
  Maria Odea Ching
  ------
- 10 July 2006
+ January 2008
  ------
~~ Licensed to the Apache Software Foundation (ASF) under one
@@ -60,7 +60,7 @@
 mvn help:describe -Dplugin=org.somewhere:some-plugin:0.0.0
 +-----+
- Here is an example with the <<<mojo>>> parameter specified: + Here is an example with the <<<mojo>>> parameter specified: +-----+
 mvn help:describe -Dplugin=org.apache.maven.plugins:maven-help-plugin 
-Dmojo=describe
@@ -93,6 +93,15 @@
 mvn help:effective-settings
 +-----+
+* The <<<help:system>>> Mojo
+
+  The <<<system>>> mojo is used to view the system informations like system 
properties and environment variables.
+
+  The mojo can be executed using the following command:
+
++-----+
+mvn help:system
++-----+
* Redirecting output to a file




--
Dennis Lundberg

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to