1 11 package org.eclipse.pde.internal.core.exports; 12 13 import java.io.File ; 14 import java.io.FileOutputStream ; 15 import java.io.IOException ; 16 import java.lang.reflect.InvocationTargetException ; 17 import java.util.Properties ; 18 19 import org.eclipse.core.runtime.CoreException; 20 import org.eclipse.core.runtime.IProgressMonitor; 21 import org.eclipse.core.runtime.SubProgressMonitor; 22 import org.eclipse.pde.core.IModel; 23 import org.eclipse.pde.core.plugin.TargetPlatform; 24 import org.eclipse.pde.internal.core.PDECore; 25 public abstract class FeatureBasedExportOperation extends FeatureExportOperation { 26 27 protected String fFeatureLocation; 28 29 public FeatureBasedExportOperation(FeatureExportInfo info) { 30 super(info); 31 } 32 33 public void run(IProgressMonitor monitor) throws CoreException { 34 try { 35 createDestination(); 36 monitor.beginTask("", 10); String featureID = "org.eclipse.pde.container.feature"; fFeatureLocation = fBuildTempLocation + File.separator + featureID; 40 String [] config = new String [] {TargetPlatform.getOS(), TargetPlatform.getWS(), TargetPlatform.getOSArch(), TargetPlatform.getNL() }; 41 createFeature(featureID, fFeatureLocation, config, false); 42 createBuildPropertiesFile(fFeatureLocation); 43 if (fInfo.useJarFormat) 44 createPostProcessingFiles(); 45 doExport(featureID, null, fFeatureLocation, TargetPlatform.getOS(), TargetPlatform.getWS(), TargetPlatform.getOSArch(), 46 new SubProgressMonitor(monitor, 7)); 47 } catch (IOException e) { 48 } catch (InvocationTargetException e) { 49 throwCoreException(e); 50 } finally { 51 for (int i = 0; i < fInfo.items.length; i++) { 52 if (fInfo.items[i] instanceof IModel) 53 deleteBuildFiles(fInfo.items[i]); 54 } 55 cleanup(null, new SubProgressMonitor(monitor, 3)); 56 monitor.done(); 57 } 58 } 59 60 protected abstract void createPostProcessingFiles(); 61 62 protected String [] getPaths() { 63 String [] paths = super.getPaths(); 64 String [] all = new String [paths.length + 1]; 65 all[0] = fFeatureLocation + File.separator + "feature.xml"; System.arraycopy(paths, 0, all, 1, paths.length); 67 return all; 68 } 69 70 private void createBuildPropertiesFile(String featureLocation) { 71 File file = new File (featureLocation); 72 if (!file.exists() || !file.isDirectory()) 73 file.mkdirs(); 74 Properties prop = new Properties (); 75 prop.put("pde", "marker"); save(new File (file, "build.properties"),prop, "Marker File"); } 78 79 private void save(File file, Properties properties, String header) { 80 try { 81 FileOutputStream stream = new FileOutputStream (file); 82 properties.store(stream, header); 83 stream.flush(); 84 stream.close(); 85 } catch (IOException e) { 86 PDECore.logException(e); 87 } 88 } 89 90 } 91 | Popular Tags |