You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by vs...@apache.org on 2008/08/24 13:11:02 UTC
svn commit: r688495 - in
/maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help:
AbstractEffectiveMojo.java EffectivePomMojo.java EffectiveSettingsMojo.java
Author: vsiveton
Date: Sun Aug 24 04:11:01 2008
New Revision: 688495
URL: http://svn.apache.org/viewvc?rev=688495&view=rev
Log:
MPH-37: help:effective-pom - sort the properties list
o using a SortedProperties class
o sorted pom.properties and settings.profiles.properties
Modified:
maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/AbstractEffectiveMojo.java
maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/EffectivePomMojo.java
maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/EffectiveSettingsMojo.java
Modified: maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/AbstractEffectiveMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/AbstractEffectiveMojo.java?rev=688495&r1=688494&r2=688495&view=diff
==============================================================================
--- maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/AbstractEffectiveMojo.java (original)
+++ maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/AbstractEffectiveMojo.java Sun Aug 24 04:11:01 2008
@@ -24,9 +24,14 @@
import java.io.StringWriter;
import java.io.Writer;
import java.text.DateFormat;
+import java.util.Collections;
import java.util.Date;
import java.util.Iterator;
+import java.util.LinkedHashSet;
import java.util.Locale;
+import java.util.Properties;
+import java.util.Set;
+import java.util.Vector;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.StringUtils;
@@ -188,4 +193,23 @@
return effectiveXml;
}
}
+
+ /**
+ * Properties which provides a sorted keySet().
+ */
+ protected static class SortedProperties
+ extends Properties
+ {
+ static final long serialVersionUID = -8985316072702233744L;
+
+ /** {@inheritDoc} */
+ public Set keySet()
+ {
+ Set keynames = super.keySet();
+ Vector list = new Vector( keynames );
+ Collections.sort( list );
+
+ return new LinkedHashSet( list );
+ }
+ }
}
Modified: maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/EffectivePomMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/EffectivePomMojo.java?rev=688495&r1=688494&r2=688495&view=diff
==============================================================================
--- maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/EffectivePomMojo.java (original)
+++ maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/EffectivePomMojo.java Sun Aug 24 04:11:01 2008
@@ -24,6 +24,7 @@
import java.io.StringWriter;
import java.util.Iterator;
import java.util.List;
+import java.util.Properties;
import org.apache.maven.model.Model;
import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
@@ -158,6 +159,8 @@
throws MojoExecutionException
{
Model pom = project.getModel();
+ cleanModel( pom );
+
String effectivePom;
StringWriter sWriter = new StringWriter();
@@ -179,6 +182,18 @@
}
/**
+ * Apply some logic to clean the model before writing it.
+ *
+ * @param pom not null
+ */
+ private static void cleanModel( Model pom )
+ {
+ Properties properties = new SortedProperties();
+ properties.putAll( pom.getProperties() );
+ pom.setProperties( properties );
+ }
+
+ /**
* @param effectivePom not null
* @return pretty format of the xml or the original <code>effectivePom</code> if an error occurred.
*/
Modified: maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/EffectiveSettingsMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/EffectiveSettingsMojo.java?rev=688495&r1=688494&r2=688495&view=diff
==============================================================================
--- maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/EffectiveSettingsMojo.java (original)
+++ maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/EffectiveSettingsMojo.java Sun Aug 24 04:11:01 2008
@@ -24,8 +24,10 @@
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Iterator;
+import java.util.Properties;
import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.settings.Profile;
import org.apache.maven.settings.Proxy;
import org.apache.maven.settings.Server;
import org.apache.maven.settings.Settings;
@@ -202,6 +204,8 @@
private static void writeEffectiveSettings( Settings settings, XMLWriter writer )
throws MojoExecutionException
{
+ cleanSettings( settings );
+
String effectiveSettings;
StringWriter sWriter = new StringWriter();
@@ -223,6 +227,23 @@
}
/**
+ * Apply some logic to clean the model before writing it.
+ *
+ * @param settings not null
+ */
+ private static void cleanSettings( Settings settings )
+ {
+ for ( Iterator it = settings.getProfiles().iterator(); it.hasNext(); )
+ {
+ Profile profile = (Profile) it.next();
+
+ Properties properties = new SortedProperties();
+ properties.putAll( profile.getProperties() );
+ profile.setProperties( properties );
+ }
+ }
+
+ /**
* @return the current host name or <code>unknown</code> if error
* @see InetAddress#getLocalHost()
*/