1 11 package org.eclipse.pde.internal.ui.wizards.exports; 12 13 import java.io.*; 14 import java.lang.reflect.*; 15 16 import org.eclipse.core.runtime.*; 17 import org.eclipse.pde.core.plugin.*; 18 import org.eclipse.pde.internal.core.*; 19 20 21 public class PluginExportJob extends FeatureExportJob { 22 23 private String fFeatureLocation; 24 25 public PluginExportJob( 26 int exportType, 27 boolean exportSource, 28 String destination, 29 String zipFileName, 30 Object [] items) { 31 super(exportType, exportSource, destination, zipFileName, items); 32 } 33 34 37 protected void doExports(IProgressMonitor monitor) 38 throws InvocationTargetException, CoreException { 39 try { 40 String featureID = "org.eclipse.pde.container.feature"; fFeatureLocation = fBuildTempLocation + File.separator + featureID; 43 createFeature(featureID, fFeatureLocation); 44 createBuildPropertiesFile(fFeatureLocation); 45 doExport(featureID, null, fFeatureLocation, TargetPlatform.getOS(), TargetPlatform.getWS(), TargetPlatform.getOSArch(), monitor); 46 } catch (IOException e) { 47 } finally { 48 for (int i = 0; i < fItems.length; i++) { 49 if (fItems[i] instanceof IPluginModelBase) 50 deleteBuildFiles((IPluginModelBase)fItems[i]); 51 } 52 cleanup(new SubProgressMonitor(monitor, 1)); 53 monitor.done(); 54 } 55 } 56 57 private void createFeature(String featureID, String featureLocation) 58 throws IOException { 59 File file = new File(featureLocation); 60 if (!file.exists() || !file.isDirectory()) 61 file.mkdirs(); 62 File featureXML = new File(file, "feature.xml"); PrintWriter writer = new PrintWriter(new OutputStreamWriter(new FileOutputStream(featureXML), "UTF-8"), true); writer.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); writer.println("<feature id=\"" + featureID+ "\" version=\"1.0\">"); for (int i = 0; i < fItems.length; i++) { 67 if (fItems[i] instanceof IPluginModelBase) { 68 IPluginBase plugin = ((IPluginModelBase) fItems[i]) 69 .getPluginBase(); 70 writer.println("<plugin id=\"" + plugin.getId()+ "\" version=\"0.0.0\"/>"); } 72 } 73 writer.println("</feature>"); writer.close(); 75 } 76 77 80 protected String [] getPaths() throws CoreException { 81 String [] paths = super.getPaths(); 82 String [] all = new String [paths.length + 1]; 83 all[0] = fFeatureLocation + File.separator + "feature.xml"; System.arraycopy(paths, 0, all, 1, paths.length); 85 return all; 86 } 87 88 private void createBuildPropertiesFile(String featureLocation) { 89 File file = new File(featureLocation); 90 if (!file.exists() || !file.isDirectory()) 91 file.mkdirs(); 92 File build = new File(file, "build.properties"); try { 94 build.createNewFile(); 95 } catch (IOException e) { 96 } 97 } 98 99 } 100 | Popular Tags |