Author: fgiust
Date: Wed Oct 18 06:54:20 2006
New Revision: 465250

URL: http://svn.apache.org/viewvc?view=rev&rev=465250
Log:
sort dependencies when writing an Osgi Manifest (note that there is still an 
open issue for sorting also in other configuration files, MECLIPSE-152 but at 
this moment the modification to manifest only look safer...)

Modified:
    
maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseOSGiManifestWriter.java
    
maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/ide/IdeDependency.java

Modified: 
maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseOSGiManifestWriter.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseOSGiManifestWriter.java?view=diff&rev=465250&r1=465249&r2=465250
==============================================================================
--- 
maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseOSGiManifestWriter.java
 (original)
+++ 
maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseOSGiManifestWriter.java
 Wed Oct 18 06:54:20 2006
@@ -21,6 +21,7 @@
 import java.io.FileReader;
 import java.io.FileWriter;
 import java.io.IOException;
+import java.util.Arrays;
 
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.eclipse.Messages;
@@ -214,10 +215,9 @@
 
     /**
      * Add all libraries that don't have the scope "provided" to the 
"Bundle-Classpath".
-     * @throws MojoExecutionException 
+     * @return complete "Bundle-ClassPath:" entry for manifest 
      */
     protected String addBundleClasspathEntries()
-        throws MojoExecutionException
     {
         StringBuffer bundleClasspathSb = new StringBuffer( 
ENTRY_BUNDLE_CLASSPATH );
 
@@ -225,9 +225,15 @@
         // @todo handle expanded plugins
         bundleClasspathSb.append( " ." );
 
-        for ( int j = 0; j < config.getDeps().length; j++ )
+        IdeDependency[] deps = config.getDeps();
+
+        // since Manifest is supposed to be in SVN, having the order of 
classpath entries shuffled at each run is very
+        // annoying. For now just sort them by using groupId/artifactId
+        Arrays.sort( deps );
+
+        for ( int j = 0; j < deps.length; j++ )
         {
-            IdeDependency dep = config.getDeps()[j];
+            IdeDependency dep = deps[j];
             if ( !dep.isProvided() && !dep.isReferencedProject() && 
!dep.isTestDependency() )
             {
                 bundleClasspathSb.append( "," + NEWLINE );

Modified: 
maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/ide/IdeDependency.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/ide/IdeDependency.java?view=diff&rev=465250&r1=465249&r2=465250
==============================================================================
--- 
maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/ide/IdeDependency.java
 (original)
+++ 
maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/ide/IdeDependency.java
 Wed Oct 18 06:54:20 2006
@@ -23,6 +23,7 @@
  * @version $Id$
  */
 public class IdeDependency
+    implements Comparable
 {
     /**
      * Is this dependency available in the reactor?
@@ -349,6 +350,32 @@
     public String toString()
     {
         return getId();
+    }
+
+    /**
+     * @see java.lang.Comparable#compareTo(java.lang.Object)
+     * Compare using groupId+artifactId+type Strings
+     */
+    public int compareTo( Object o )
+    {
+        IdeDependency dep = (IdeDependency) o;
+        int equals = this.getGroupId().compareTo( dep.getGroupId() );
+        if ( equals != 0 )
+        {
+            return equals;
+        }
+        equals = this.getArtifactId().compareTo( dep.getArtifactId() );
+        if ( equals != 0 )
+        {
+            return equals;
+        }
+        equals = this.getType().compareTo( dep.getType() );
+        if ( equals != 0 )
+        {
+            return equals;
+        }
+
+        return 0;
     }
 
 }


Reply via email to