Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[equinox-dev] EclipseStarter.searchFor() - expected JAR naming scheme

At present, EclipseStarter.searchFor() looks for JAR files given some
target name, which can be

 o the entire file name
 o the file's base name minus the ".jar" extension
 o the prefix of a base name, followed by an underscore that
   introduces a version tuple

The third one is clever and convenient, but I found that it conflicts
with Maven's preferred JAR naming scheme. Maven separates the
artifactId from the version tuple by a dash or hyphen.

With the small change attached, we could use Maven-generated artifacts
named by their artifactId and have them properly discovered.

-- 
Steven E. Harris
--- EclipseStarter.java.orig	2007-02-15 10:13:39.417750000 -0800
+++ EclipseStarter.java	2007-02-15 10:35:22.839625000 -0800
@@ -1232,20 +1232,20 @@
 			if (!name.startsWith(target))
 				continue;
 			boolean simpleJar = false;
-			if (name.length() > target.length() && name.charAt(target.length()) != '_') {
-				// make sure this is not just a jar with no _version tacked on the end
-				if (name.length() == 4 + target.length() && name.endsWith(".jar")) //$NON-NLS-1$
-					simpleJar = true;
-				else
-					// name does not match the target properly with an _version at the end
-					continue;
-			}
-			String version = ""; //$NON-NLS-1$ // Note: directory with version suffix is always > than directory without version suffix
-			int index = name.indexOf('_');
-			if (index != -1)
-				version = name.substring(index + 1);
-			Object[] currentVersion = getVersionElements(version);
-			File candidate = new File(start, candidates[i]);
+            final char sep = name.charAt(target.length());
+            if ( sep != '_' && sep != '-' ) {
+                // make sure this is not just a jar with no (_|-)version tacked on the end
+                if (name.length() == 4 + target.length() && name.endsWith(".jar")) //$NON-NLS-1$
+                    simpleJar = true;
+                else
+                    // name does not match the target properly with a (_|-)version at the end
+                    continue;
+            }
+			final String version = simpleJar ?
+                "" : //$NON-NLS-1$ // Note: directory with version suffix is always > than directory without version suffix
+                name.substring(target.length() + 1);
+			final Object[] currentVersion = getVersionElements(version);
+			final File candidate = new File(start, name);
 			if (compareVersion(maxVersion, currentVersion) < 0) {
 				result = candidate.getAbsolutePath();
 				// if simple jar; make sure it is really a file before accepting it
@@ -1253,9 +1253,8 @@
 					maxVersion = currentVersion;
 			}
 		}
-		if (result == null)
-			return null;
-		return result.replace(File.separatorChar, '/') + "/"; //$NON-NLS-1$
+		return result == null ? null :
+            result.replace(File.separatorChar, '/') + "/"; //$NON-NLS-1$
 	}
 
 	/**

Back to the top