|
Lines 21-26
Link Here
|
| 21 |
import org.eclipse.core.runtime.jobs.*; |
21 |
import org.eclipse.core.runtime.jobs.*; |
| 22 |
import org.eclipse.jdt.core.*; |
22 |
import org.eclipse.jdt.core.*; |
| 23 |
import org.eclipse.jface.dialogs.*; |
23 |
import org.eclipse.jface.dialogs.*; |
|
|
24 |
import org.eclipse.osgi.service.resolver.BundleDescription; |
| 25 |
import org.eclipse.osgi.service.resolver.State; |
| 24 |
import org.eclipse.osgi.util.NLS; |
26 |
import org.eclipse.osgi.util.NLS; |
| 25 |
import org.eclipse.pde.core.*; |
27 |
import org.eclipse.pde.core.*; |
| 26 |
import org.eclipse.pde.core.build.*; |
28 |
import org.eclipse.pde.core.build.*; |
|
Lines 61-66
Link Here
|
| 61 |
|
63 |
|
| 62 |
protected static String FEATURE_POST_PROCESSING = "features.postProcessingSteps.properties"; //$NON-NLS-1$ |
64 |
protected static String FEATURE_POST_PROCESSING = "features.postProcessingSteps.properties"; //$NON-NLS-1$ |
| 63 |
protected static String PLUGIN_POST_PROCESSING = "plugins.postProcessingSteps.properties"; //$NON-NLS-1$ |
65 |
protected static String PLUGIN_POST_PROCESSING = "plugins.postProcessingSteps.properties"; //$NON-NLS-1$ |
|
|
66 |
protected String[][] ftargets; |
| 64 |
|
67 |
|
| 65 |
class SchedulingRule implements ISchedulingRule { |
68 |
class SchedulingRule implements ISchedulingRule { |
| 66 |
|
69 |
|
|
Lines 85-91
Link Here
|
| 85 |
setRule(new SchedulingRule()); |
88 |
setRule(new SchedulingRule()); |
| 86 |
} |
89 |
} |
| 87 |
|
90 |
|
| 88 |
public FeatureExportJob(boolean toDirectory, boolean useJarFormat, boolean exportSource, String destination, String zipFileName, Object[] items, String[] signingInfo, String[] jnlpInfo) { |
91 |
public FeatureExportJob(boolean toDirectory, boolean useJarFormat, boolean exportSource, String destination, String zipFileName, Object[] items, String[] signingInfo, String[] jnlpInfo, String[][] targets) { |
| 89 |
super(PDEUIMessages.FeatureExportJob_name); //$NON-NLS-1$ |
92 |
super(PDEUIMessages.FeatureExportJob_name); //$NON-NLS-1$ |
| 90 |
fExportToDirectory = toDirectory; |
93 |
fExportToDirectory = toDirectory; |
| 91 |
fUseJarFormat = useJarFormat; |
94 |
fUseJarFormat = useJarFormat; |
|
Lines 95-106
Link Here
|
| 95 |
fItems = items; |
98 |
fItems = items; |
| 96 |
fSigningInfo = signingInfo; |
99 |
fSigningInfo = signingInfo; |
| 97 |
fJnlpInfo = jnlpInfo; |
100 |
fJnlpInfo = jnlpInfo; |
|
|
101 |
ftargets = targets; |
| 102 |
// TODO remove when there is UI to set ftargets |
| 103 |
if (ftargets == null) |
| 104 |
ftargets = new String[][] { { "linux", "gtk", "x86", ""} , {"win32", "win32", "x86", ""} }; |
| 98 |
fBuildTempLocation = PDEPlugin.getDefault().getStateLocation().append("temp").toString(); //$NON-NLS-1$ |
105 |
fBuildTempLocation = PDEPlugin.getDefault().getStateLocation().append("temp").toString(); //$NON-NLS-1$ |
| 99 |
setRule(new SchedulingRule()); |
106 |
setRule(new SchedulingRule()); |
| 100 |
} |
107 |
} |
| 101 |
|
108 |
|
| 102 |
public FeatureExportJob(boolean toDirectory, boolean useJarFormat, boolean exportSource, String destination, String zipFileName, Object[] items) { |
109 |
public FeatureExportJob(boolean toDirectory, boolean useJarFormat, boolean exportSource, String destination, String zipFileName, Object[] items) { |
| 103 |
this(toDirectory, useJarFormat, exportSource, destination, zipFileName, items, null, null); |
110 |
this(toDirectory, useJarFormat, exportSource, destination, zipFileName, items, null, null, null); |
| 104 |
} |
111 |
} |
| 105 |
|
112 |
|
| 106 |
/* |
113 |
/* |
|
Lines 150-179
Link Here
|
| 150 |
protected void doExports(IProgressMonitor monitor) throws InvocationTargetException, CoreException { |
157 |
protected void doExports(IProgressMonitor monitor) throws InvocationTargetException, CoreException { |
| 151 |
createDestination(); |
158 |
createDestination(); |
| 152 |
monitor.beginTask("", fItems.length + 1); //$NON-NLS-1$ |
159 |
monitor.beginTask("", fItems.length + 1); //$NON-NLS-1$ |
| 153 |
try { |
160 |
String[][] configurations = ftargets; |
| 154 |
for (int i = 0; i < fItems.length; i++) { |
161 |
if (configurations == null) |
| 155 |
if (monitor.isCanceled()) |
162 |
configurations = new String[][] { null }; |
| 156 |
throw new OperationCanceledException(); |
163 |
for (int i = 0; i < configurations.length; i++) { |
| 157 |
IFeatureModel model = (IFeatureModel) fItems[i]; |
164 |
try { |
| 158 |
try { |
165 |
for (int j = 0; j < fItems.length; j++) { |
| 159 |
String location = model.getInstallLocation(); |
166 |
if (monitor.isCanceled()) |
| 160 |
if (fUseJarFormat) { |
167 |
throw new OperationCanceledException(); |
| 161 |
createPostProcessingFile(new File(location, FEATURE_POST_PROCESSING)); |
168 |
doExport((IFeatureModel) fItems[j], configurations[i], monitor); |
| 162 |
createPostProcessingFile(new File(location, PLUGIN_POST_PROCESSING)); |
|
|
| 163 |
} |
| 164 |
IFeature feature = model.getFeature(); |
| 165 |
String id = feature.getId(); |
| 166 |
String os = getOS(feature); |
| 167 |
String ws = getWS(feature); |
| 168 |
String arch = getOSArch(feature); |
| 169 |
doExport(id, model.getFeature().getVersion(), model.getInstallLocation(), os, ws, arch, new SubProgressMonitor(monitor, 1)); |
| 170 |
} finally { |
| 171 |
deleteBuildFiles(model); |
| 172 |
} |
169 |
} |
|
|
170 |
} finally { |
| 171 |
cleanup(configurations[i], new SubProgressMonitor(monitor, 1)); |
| 172 |
monitor.done(); |
| 173 |
} |
| 174 |
} |
| 175 |
} |
| 176 |
|
| 177 |
private void doExport(IFeatureModel model, String os, String ws, String arch, IProgressMonitor monitor) throws CoreException, InvocationTargetException { |
| 178 |
try { |
| 179 |
String location = model.getInstallLocation(); |
| 180 |
if (fUseJarFormat) { |
| 181 |
createPostProcessingFile(new File(location, FEATURE_POST_PROCESSING)); |
| 182 |
createPostProcessingFile(new File(location, PLUGIN_POST_PROCESSING)); |
| 173 |
} |
183 |
} |
|
|
184 |
IFeature feature = model.getFeature(); |
| 185 |
doExport(feature.getId(), feature.getVersion(), location, os, ws, arch, new SubProgressMonitor(monitor, 1)); |
| 174 |
} finally { |
186 |
} finally { |
| 175 |
cleanup(new SubProgressMonitor(monitor, 1)); |
187 |
deleteBuildFiles(model); |
| 176 |
monitor.done(); |
|
|
| 177 |
} |
188 |
} |
| 178 |
} |
189 |
} |
| 179 |
|
190 |
|
|
Lines 224-229
Link Here
|
| 224 |
} |
235 |
} |
| 225 |
} |
236 |
} |
| 226 |
|
237 |
|
|
|
238 |
private void createDestination(String os, String ws, String arch) throws InvocationTargetException { |
| 239 |
if (!fExportToDirectory) |
| 240 |
return; |
| 241 |
File file = new File(fDestinationDirectory, os + '.' + ws + '.' + arch); |
| 242 |
if (!file.exists() || !file.isDirectory()) { |
| 243 |
if (!file.mkdirs()) |
| 244 |
throw new InvocationTargetException(new Exception(PDEUIMessages.ExportWizard_badDirectory)); //$NON-NLS-1$ |
| 245 |
} |
| 246 |
} |
| 247 |
|
| 248 |
protected void doExport(IFeatureModel model, String[] config, IProgressMonitor monitor) throws CoreException, InvocationTargetException { |
| 249 |
// TODO progress monitoring |
| 250 |
if (config == null) { |
| 251 |
IFeature feature = model.getFeature(); |
| 252 |
doExport(model, getOS(feature), getWS(feature), getOSArch(feature), monitor); |
| 253 |
} else { |
| 254 |
createDestination(config[0], config[1], config[2]); |
| 255 |
doExport(model, config[0], config[1], config[2], monitor); |
| 256 |
} |
| 257 |
} |
| 258 |
|
| 227 |
protected void doExport(String featureID, String version, String featureLocation, String os, String ws, String arch, IProgressMonitor monitor) throws CoreException, InvocationTargetException { |
259 |
protected void doExport(String featureID, String version, String featureLocation, String os, String ws, String arch, IProgressMonitor monitor) throws CoreException, InvocationTargetException { |
| 228 |
monitor.beginTask("", 5); //$NON-NLS-1$ |
260 |
monitor.beginTask("", 5); //$NON-NLS-1$ |
| 229 |
monitor.setTaskName(PDEUIMessages.FeatureExportJob_taskName); //$NON-NLS-1$ |
261 |
monitor.setTaskName(PDEUIMessages.FeatureExportJob_taskName); //$NON-NLS-1$ |
|
Lines 291-300
Link Here
|
| 291 |
fAntBuildProperties.put(IXMLConstants.PROPERTY_COLLECTING_FOLDER, "."); //$NON-NLS-1$ |
323 |
fAntBuildProperties.put(IXMLConstants.PROPERTY_COLLECTING_FOLDER, "."); //$NON-NLS-1$ |
| 292 |
String prefix = Platform.getOS().equals("macosx") ? "." : ""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
324 |
String prefix = Platform.getOS().equals("macosx") ? "." : ""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
| 293 |
fAntBuildProperties.put(IXMLConstants.PROPERTY_ARCHIVE_PREFIX, prefix); |
325 |
fAntBuildProperties.put(IXMLConstants.PROPERTY_ARCHIVE_PREFIX, prefix); |
| 294 |
if (!fExportToDirectory) |
326 |
if (!fExportToDirectory) { |
| 295 |
fAntBuildProperties.put(IXMLConstants.PROPERTY_ARCHIVE_FULLPATH, fDestinationDirectory + File.separator + fZipFilename); |
327 |
String filename = fZipFilename; |
| 296 |
else |
328 |
if (ftargets != null) { |
| 297 |
fAntBuildProperties.put(IXMLConstants.PROPERTY_ASSEMBLY_TMP, fDestinationDirectory); |
329 |
int i = filename.lastIndexOf('.'); |
|
|
330 |
filename = filename.substring(0, i) + '.' + os + '.' + ws + '.' + arch + filename.substring(i); |
| 331 |
} |
| 332 |
fAntBuildProperties.put(IXMLConstants.PROPERTY_ARCHIVE_FULLPATH, fDestinationDirectory + File.separator + filename); |
| 333 |
} else { |
| 334 |
String dir = fDestinationDirectory; |
| 335 |
if (ftargets != null) |
| 336 |
dir += File.separatorChar + os + '.' + ws + '.' + arch; |
| 337 |
fAntBuildProperties.put(IXMLConstants.PROPERTY_ASSEMBLY_TMP, dir); |
| 338 |
} |
| 298 |
fAntBuildProperties.put(IXMLConstants.PROPERTY_TAR_ARGS, ""); //$NON-NLS-1$ |
339 |
fAntBuildProperties.put(IXMLConstants.PROPERTY_TAR_ARGS, ""); //$NON-NLS-1$ |
| 299 |
} |
340 |
} |
| 300 |
return fAntBuildProperties; |
341 |
return fAntBuildProperties; |
|
Lines 455-461
Link Here
|
| 455 |
paths.add(models[i].getInstallLocation() + IPath.SEPARATOR + "feature.xml"); //$NON-NLS-1$ |
496 |
paths.add(models[i].getInstallLocation() + IPath.SEPARATOR + "feature.xml"); //$NON-NLS-1$ |
| 456 |
} |
497 |
} |
| 457 |
|
498 |
|
| 458 |
String[] plugins = TargetPlatform.createPluginPath(); |
499 |
State state = TargetPlatform.getState(); |
|
|
500 |
BundleDescription[] descriptions = state.getBundles(); |
| 501 |
String[] plugins = new String[descriptions.length]; |
| 502 |
for (int i = 0; i < descriptions.length; i++) |
| 503 |
plugins[i] = descriptions[i].getLocation(); |
| 504 |
// String[] plugins = TargetPlatform.createPluginPath(); |
| 459 |
String[] features = (String[]) paths.toArray(new String[paths.size()]); |
505 |
String[] features = (String[]) paths.toArray(new String[paths.size()]); |
| 460 |
String[] all = new String[plugins.length + paths.size()]; |
506 |
String[] all = new String[plugins.length + paths.size()]; |
| 461 |
System.arraycopy(plugins, 0, all, 0, plugins.length); |
507 |
System.arraycopy(plugins, 0, all, 0, plugins.length); |
|
Lines 482-497
Link Here
|
| 482 |
return writer; |
528 |
return writer; |
| 483 |
} |
529 |
} |
| 484 |
|
530 |
|
| 485 |
protected void cleanup(IProgressMonitor monitor) { |
531 |
protected void cleanup(String[] config, IProgressMonitor monitor) { |
| 486 |
monitor.beginTask("", 2); |
532 |
monitor.beginTask("", 2); |
|
|
533 |
// TODO clear out some cached values that depend on the configuration being built. |
| 534 |
fDevProperties = null; |
| 535 |
fAntBuildProperties = null; |
| 487 |
File scriptFile = null; |
536 |
File scriptFile = null; |
| 488 |
try { |
537 |
try { |
| 489 |
scriptFile = createScriptFile(); |
538 |
scriptFile = createScriptFile(); |
| 490 |
writer = new PrintWriter(new FileWriter(scriptFile), true); |
539 |
writer = new PrintWriter(new FileWriter(scriptFile), true); |
| 491 |
generateHeader(writer); |
540 |
generateHeader(writer); |
| 492 |
generateDeleteZipTarget(writer); |
541 |
generateDeleteZipTarget(writer, config); |
| 493 |
generateCleanTarget(writer); |
542 |
generateCleanTarget(writer); |
| 494 |
boolean errors = generateZipLogsTarget(writer); |
543 |
boolean errors = generateZipLogsTarget(writer, config); |
| 495 |
generateClosingTag(writer); |
544 |
generateClosingTag(writer); |
| 496 |
writer.close(); |
545 |
writer.close(); |
| 497 |
|
546 |
|
|
Lines 534-549
Link Here
|
| 534 |
writer.println("</target>"); //$NON-NLS-1$ |
583 |
writer.println("</target>"); //$NON-NLS-1$ |
| 535 |
} |
584 |
} |
| 536 |
|
585 |
|
| 537 |
private void generateDeleteZipTarget(PrintWriter writer) { |
586 |
private String logName(String[] config) { |
|
|
587 |
if (config == null) |
| 588 |
return "/logs.zip"; |
| 589 |
return "/logs." + config[0] + '.' + config[1] + '.' + config[2] + ".zip"; |
| 590 |
} |
| 591 |
private void generateDeleteZipTarget(PrintWriter writer, String[] config) { |
| 538 |
writer.println("<target name=\"deleteZip\">"); //$NON-NLS-1$ |
592 |
writer.println("<target name=\"deleteZip\">"); //$NON-NLS-1$ |
| 539 |
writer.println("<delete file=\"" + fDestinationDirectory + "/logs.zip\"/>"); //$NON-NLS-1$ //$NON-NLS-2$ |
593 |
writer.println("<delete file=\"" + fDestinationDirectory + logName(config) + "\"/>"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 540 |
writer.println("</target>"); //$NON-NLS-1$ |
594 |
writer.println("</target>"); //$NON-NLS-1$ |
| 541 |
} |
595 |
} |
| 542 |
|
596 |
|
| 543 |
private boolean generateZipLogsTarget(PrintWriter writer) { |
597 |
private boolean generateZipLogsTarget(PrintWriter writer, String[] config) { |
| 544 |
if (logFile != null && logFile.exists() && logFile.length() > 0) { |
598 |
if (logFile != null && logFile.exists() && logFile.length() > 0) { |
| 545 |
writer.println("<target name=\"zip.logs\">"); //$NON-NLS-1$ |
599 |
writer.println("<target name=\"zip.logs\">"); //$NON-NLS-1$ |
| 546 |
writer.println("<zip zipfile=\"" + fDestinationDirectory + "/logs.zip\" basedir=\"" + fBuildTempLocation + "/pde.logs\"/>"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
600 |
writer.println("<zip zipfile=\"" + fDestinationDirectory + logName(config) + "\" basedir=\"" + fBuildTempLocation + "/pde.logs\"/>"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
| 547 |
writer.println("</target>"); //$NON-NLS-1$ |
601 |
writer.println("</target>"); //$NON-NLS-1$ |
| 548 |
return true; |
602 |
return true; |
| 549 |
} |
603 |
} |
|
Lines 577-583
Link Here
|
| 577 |
return NLS.bind(PDEUIMessages.ExportJob_error_message, fDestinationDirectory + File.separator + "logs.zip"); //$NON-NLS-1$ //$NON-NLS-2$ |
631 |
return NLS.bind(PDEUIMessages.ExportJob_error_message, fDestinationDirectory + File.separator + "logs.zip"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 578 |
} |
632 |
} |
| 579 |
|
633 |
|
| 580 |
protected void createFeature(String featureID, String featureLocation) throws IOException { |
634 |
protected void createFeature(String featureID, String featureLocation, String[] config) throws IOException { |
| 581 |
File file = new File(featureLocation); |
635 |
File file = new File(featureLocation); |
| 582 |
if (!file.exists() || !file.isDirectory()) |
636 |
if (!file.exists() || !file.isDirectory()) |
| 583 |
file.mkdirs(); |
637 |
file.mkdirs(); |
|
Lines 588-594
Link Here
|
| 588 |
writer.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); //$NON-NLS-1$ |
642 |
writer.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); //$NON-NLS-1$ |
| 589 |
writer.println("<feature id=\"" + featureID + "\" version=\"1.0\">"); //$NON-NLS-1$ //$NON-NLS-2$ |
643 |
writer.println("<feature id=\"" + featureID + "\" version=\"1.0\">"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 590 |
|
644 |
|
| 591 |
Dictionary environment = TargetPlatform.getTargetEnvironment(); |
645 |
IFeatureModel[] models = PDECore.getDefault().getFeatureModelManager().getModels(); |
|
|
646 |
for (int i = 0; i < models.length; i++) { |
| 647 |
IFeature feature = models[i].getFeature(); |
| 648 |
if ("org.eclipse.platform.launchers".equals(feature.getId())) |
| 649 |
writer.println("<includes id=\"" + feature.getId() + "\" version=\"" + feature.getVersion() + "\"/>"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 650 |
} |
| 651 |
|
| 652 |
Dictionary environment = new Hashtable(4); |
| 653 |
environment.put("osgi.os", config[0]); |
| 654 |
environment.put("osgi.ws", config[1]); |
| 655 |
environment.put("osgi.arch", config[2]); |
| 656 |
environment.put("osgi.nl", config[3]); |
| 657 |
|
| 592 |
BundleContext context = PDEPlugin.getDefault().getBundleContext(); |
658 |
BundleContext context = PDEPlugin.getDefault().getBundleContext(); |
| 593 |
for (int i = 0; i < fItems.length; i++) { |
659 |
for (int i = 0; i < fItems.length; i++) { |
| 594 |
if (fItems[i] instanceof IPluginModelBase) { |
660 |
if (fItems[i] instanceof IPluginModelBase) { |