This is an automated email from the ASF dual-hosted git repository.

hboutemy pushed a commit to annotated tag maven-help-plugin-2.0
in repository https://gitbox.apache.org/repos/asf/maven-help-plugin.git

commit 0044a79bd5bb9c19a85d6250312402aa157cdb70
Author: John Dennis Casey <jdca...@apache.org>
AuthorDate: Tue Jun 14 15:26:43 2005 +0000

    Added projecthelp:effective-settings mojo
    
    git-svn-id: 
https://svn.apache.org/repos/asf/maven/components/trunk/maven-plugins/maven-projecthelp-plugin@190615
 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                            |   5 +
 .../plugins/projecthelp/EffectiveSettingsMojo.java | 118 +++++++++++++++++++++
 2 files changed, 123 insertions(+)

diff --git a/pom.xml b/pom.xml
index bbf7525..3e23745 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,6 +23,11 @@
     </dependency>
     <dependency>
       <groupId>org.apache.maven</groupId>
+      <artifactId>maven-settings</artifactId>
+      <version>2.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
       <artifactId>maven-project</artifactId>
       <version>2.0-SNAPSHOT</version>
     </dependency>
diff --git 
a/src/main/java/org/apache/maven/plugins/projecthelp/EffectiveSettingsMojo.java 
b/src/main/java/org/apache/maven/plugins/projecthelp/EffectiveSettingsMojo.java
new file mode 100644
index 0000000..e247165
--- /dev/null
+++ 
b/src/main/java/org/apache/maven/plugins/projecthelp/EffectiveSettingsMojo.java
@@ -0,0 +1,118 @@
+package org.apache.maven.plugins.projecthelp;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.settings.Settings;
+import org.apache.maven.settings.io.xpp3.SettingsXpp3Writer;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.StringWriter;
+
+/*
+ * Copyright 2001-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.
+ */
+
+/** Print out the calculated settings for this project, given any profile 
enhancement and 
+ *  the inheritance of the global settings into the user-level settings.
+ *  
+ * @goal effective-settings
+ * 
+ */
+public class EffectiveSettingsMojo
+    extends AbstractMojo
+{
+
+    /**
+     * @parameter expression="${settings}"
+     * @readonly
+     * @required
+     */
+    private Settings settings;
+
+    /**
+     * @parameter
+     */
+    private String output;
+
+    public void execute()
+        throws MojoExecutionException
+    {
+        StringWriter sWriter = new StringWriter();
+
+        SettingsXpp3Writer settingsWriter = new SettingsXpp3Writer();
+
+        try
+        {
+            settingsWriter.write( sWriter, settings );
+        }
+        catch ( IOException e )
+        {
+            throw new MojoExecutionException( "Cannot serialize POM to XML.", 
e );
+        }
+
+        if ( output != null && output.trim().length() > 0 )
+        {
+            FileWriter fWriter = null;
+            try
+            {
+                File outFile = new File( output ).getAbsoluteFile();
+
+                File dir = outFile.getParentFile();
+
+                if ( !dir.exists() )
+                {
+                    dir.mkdirs();
+                }
+
+                getLog().info( "Writing effective-settings to: " + outFile );
+
+                fWriter = new FileWriter( outFile );
+
+                fWriter.write( sWriter.toString() );
+            }
+            catch ( IOException e )
+            {
+                throw new MojoExecutionException( "Cannot write 
effective-settings to output: " + output, e );
+            }
+            finally
+            {
+                if ( fWriter != null )
+                {
+                    try
+                    {
+                        fWriter.close();
+                    }
+                    catch ( IOException e )
+                    {
+                        getLog().debug( "Cannot close FileWriter to output 
location: " + output, e );
+                    }
+                }
+            }
+        }
+        else
+        {
+            StringBuffer message = new StringBuffer();
+
+            message.append( "\nEffective settings:\n\n" );
+            message.append( sWriter.toString() );
+            message.append( "\n\n" );
+
+            getLog().info( message );
+        }
+    }
+
+}

-- 
To stop receiving notification emails like this one, please contact
"commits@maven.apache.org" <commits@maven.apache.org>.

Reply via email to