1 11 package org.eclipse.pde.internal.build.properties; 12 13 import java.io.IOException ; 14 import java.net.URL ; 15 import java.util.HashMap ; 16 import java.util.Map ; 17 import org.eclipse.ant.core.IAntPropertyValueProvider; 18 import org.eclipse.core.runtime.*; 19 import org.eclipse.osgi.util.NLS; 20 import org.eclipse.pde.internal.build.*; 21 22 public class PDEProperties implements IAntPropertyValueProvider { 23 static private final String PREFIX = "eclipse.pdebuild"; static private final String HOME = PREFIX + ".home"; static private final String SCRIPTS = PREFIX + ".scripts"; static private final String TEMPLATES = PREFIX + ".templates"; static private final Map cache = new HashMap (); 28 29 public String getAntPropertyValue(String antPropertyName) { 30 String searchedEntry = null; 31 if (HOME.equals(antPropertyName)) 32 searchedEntry = "."; 34 if (SCRIPTS.equals(antPropertyName)) 35 searchedEntry = "scripts"; 37 if (TEMPLATES.equals(antPropertyName)) 38 searchedEntry = "templates"; 40 if (searchedEntry == null) 41 return null; 43 try { 44 String result = (String ) cache.get(searchedEntry); 45 if (result == null) { 46 URL foundEntry = Platform.getBundle(IPDEBuildConstants.PI_PDEBUILD).getEntry(searchedEntry); 47 if (foundEntry == null) { 48 BundleHelper.getDefault().getLog().log(new Status(IStatus.ERROR, IPDEBuildConstants.PI_PDEBUILD, IPDEBuildConstants.WARNING_PLUGIN_ALTERED, NLS.bind(Messages.exception_missing_pdebuild_folder, antPropertyName), null)); 49 } else { 50 result = FileLocator.toFileURL(foundEntry).getPath(); 51 cache.put(searchedEntry, result); 52 } 53 } 54 return result; 55 } catch (IOException e) { 56 return null; 57 } 58 59 } 60 61 } 62 | Popular Tags |