diff options
author | Jose <jose@zeroc.com> | 2015-02-02 16:37:08 +0100 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2015-02-02 16:37:08 +0100 |
commit | 1e97cdd74016a72909a4275ee53dcb5bf7ea68c0 (patch) | |
tree | c3f55bcce33c96eaea16f4f14b849b9b4dd4a595 /eclipse/java/Slice2javaPlugin | |
parent | Fixed bug which could cause Ice::NullHandleException in IceGrid replication (diff) | |
download | ice-1e97cdd74016a72909a4275ee53dcb5bf7ea68c0.tar.bz2 ice-1e97cdd74016a72909a4275ee53dcb5bf7ea68c0.tar.xz ice-1e97cdd74016a72909a4275ee53dcb5bf7ea68c0.zip |
Fixed (ICE-6235) - Update eclipse to support new JAR names
Diffstat (limited to 'eclipse/java/Slice2javaPlugin')
5 files changed, 172 insertions, 69 deletions
diff --git a/eclipse/java/Slice2javaPlugin/META-INF/MANIFEST.MF b/eclipse/java/Slice2javaPlugin/META-INF/MANIFEST.MF index 44bd3f77923..1347214dea9 100644 --- a/eclipse/java/Slice2javaPlugin/META-INF/MANIFEST.MF +++ b/eclipse/java/Slice2javaPlugin/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name.0 Bundle-SymbolicName: com.zeroc.Slice2JavaPlugin;singleton:=true -Bundle-Version: 3.5.1.qualifier +Bundle-Version: 3.6.0.qualifier Bundle-Activator: com.zeroc.slice2javaplugin.Activator Bundle-Vendor: %Bundle-Vendor.0 Require-Bundle: org.eclipse.ui, diff --git a/eclipse/java/Slice2javaPlugin/src/com/zeroc/slice2javaplugin/internal/Configuration.java b/eclipse/java/Slice2javaPlugin/src/com/zeroc/slice2javaplugin/internal/Configuration.java index 15dd2ad979e..7ff1be49682 100644 --- a/eclipse/java/Slice2javaPlugin/src/com/zeroc/slice2javaplugin/internal/Configuration.java +++ b/eclipse/java/Slice2javaPlugin/src/com/zeroc/slice2javaplugin/internal/Configuration.java @@ -70,7 +70,7 @@ public class Configuration _store.setDefault(ADD_JARS_KEY, true); _store.setDefault(UNDERSCORE_KEY, false); - _store.setDefault(JARS_KEY, "Ice.jar"); + _store.setDefault(JARS_KEY, getJarName("Ice")); } /** @@ -230,12 +230,12 @@ public class Configuration IJavaProject javaProject = JavaCore.create(_project); if(isAndroidProject()) { - removeLibrary(javaProject, "Ice.jar"); - removeLibrary(javaProject, "Glacier2.jar"); - removeLibrary(javaProject, "IceBox.jar"); - removeLibrary(javaProject, "IceGrid.jar"); - removeLibrary(javaProject, "IcePatch2.jar"); - removeLibrary(javaProject, "IceStorm.jar"); + removeLibrary(javaProject, getJarName("Ice")); + removeLibrary(javaProject, getJarName("Glacier2")); + removeLibrary(javaProject, getJarName("IceBox")); + removeLibrary(javaProject, getJarName("IceGrid")); + removeLibrary(javaProject, getJarName("IcePatch2")); + removeLibrary(javaProject, getJarName("IceStorm")); } else { @@ -248,6 +248,29 @@ public class Configuration generatedFolder.delete(true, null); } } + + public String getJarName(String base) + { + String version = getIceVersion(); + + int intVersion = 306; + if(version != null) + { + String tokens[] = version.split(java.util.regex.Pattern.quote(".")); + if(tokens.length >= 2) + { + intVersion = (Integer.parseInt(tokens[0]) * 100) + + Integer.parseInt(tokens[1]); + } + } + + if(intVersion >= 306) + { + base = base.toLowerCase() + "-" + version; + } + + return base + ".jar"; + } public boolean isAndroidProject() { @@ -448,26 +471,24 @@ public class Configuration List<String> s = toList(_store.getString(INCLUDES_KEY)); String iceHome = getIceHome(); - String os = System.getProperty("os.name"); String path = null; - if(os.equals("Linux") && iceHome.equals("/usr")) + if(!System.getProperty("os.name").startsWith("Windows") && + (iceHome.equals("/usr") || iceHome.equals("/usr/local"))) { String version = getIceVersion(); if(version != null) { - File f = new File("/usr/share/Ice-" + version + "/slice"); + File f = new File(iceHome + "/share/Ice-" + version + "/slice"); if(f.exists()) { path = f.toString(); } } } - if(path == null) { path = new File(iceHome + File.separator + "slice").toString(); } - s.add(path); return s; } @@ -516,11 +537,11 @@ public class Configuration { IJavaProject javaProject = JavaCore.create(_project); ArrayList<String> removeJars = new ArrayList<String>(); - removeJars.add("Glacier2.jar"); - removeJars.add("IceBox.jar"); - removeJars.add("IceGrid.jar"); - removeJars.add("IcePatch2.jar"); - removeJars.add("IceStorm.jar"); + removeJars.add(getJarName("Ice")); + removeJars.add(getJarName("IceBox")); + removeJars.add(getJarName("IceGrid")); + removeJars.add(getJarName("IcePatch2")); + removeJars.add(getJarName("IceStorm")); for(String jar : jars) { @@ -693,7 +714,30 @@ public class Configuration public static void setupSharedLibraryPath(Map<String, String> env) { String iceHome = getIceHome(); - + String os = System.getProperty("os.name"); + + if(iceHome.equals("/usr") && os.equals("Linux")) + { + return; + } + + String lib32Subdir = "lib"; + String lib64Subdir = "lib64"; + if(os.equals("Linux")) + { + if(new File("/usr/lib/i386-linux-gnu").exists()) + { + lib32Subdir = "lib" + File.separator + "i386-linux-gnu"; + } + + if(new File("/usr/lib/x86_64-linux-gnu").exists()) + { + lib64Subdir = "lib" + File.separator + "x86_64-linux-gnu"; + } + } + + + String libPath; boolean srcdist = false; if(new File(iceHome + File.separator + "cpp" + File.separator + "bin").exists()) @@ -704,14 +748,13 @@ public class Configuration } else { - libPath = new File(iceHome + File.separator + "lib").toString(); + libPath = new File(iceHome + File.separator + lib32Subdir).toString(); } String ldLibPathEnv = null; String ldLib64PathEnv = null; String lib64Path = null; - - String os = System.getProperty("os.name"); + if(os.equals("Mac OS X")) { ldLibPathEnv = "DYLD_LIBRARY_PATH"; @@ -771,7 +814,7 @@ public class Configuration } else { - lib64Path = new File(iceHome + File.separator + "lib64").toString(); + lib64Path = new File(iceHome + File.separator + lib64Subdir).toString(); } } @@ -816,7 +859,8 @@ public class Configuration { String iceHome = getIceHome(); String os = System.getProperty("os.name"); - if(os.equals("Linux") && iceHome.equals("/usr")) + if(!System.getProperty("os.name").startsWith("Windows") && + (iceHome.equals("/usr") || iceHome.equals("/usr/local"))) { File f = new File(iceHome + File.separator + "share" + File.separator + "java"); if(f.exists()) @@ -881,31 +925,36 @@ public class Configuration // Obtain the Ice version by executing the translator with the -v option. private String getIceVersion() { - String version = null; - String exec = getTranslatorForHome(getIceHome()); - if(exec != null) + String iceHome = getIceHome(); + if(_version == null || !iceHome.equals(_iceHome)) { - try + _version = null; + String exec = getTranslatorForHome(getIceHome()); + if(exec != null) { - ProcessBuilder b = new ProcessBuilder(exec, "-v"); - b.redirectErrorStream(true); - Map<String, String> env = b.environment(); - setupSharedLibraryPath(env); - Process p = b.start(); - int status = p.waitFor(); - if(status == 0) + try { - BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream())); - String line = r.readLine(); - version = line.trim(); + ProcessBuilder b = new ProcessBuilder(exec, "-v"); + b.redirectErrorStream(true); + Map<String, String> env = b.environment(); + setupSharedLibraryPath(env); + Process p = b.start(); + int status = p.waitFor(); + if(status == 0) + { + BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream())); + String line = r.readLine(); + _version = line.trim(); + _iceHome = iceHome; + } + } + catch(Throwable ex) + { + // Ignore. } - } - catch(Throwable ex) - { - // Ignore. } } - return version; + return _version; } private static String getTranslatorForHome(String dir) @@ -921,6 +970,15 @@ public class Configuration { return f.toString(); } + if(os.startsWith("Windows")) + { + f = new File(dir + File.separator + "bin" + File.separator + + "x64" + File.separator + "slice2java" + suffix); + if(f.exists()) + { + return f.toString(); + } + } f = new File(dir + File.separator + "cpp" + File.separator + "bin" + File.separator + "slice2java" + suffix); if(f.exists()) { @@ -939,8 +997,8 @@ public class Configuration } else { - cpEntry = JavaCore.newVariableEntry(new Path("ICE_JAR_HOME/Ice.jar"), - new Path("ICE_JAR_HOME/Ice.jar"), + final String iceJarPath = "ICE_JAR_HOME/" + getJarName("Ice"); + cpEntry = JavaCore.newVariableEntry(new Path(iceJarPath), new Path(iceJarPath), new Path("ICE_JAR_HOME/lib/"), true); } @@ -1134,4 +1192,7 @@ public class Configuration private IProject _project; private boolean _androidProject; + + private static String _version = null; + private static String _iceHome = null; } diff --git a/eclipse/java/Slice2javaPlugin/src/com/zeroc/slice2javaplugin/internal/IceClasspathContainerIntializer.java b/eclipse/java/Slice2javaPlugin/src/com/zeroc/slice2javaplugin/internal/IceClasspathContainerIntializer.java index 86b89967330..9c64c8abfae 100644 --- a/eclipse/java/Slice2javaPlugin/src/com/zeroc/slice2javaplugin/internal/IceClasspathContainerIntializer.java +++ b/eclipse/java/Slice2javaPlugin/src/com/zeroc/slice2javaplugin/internal/IceClasspathContainerIntializer.java @@ -55,6 +55,40 @@ public class IceClasspathContainerIntializer extends ClasspathContainerInitializ configure(c, javaProject, containerPath); } + + private static String componentName(String jar) + { + String[] jars = new String[]{"Ice.jar", "Glacier2.jar", "IceBox.jar", "IceStorm.jar", "IceGrid.jar"}; + for(String f : jars) + { + if(f.equals(jar)) + { + return jar.replace(".jar", ""); + } + } + + if(jar.matches("ice-.*")) + { + return "Ice"; + } + else if(jar.matches("glacier2-.*")) + { + return "Glacier2"; + } + else if(jar.matches("icebox-.*")) + { + return "IceBox"; + } + else if(jar.matches("icestorm-.*")) + { + return "IceStorm"; + } + else if(jar.matches("icegrid-.*")) + { + return "IceGrid"; + } + return null; + } private static void configure(Configuration c, IJavaProject javaProject, IPath containerPath) throws JavaModelException @@ -65,7 +99,7 @@ public class IceClasspathContainerIntializer extends ClasspathContainerInitializ List<IClasspathEntry> entries = new ArrayList<IClasspathEntry>(); for(String jar : c.getJars()) { - IPath path = dir.append(new Path(jar)); + IPath path = dir.append(new Path(c.getJarName(componentName(jar)))); IClasspathEntry classpathEntry = JavaCore.newLibraryEntry(path, null, null, new IAccessRule[0], new IClasspathAttribute[0], false); entries.add(classpathEntry); } diff --git a/eclipse/java/Slice2javaPlugin/src/com/zeroc/slice2javaplugin/preferences/PreferenceInitializer.java b/eclipse/java/Slice2javaPlugin/src/com/zeroc/slice2javaplugin/preferences/PreferenceInitializer.java index 335b9703b25..10e66e7dccc 100644 --- a/eclipse/java/Slice2javaPlugin/src/com/zeroc/slice2javaplugin/preferences/PreferenceInitializer.java +++ b/eclipse/java/Slice2javaPlugin/src/com/zeroc/slice2javaplugin/preferences/PreferenceInitializer.java @@ -27,23 +27,31 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer String os = System.getProperty("os.name"); //$NON-NLS-1$ if(os.startsWith("Windows")) //$NON-NLS-1$ { - File f = new File("C:\\Program Files\\ZeroC\\Ice-" + Messages.IceStringVersion); - if(!f.exists()) + final String[] defaultLocations = new String[]{ + "C:\\Program Files\\ZeroC\\Ice-" + Messages.IceStringVersion, + "C:\\Program Files (x86)\\ZeroC\\Ice-" + Messages.IceStringVersion, + "C:\\Ice-" + Messages.IceStringVersion}; + for(String s : defaultLocations) { - File f2 = new File("C:\\Program Files (x86)\\ZeroC\\Ice-" + Messages.IceStringVersion); - if(f2.exists()) + if(new File(s).exists()) { - return f2.toString(); + return s; } } - return f.toString(); } - if(os.equals("Linux")) //$NON-NLS-1$ + else { - File f = new File("/usr/bin/slice2java"); //$NON-NLS-1$ - if(f.exists()) + final String[] defaultLocations = new String[]{ + "/usr/bin/slice2java", + "/usr/local/bin/slice2java", + "/opt/Ice-" + Messages.IceStringVersion + "/bin/slice2java"}; + + for(String s : defaultLocations) { - return "/usr"; //$NON-NLS-1$ + if(new File(s).exists()) + { + return s.replace("/bin/slice2java", ""); + } } } return "/opt/Ice-" + Messages.IceStringVersion; //$NON-NLS-1$ diff --git a/eclipse/java/Slice2javaPlugin/src/com/zeroc/slice2javaplugin/properties/ProjectProperties.java b/eclipse/java/Slice2javaPlugin/src/com/zeroc/slice2javaplugin/properties/ProjectProperties.java index cdd5281b64d..00a6dc40b42 100644 --- a/eclipse/java/Slice2javaPlugin/src/com/zeroc/slice2javaplugin/properties/ProjectProperties.java +++ b/eclipse/java/Slice2javaPlugin/src/com/zeroc/slice2javaplugin/properties/ProjectProperties.java @@ -80,30 +80,30 @@ public class ProjectProperties extends PropertyPage if(_config.getAddJars()) { java.util.List<String> jars = new ArrayList<String>(); - jars.add("Ice.jar"); + jars.add(_config.getJarName("Ice")); if(_freezeJar.getSelection()) { - jars.add("Freeze.jar"); + jars.add(_config.getJarName("Freeze")); } if(_glacier2Jar.getSelection()) { - jars.add("Glacier2.jar"); + jars.add(_config.getJarName("Glacier2")); } if(_iceBoxJar.getSelection()) { - jars.add("IceBox.jar"); + jars.add(_config.getJarName("IceBox")); } if(_iceStormJar.getSelection()) { - jars.add("IceStorm.jar"); + jars.add(_config.getJarName("IceStorm")); } if(_iceGridJar.getSelection()) { - jars.add("IceGrid.jar"); + jars.add(_config.getJarName("IceGrid")); } if(_icePatch2Jar.getSelection()) { - jars.add("IcePatch2.jar"); + jars.add(_config.getJarName("IcePatch2")); } _config.setJars(jars); } @@ -219,27 +219,27 @@ public class ProjectProperties extends PropertyPage for(Iterator<String> iter = _config.getJars().iterator(); iter.hasNext();) { String jarFile = iter.next(); - if(jarFile.equals("Freeze.jar")) + if(jarFile.equals(_config.getJarName("Freeze"))) { _freezeJar.setSelection(true); } - else if(jarFile.equals("Glacier2.jar")) + else if(jarFile.equals(_config.getJarName("Glacier2"))) { _glacier2Jar.setSelection(true); } - else if(jarFile.equals("IceBox.jar")) + else if(jarFile.equals(_config.getJarName("IceBox"))) { _iceBoxJar.setSelection(true); } - else if(jarFile.equals("IceGrid.jar")) + else if(jarFile.equals(_config.getJarName("IceGrid"))) { _iceGridJar.setSelection(true); } - else if(jarFile.equals("IcePatch2.jar")) + else if(jarFile.equals(_config.getJarName("IcePatch2"))) { _icePatch2Jar.equals(true); } - else if(jarFile.equals("IceStorm.jar")) + else if(jarFile.equals(_config.getJarName("IceStorm"))) { _iceStormJar.setSelection(true); } |