diff options
author | Wassim Melhem | 2004-04-11 02:11:47 +0000 |
---|---|---|
committer | Wassim Melhem | 2004-04-11 02:11:47 +0000 |
commit | bcd0d30441939b8e3af4ed6696d76926629e5db6 (patch) | |
tree | a2237b33512af2771b893d7a1c872f1e92dabeea | |
parent | 3ea81e45d3696f9b9842a02b567bcbcbf60c3875 (diff) | |
download | eclipse.pde.ui-pde_to_bde.tar.gz eclipse.pde.ui-pde_to_bde.tar.xz eclipse.pde.ui-pde_to_bde.zip |
*** empty log message ***pde_to_bde
2 files changed, 101 insertions, 153 deletions
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/exports/FeatureExportJob.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/exports/FeatureExportJob.java index e0987639d9..fb5962ffa5 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/exports/FeatureExportJob.java +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/exports/FeatureExportJob.java @@ -111,11 +111,16 @@ public class FeatureExportJob extends Job implements IPreferenceConstants { monitor.beginTask("", fItems.length + 1); try { for (int i = 0; i < fItems.length; i++) { - IModel model = (IModel) fItems[i]; - doExport(model, new SubProgressMonitor(monitor, 1)); + IFeatureModel model = (IFeatureModel)fItems[i]; + try { + doExport(model.getFeature().getId(), model.getInstallLocation(), new SubProgressMonitor(monitor, 1)); + } finally { + deleteBuildFiles(model); + } } } finally { cleanup(new SubProgressMonitor(monitor, 1)); + monitor.done(); } } @@ -127,22 +132,19 @@ public class FeatureExportJob extends Job implements IPreferenceConstants { } } - protected void doExport(IModel model, IProgressMonitor monitor) + protected void doExport(String featureID, String featureLocation, IProgressMonitor monitor) throws CoreException, InvocationTargetException { - IFeatureModel feature = (IFeatureModel) model; - String label = PDEPlugin.getDefault().getLabelProvider().getObjectText(feature); monitor.beginTask("", 5); - monitor.setTaskName(PDEPlugin.getResourceString("ExportJob.exporting") + " " + label); + monitor.setTaskName(PDEPlugin.getResourceString("ExportJob.exporting") + " " + featureID); try { HashMap properties = createBuildProperties(); - makeScript(feature); + makeScript(featureID, featureLocation); monitor.worked(1); - runScript(getBuildScriptName(feature), getBuildExecutionTargets(), + runScript(getBuildScriptName(featureLocation), getBuildExecutionTargets(), properties, new SubProgressMonitor(monitor, 2)); - runScript(getAssemblyScriptName(feature), new String[]{"main"}, + runScript(getAssemblyScriptName(featureID, featureLocation), new String[]{"main"}, properties, new SubProgressMonitor(monitor, 2)); } finally { - deleteBuildFiles(feature); monitor.done(); } } @@ -179,12 +181,12 @@ public class FeatureExportJob extends Job implements IPreferenceConstants { return fBuildProperties; } - private void makeScript(IFeatureModel model) throws CoreException { + private void makeScript(String featureID, String featureLocation) throws CoreException { BuildScriptGenerator generator = new BuildScriptGenerator(); generator.setBuildingOSGi(PDECore.getDefault().getModelManager().isOSGiRuntime()); generator.setChildren(true); - generator.setWorkingDirectory(model.getUnderlyingResource().getProject().getLocation().toOSString()); - generator.setElements(new String[] {"feature@" + model.getFeature().getId()}); + generator.setWorkingDirectory(featureLocation); + generator.setElements(new String[] {"feature@" + featureID}); generator.setPluginPath(getPaths()); generator.setOutputFormat(fExportType == EXPORT_AS_ZIP ? "antzip" : "folder"); generator.setForceUpdateJar(fExportType == EXPORT_AS_UPDATE_JARS); @@ -204,13 +206,13 @@ public class FeatureExportJob extends Job implements IPreferenceConstants { runner.run(monitor); } - private String getBuildScriptName(IFeatureModel feature) { - return feature.getInstallLocation() + Path.SEPARATOR + "build.xml"; + private String getBuildScriptName(String featureLocation) { + return featureLocation + Path.SEPARATOR + "build.xml"; } - private String getAssemblyScriptName(IFeatureModel feature) { - return feature.getInstallLocation() + Path.SEPARATOR + "assemble." - + feature.getFeature().getId() + ".xml"; + private String getAssemblyScriptName(String featureID, String featureLocation) { + return featureLocation + Path.SEPARATOR + "assemble." + + featureID + ".xml"; } private String[] getBuildExecutionTargets() { @@ -219,38 +221,44 @@ public class FeatureExportJob extends Job implements IPreferenceConstants { return new String[] {"build.jars", "gather.logs"}; } - private void deleteBuildFiles(IFeatureModel model) throws CoreException { - deleteBuildFile(model); - IFeaturePlugin[] plugins = model.getFeature().getPlugins(); - PluginModelManager manager = PDECore.getDefault().getModelManager(); - for (int i = 0; i < plugins.length; i++) { - ModelEntry entry = - manager.findEntry(plugins[i].getId(), plugins[i].getVersion()); - if (entry != null) { - deleteBuildFile(entry.getActiveModel()); - } - } - } - - public void deleteBuildFile(IModel model) throws CoreException { + public void deleteBuildFiles(IModel model) throws CoreException { String directory = (model instanceof IFeatureModel) ? ((IFeatureModel) model).getInstallLocation() : ((IPluginModelBase) model).getInstallLocation(); - if (!isCustomBuild(model)) { + + if (model.getUnderlyingResource() != null && !isCustomBuild(model)) { File file = new File(directory, "build.xml"); if (file.exists() && !file.isDirectory()) { file.delete(); } + if (model instanceof IFeatureModel) { + String id = ((IFeatureModel)model).getFeature().getId(); + file = new File(directory, "assemble." + id + ".all.xml"); + if (file.exists() && !file.isDirectory()) + file.delete(); + file = new File(directory, "assemble." + id + ".xml"); + if (file.exists() && !file.isDirectory()) + file.delete(); + } } + if (model instanceof IFeatureModel) { - String id = ((IFeatureModel)model).getFeature().getId(); - File file = new File(directory, "assemble." + id + ".all.xml"); - if (file.exists() && !file.isDirectory()) - file.delete(); - file = new File(directory, "assemble." + id + ".xml"); - if (file.exists() && !file.isDirectory()) - file.delete(); + IFeature feature = ((IFeatureModel)model).getFeature(); + IFeatureChild[] children = feature.getIncludedFeatures(); + for (int i = 0; i < children.length; i++) { + deleteBuildFiles(children[i].getModel()); + } + + IFeaturePlugin[] plugins = feature.getPlugins(); + PluginModelManager manager = PDECore.getDefault().getModelManager(); + for (int i = 0; i < plugins.length; i++) { + ModelEntry entry = + manager.findEntry(plugins[i].getId(), plugins[i].getVersion()); + if (entry != null) { + deleteBuildFiles(entry.getActiveModel()); + } + } } } @@ -275,7 +283,7 @@ public class FeatureExportJob extends Job implements IPreferenceConstants { return false; } - private String[] getPaths() throws CoreException { + protected String[] getPaths() throws CoreException { ArrayList paths = new ArrayList(); IFeatureModel[] models = PDECore.getDefault().getWorkspaceModelManager().getFeatureModels(); for (int i = 0; i < models.length; i++) { diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/exports/PluginExportJob.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/exports/PluginExportJob.java index ded9e06ab1..e46dc06f2a 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/exports/PluginExportJob.java +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/exports/PluginExportJob.java @@ -10,25 +10,16 @@ *******************************************************************************/ package org.eclipse.pde.internal.ui.wizards.exports; -import java.io.File; -import java.lang.reflect.InvocationTargetException; -import java.util.HashMap; +import java.io.*; +import java.lang.reflect.*; +import org.eclipse.core.runtime.*; +import org.eclipse.pde.core.plugin.*; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.pde.core.IModel; -import org.eclipse.pde.core.plugin.IPluginBase; -import org.eclipse.pde.core.plugin.IPluginModelBase; -import org.eclipse.pde.internal.build.builder.ModelBuildScriptGenerator; -import org.eclipse.pde.internal.core.TargetPlatform; -import org.eclipse.pde.internal.ui.PDEPlugin; public class PluginExportJob extends FeatureExportJob { + private String fFeatureLocation; + public PluginExportJob( int exportType, boolean exportSource, @@ -38,109 +29,58 @@ public class PluginExportJob extends FeatureExportJob { super(exportType, exportSource, destination, zipFileName, items); } - protected HashMap createProperties( - String destination, - IPluginBase model, - int exportType) { - HashMap map = new HashMap(4); - String location = fBuildTempLocation + "/build_result/" + model.getId(); - File dir = new File(location); - if (!dir.exists() || !dir.isDirectory()) - dir.mkdirs(); - map.put("build.result.folder", location); - map.put( - "temp.folder", - fBuildTempLocation + "/temp.folder/" + model.getId()); - if (exportType != FeatureExportJob.EXPORT_AS_UPDATE_JARS) - map.put( - "destination.temp.folder", - fBuildTempLocation + "/destination/plugins"); - else - map.put( - "destination.temp.folder", - fBuildTempLocation + "/temp.folder/" + model.getId()); - map.put("plugin.destination", destination); - map.put("baseos", TargetPlatform.getOS()); - map.put("basews", TargetPlatform.getWS()); - map.put("basearch", TargetPlatform.getOSArch()); - map.put("basenl", TargetPlatform.getNL()); - map.put("eclipse.running", "true"); - - IPreferenceStore store = PDEPlugin.getDefault().getPreferenceStore(); - map.put("javacFailOnError", "false"); - map.put( - "javacDebugInfo", - store.getBoolean(PROP_JAVAC_DEBUG_INFO) ? "on" : "off"); - map.put("javacVerbose", store.getString(PROP_JAVAC_VERBOSE)); - map.put("javacSource", store.getString(PROP_JAVAC_SOURCE)); - map.put("javacTarget", store.getString(PROP_JAVAC_TARGET)); - return map; - } - - protected void doExport(IModel model, IProgressMonitor monitor) - throws CoreException, InvocationTargetException { - - IPluginModelBase modelBase = (IPluginModelBase) model; + /* (non-Javadoc) + * @see org.eclipse.pde.internal.ui.wizards.exports.FeatureExportJob#doExports(org.eclipse.core.runtime.IProgressMonitor) + */ + protected void doExports(IProgressMonitor monitor) + throws InvocationTargetException, CoreException { try { - String label = - PDEPlugin.getDefault().getLabelProvider().getObjectText( - modelBase.getPluginBase()); - monitor.setTaskName( - PDEPlugin.getResourceString("ExportJob.exporting") - + " " - + label); - monitor.beginTask("", 10); - makeScript(modelBase); - monitor.worked(1); - //TODO uncomment this - /*runScript( - modelBase.getInstallLocation(), - destination, - exportType, - exportSource, - createProperties( - destination, - modelBase.getPluginBase(), - exportType), - new SubProgressMonitor(monitor, 9));*/ + // create a feature to contain all plug-ins + String featureID = "org.eclipse.pde.container.feature"; + fFeatureLocation = fBuildTempLocation + File.separator + featureID; + createFeature(featureID, fFeatureLocation); + doExport(featureID, fFeatureLocation, monitor); + } catch (IOException e) { } finally { - deleteBuildFile(modelBase); + for (int i = 0; i < fItems.length; i++) { + if (fItems[i] instanceof IPluginModelBase) + deleteBuildFiles((IPluginModelBase)fItems[i]); + } + cleanup(new SubProgressMonitor(monitor, 1)); monitor.done(); } - } - - public void deleteBuildFile(IPluginModelBase model) throws CoreException { - if (isCustomBuild(model)) - return; - File file = new File(model.getInstallLocation(), "build.xml"); - if (file.exists()) - file.delete(); - } - - private void makeScript(IPluginModelBase model) throws CoreException { - ModelBuildScriptGenerator generator = null; - generator = new ModelBuildScriptGenerator(); - - generator.setWorkingDirectory(model.getInstallLocation()); - - IProject project = model.getUnderlyingResource().getProject(); - if (project.hasNature(JavaCore.NATURE_ID)) { - IPath path = - JavaCore - .create(project) - .getOutputLocation() - .removeFirstSegments( - 1); - generator.setDevEntries(path.toOSString()); - } else { - generator.setDevEntries("bin" ); + + private void createFeature(String featureID, String featureLocation) + throws IOException { + File file = new File(featureLocation); + if (!file.exists() || !file.isDirectory()) + file.mkdirs(); + File featureXML = new File(file, "feature.xml"); + PrintWriter writer = new PrintWriter(new FileWriter(featureXML), 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++) { + if (fItems[i] instanceof IPluginModelBase) { + IPluginBase plugin = ((IPluginModelBase) fItems[i]) + .getPluginBase(); + writer.println("<plugin id=\"" + plugin.getId() + + "\" version=\"" + plugin.getVersion() + "\"/>"); + } } - - generator.setPluginPath(TargetPlatform.createPluginPath()); - - generator.setModelId(model.getPluginBase().getId()); - generator.generate(); + writer.println("</feature>"); + writer.close(); + } + + /* (non-Javadoc) + * @see org.eclipse.pde.internal.ui.wizards.exports.FeatureExportJob#getPaths() + */ + protected String[] getPaths() throws CoreException { + String[] paths = super.getPaths(); + String[] all = new String[paths.length + 1]; + all[0] = fFeatureLocation + File.separator + "feature.xml"; + System.arraycopy(paths, 0, all, 1, paths.length); + return all; } } |