1 11 package org.eclipse.pde.internal.build.builder; 12 13 import java.io.IOException ; 14 import java.io.InputStream ; 15 import java.net.MalformedURLException ; 16 import java.net.URL ; 17 import java.util.Properties ; 18 import org.eclipse.core.runtime.*; 19 import org.eclipse.osgi.util.NLS; 20 import org.eclipse.pde.internal.build.*; 21 22 public class DevClassPathHelper { 23 protected boolean inDevelopmentMode = false; 24 protected String [] devDefaultClasspath; 25 protected Properties devProperties = null; 26 27 public DevClassPathHelper(String devInfo) { 28 String osgiDev = devInfo; 30 if (osgiDev != null) { 31 try { 32 inDevelopmentMode = true; 33 URL location = new URL (osgiDev); 34 devProperties = load(location); 35 devDefaultClasspath = Utils.getArrayFromString(devProperties.getProperty("*")); } catch (MalformedURLException e) { 37 devDefaultClasspath = Utils.getArrayFromString(osgiDev); 38 } 39 } 40 } 41 42 public String [] getDevClassPath(String id) { 43 String [] result = null; 44 if (id != null && devProperties != null) { 45 String entry = devProperties.getProperty(id); 46 if (entry != null) 47 result = Utils.getArrayFromString(entry); 48 } 49 if (result == null) 50 result = devDefaultClasspath; 51 return result; 52 } 53 54 public boolean inDevelopmentMode() { 55 return inDevelopmentMode; 56 } 57 58 61 private static Properties load(URL url) { 62 Properties props = new Properties (); 63 try { 64 InputStream is = null; 65 try { 66 is = url.openStream(); 67 props.load(is); 68 } finally { 69 if (is != null) 70 is.close(); 71 } 72 } catch (IOException e) { 73 String message = NLS.bind(Messages.exception_missingFile, url.toExternalForm()); 74 BundleHelper.getDefault().getLog().log(new Status(IStatus.WARNING, IPDEBuildConstants.PI_PDEBUILD, IPDEBuildConstants.EXCEPTION_READING_FILE, message, null)); 75 } 76 return props; 77 } 78 } 79 | Popular Tags |