|
Lines 11-16
Link Here
|
| 11 |
package org.eclipse.pde.internal.build; |
11 |
package org.eclipse.pde.internal.build; |
| 12 |
|
12 |
|
| 13 |
import java.io.File; |
13 |
import java.io.File; |
|
|
14 |
import java.io.IOException; |
| 14 |
import java.util.*; |
15 |
import java.util.*; |
| 15 |
import java.util.jar.JarFile; |
16 |
import java.util.jar.JarFile; |
| 16 |
import org.eclipse.core.runtime.*; |
17 |
import org.eclipse.core.runtime.*; |
|
Lines 20-25
Link Here
|
| 20 |
import org.eclipse.pde.internal.build.builder.BuildDirector; |
21 |
import org.eclipse.pde.internal.build.builder.BuildDirector; |
| 21 |
import org.eclipse.pde.internal.build.builder.ModelBuildScriptGenerator; |
22 |
import org.eclipse.pde.internal.build.builder.ModelBuildScriptGenerator; |
| 22 |
import org.eclipse.pde.internal.build.site.BuildTimeFeature; |
23 |
import org.eclipse.pde.internal.build.site.BuildTimeFeature; |
|
|
24 |
import org.osgi.framework.Bundle; |
| 23 |
|
25 |
|
| 24 |
/** |
26 |
/** |
| 25 |
* Generate an assemble script for a given feature and a given config. It |
27 |
* Generate an assemble script for a given feature and a given config. It |
|
Lines 119-128
Link Here
|
| 119 |
|
121 |
|
| 120 |
generateMainBegin(); |
122 |
generateMainBegin(); |
| 121 |
generateInitializationSteps(); |
123 |
generateInitializationSteps(); |
| 122 |
generateGatherCalls(); |
124 |
if (BuildDirector.p2Gathering) { |
| 123 |
generateProcessingCalls(); |
125 |
generateDirectorCall(); |
| 124 |
generateBrandingCalls(); |
126 |
} else { |
| 125 |
generateP2Steps(); |
127 |
generateGatherCalls(); |
|
|
128 |
generateProcessingCalls(); |
| 129 |
generateBrandingCalls(); |
| 130 |
generateP2Steps(); |
| 131 |
} |
| 126 |
generateArchivingCalls(); |
132 |
generateArchivingCalls(); |
| 127 |
generateMainEnd(); |
133 |
generateMainEnd(); |
| 128 |
|
134 |
|
|
Lines 139-151
Link Here
|
| 139 |
script.println(); |
145 |
script.println(); |
| 140 |
} |
146 |
} |
| 141 |
|
147 |
|
|
|
148 |
protected void generateDirectorCall() { |
| 149 |
if (productFile != null) |
| 150 |
script.printAntCallTask(TARGET_RUN_DIRECTOR, true, null); |
| 151 |
} |
| 152 |
|
| 153 |
protected void generateDirectorTarget(boolean assembling) { |
| 154 |
script.printTargetDeclaration(TARGET_RUN_DIRECTOR, null, null, assembling ? PROPERTY_RUN_PACKAGER : null, null); |
| 155 |
Map parameters = new HashMap(); |
| 156 |
parameters.put(PROPERTY_OS, Utils.getPropertyFormat(PROPERTY_OS)); |
| 157 |
parameters.put(PROPERTY_WS, Utils.getPropertyFormat(PROPERTY_WS)); |
| 158 |
parameters.put(PROPERTY_ARCH, Utils.getPropertyFormat(PROPERTY_ARCH)); |
| 159 |
parameters.put(PROPERTY_P2_REPO, Utils.getPropertyFormat(PROPERTY_P2_BUILD_REPO)); |
| 160 |
parameters.put(PROPERTY_P2_DIRECTOR_IU, productFile != null ? productFile.getId() : Utils.getPropertyFormat(PROPERTY_P2_ROOT_NAME)); |
| 161 |
parameters.put(PROPERTY_P2_DIRECTOR_VERSION, productFile != null ? productFile.getVersion() : Utils.getPropertyFormat(PROPERTY_P2_ROOT_VERSION)); |
| 162 |
parameters.put(PROPERTY_P2_DIRECTOR_INSTALLPATH, Utils.getPropertyFormat(PROPERTY_ECLIPSE_BASE)); |
| 163 |
script.printAntTask(Utils.getPropertyFormat(PROPERTY_GENERIC_TARGETS), null, TARGET_RUN_DIRECTOR, null, TRUE, parameters); |
| 164 |
script.println(); |
| 165 |
script.printTargetEnd(); |
| 166 |
} |
| 167 |
|
| 142 |
private void generateProcessingCalls() { |
168 |
private void generateProcessingCalls() { |
| 143 |
script.printAntCallTask(TARGET_JAR_PROCESSING, true, null); |
169 |
script.printAntCallTask(TARGET_JAR_PROCESSING, true, null); |
| 144 |
script.println(); |
170 |
script.println(); |
| 145 |
} |
171 |
} |
| 146 |
|
172 |
|
| 147 |
private void generateArchivingCalls() { |
173 |
private void generateArchivingCalls() { |
| 148 |
if (!BuildDirector.p2Gathering) |
174 |
if (!BuildDirector.p2Gathering || productFile != null) |
| 149 |
script.printAntCallTask(TARGET_ASSEMBLE_ARCHIVE, true, null); |
175 |
script.printAntCallTask(TARGET_ASSEMBLE_ARCHIVE, true, null); |
| 150 |
} |
176 |
} |
| 151 |
|
177 |
|
|
Lines 175-182
Link Here
|
| 175 |
script.println(); |
201 |
script.println(); |
| 176 |
} |
202 |
} |
| 177 |
|
203 |
|
| 178 |
private void generateArchivingTarget() { |
204 |
protected void generateArchivingTarget(boolean assembling) { |
| 179 |
script.printTargetDeclaration(TARGET_ASSEMBLE_ARCHIVE, null, null, null, null); |
205 |
script.printTargetDeclaration(TARGET_ASSEMBLE_ARCHIVE, null, null, assembling && BuildDirector.p2Gathering ? PROPERTY_RUN_PACKAGER : null, null); |
| 180 |
Map properties = new HashMap(); |
206 |
Map properties = new HashMap(); |
| 181 |
properties.put(PROPERTY_ROOT_FOLDER, rootFolder); |
207 |
properties.put(PROPERTY_ROOT_FOLDER, rootFolder); |
| 182 |
printCustomAssemblyAntCall(PROPERTY_PRE + "archive", properties); //$NON-NLS-1$ |
208 |
printCustomAssemblyAntCall(PROPERTY_PRE + "archive", properties); //$NON-NLS-1$ |
|
Lines 334-339
Link Here
|
| 334 |
script.printProperty(PROPERTY_ECLIPSE_PLUGINS, Utils.getPropertyFormat(PROPERTY_ECLIPSE_BASE) + '/' + DEFAULT_PLUGIN_LOCATION); |
360 |
script.printProperty(PROPERTY_ECLIPSE_PLUGINS, Utils.getPropertyFormat(PROPERTY_ECLIPSE_BASE) + '/' + DEFAULT_PLUGIN_LOCATION); |
| 335 |
script.printProperty(PROPERTY_ECLIPSE_FEATURES, Utils.getPropertyFormat(PROPERTY_ECLIPSE_BASE) + '/' + DEFAULT_FEATURE_LOCATION); |
361 |
script.printProperty(PROPERTY_ECLIPSE_FEATURES, Utils.getPropertyFormat(PROPERTY_ECLIPSE_BASE) + '/' + DEFAULT_FEATURE_LOCATION); |
| 336 |
script.printProperty(PROPERTY_ARCHIVE_FULLPATH, Utils.getPropertyFormat(PROPERTY_BASEDIR) + '/' + Utils.getPropertyFormat(PROPERTY_BUILD_LABEL) + '/' + Utils.getPropertyFormat(PROPERTY_ARCHIVE_NAME)); |
362 |
script.printProperty(PROPERTY_ARCHIVE_FULLPATH, Utils.getPropertyFormat(PROPERTY_BASEDIR) + '/' + Utils.getPropertyFormat(PROPERTY_BUILD_LABEL) + '/' + Utils.getPropertyFormat(PROPERTY_ARCHIVE_NAME)); |
|
|
363 |
printLauncherJarProperty(); |
| 364 |
script.printProperty(PROPERTY_P2_BUILD_REPO, "file:" + Utils.getPropertyFormat(PROPERTY_BUILD_DIRECTORY) + "/buildRepo"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 337 |
script.printAvailableTask(PROPERTY_CUSTOM_ASSEMBLY, "${builder}/customAssembly.xml", "${builder}/customAssembly.xml"); //$NON-NLS-1$ //$NON-NLS-2$ |
365 |
script.printAvailableTask(PROPERTY_CUSTOM_ASSEMBLY, "${builder}/customAssembly.xml", "${builder}/customAssembly.xml"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 338 |
|
366 |
|
| 339 |
if (productFile != null && productFile.getLauncherName() != null) |
367 |
if (productFile != null && productFile.getLauncherName() != null) |
|
Lines 345-350
Link Here
|
| 345 |
generatePackagingTargets(); |
373 |
generatePackagingTargets(); |
| 346 |
} |
374 |
} |
| 347 |
|
375 |
|
|
|
376 |
protected void printLauncherJarProperty() { |
| 377 |
Bundle launcherBundle = Platform.getBundle(BUNDLE_EQUINOX_LAUNCHER); |
| 378 |
try { |
| 379 |
File bundleFile = FileLocator.getBundleFile(launcherBundle); |
| 380 |
script.printProperty(PROPERTY_LAUNCHER_JAR, bundleFile.getAbsolutePath()); |
| 381 |
} catch (IOException e) { |
| 382 |
// what can we do with this? |
| 383 |
} |
| 384 |
} |
| 385 |
|
| 348 |
protected void generateCustomGatherMacro() { |
386 |
protected void generateCustomGatherMacro() { |
| 349 |
List attributes = new ArrayList(5); |
387 |
List attributes = new ArrayList(5); |
| 350 |
attributes.add("dir"); //$NON-NLS-1$ |
388 |
attributes.add("dir"); //$NON-NLS-1$ |
|
Lines 367-373
Link Here
|
| 367 |
script.println(); |
405 |
script.println(); |
| 368 |
} |
406 |
} |
| 369 |
|
407 |
|
| 370 |
private void printCustomGatherCall(String fullName, String dir, String propertyName, String propertyValue, String subFolder) { |
408 |
protected void printCustomGatherCall(String fullName, String dir, String propertyName, String propertyValue, String subFolder) { |
| 371 |
script.println("<" + PROPERTY_CUSTOM_GATHER + " dir=\"" + dir + "\" projectName=\"" + fullName + "\" propertyName=\"" + propertyName + "\" propertyValue=\"" + propertyValue + "\" subFolder=\"" + (subFolder != null ? subFolder : "") + "\" />"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ |
409 |
script.println("<" + PROPERTY_CUSTOM_GATHER + " dir=\"" + dir + "\" projectName=\"" + fullName + "\" propertyName=\"" + propertyName + "\" propertyValue=\"" + propertyValue + "\" subFolder=\"" + (subFolder != null ? subFolder : "") + "\" />"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ |
| 372 |
} |
410 |
} |
| 373 |
|
411 |
|
|
Lines 492-504
Link Here
|
| 492 |
if (embeddedSource) |
530 |
if (embeddedSource) |
| 493 |
generateGatherSourceTarget(); |
531 |
generateGatherSourceTarget(); |
| 494 |
generatePostProcessingTarget(); |
532 |
generatePostProcessingTarget(); |
| 495 |
generateArchivingTarget(); |
533 |
generateArchivingTarget(true); |
| 496 |
|
534 |
|
| 497 |
if (FORMAT_TAR.equalsIgnoreCase(archiveFormat)) |
535 |
if (FORMAT_TAR.equalsIgnoreCase(archiveFormat)) |
| 498 |
generateGZipTarget(true); |
536 |
generateGZipTarget(true); |
| 499 |
|
537 |
|
| 500 |
generateCustomAssemblyTarget(); |
538 |
generateCustomAssemblyTarget(); |
| 501 |
generateMetadataTarget(); |
539 |
generateMetadataTarget(); |
|
|
540 |
generateDirectorTarget(true); |
| 502 |
|
541 |
|
| 503 |
script.printProjectEnd(); |
542 |
script.printProjectEnd(); |
| 504 |
script.close(); |
543 |
script.close(); |
|
Lines 589-594
Link Here
|
| 589 |
} |
628 |
} |
| 590 |
|
629 |
|
| 591 |
script.printTargetEnd(); |
630 |
script.printTargetEnd(); |
|
|
631 |
script.println(); |
| 592 |
} |
632 |
} |
| 593 |
} |
633 |
} |
| 594 |
|
634 |
|
|
Lines 700-740
Link Here
|
| 700 |
|
740 |
|
| 701 |
//TODO this code and the generateAntTarTarget() should be refactored using a factory or something like that. |
741 |
//TODO this code and the generateAntTarTarget() should be refactored using a factory or something like that. |
| 702 |
protected void generateAntZipTarget() { |
742 |
protected void generateAntZipTarget() { |
| 703 |
FileSet[] filesPlugins = new FileSet[plugins.length]; |
743 |
List fileSets = new ArrayList(); |
| 704 |
for (int i = 0; i < plugins.length; i++) { |
|
|
| 705 |
Object[] shape = shapeAdvisor.getFinalShape(plugins[i]); |
| 706 |
filesPlugins[i] = new ZipFileSet(Utils.getPropertyFormat(PROPERTY_ECLIPSE_BASE) + '/' + DEFAULT_PLUGIN_LOCATION + '/' + (String) shape[0], shape[1] == ShapeAdvisor.FILE, null, null, null, null, null, Utils.getPropertyFormat(PROPERTY_PLUGIN_ARCHIVE_PREFIX) + '/' + (String) shape[0], null, null); |
| 707 |
} |
| 708 |
if (plugins.length != 0) |
| 709 |
script.printZipTask(Utils.getPropertyFormat(PROPERTY_ARCHIVE_FULLPATH), null, false, true, filesPlugins); |
| 710 |
|
744 |
|
| 711 |
FileSet[] filesFeatures = new FileSet[features.length]; |
745 |
if (BuildDirector.p2Gathering) { |
| 712 |
for (int i = 0; i < features.length; i++) { |
746 |
//TODO permissions |
| 713 |
Object[] shape = shapeAdvisor.getFinalShape(features[i]); |
747 |
fileSets.add(new ZipFileSet(Utils.getPropertyFormat(PROPERTY_ECLIPSE_BASE), false, null, "**/**", null, null, null, Utils.getPropertyFormat(PROPERTY_ARCHIVE_PREFIX), null, null)); //$NON-NLS-1$ |
| 714 |
filesFeatures[i] = new ZipFileSet(Utils.getPropertyFormat(PROPERTY_ECLIPSE_BASE) + '/' + DEFAULT_FEATURE_LOCATION + '/' + (String) shape[0], shape[1] == ShapeAdvisor.FILE, null, null, null, null, null, Utils.getPropertyFormat(PROPERTY_FEATURE_ARCHIVE_PREFIX) + '/' + (String) shape[0], null, null); |
748 |
} else { |
| 715 |
} |
749 |
for (int i = 0; i < plugins.length; i++) { |
| 716 |
if (features.length != 0) |
750 |
Object[] shape = shapeAdvisor.getFinalShape(plugins[i]); |
| 717 |
script.printZipTask(Utils.getPropertyFormat(PROPERTY_ARCHIVE_FULLPATH), null, false, true, filesFeatures); |
751 |
fileSets.add(new ZipFileSet(Utils.getPropertyFormat(PROPERTY_ECLIPSE_BASE) + '/' + DEFAULT_PLUGIN_LOCATION + '/' + (String) shape[0], shape[1] == ShapeAdvisor.FILE, null, null, null, null, null, Utils.getPropertyFormat(PROPERTY_PLUGIN_ARCHIVE_PREFIX) + '/' + (String) shape[0], null, null)); |
|
|
752 |
} |
| 718 |
|
753 |
|
| 719 |
if (rootFileProviders.size() == 0) |
754 |
for (int i = 0; i < features.length; i++) { |
| 720 |
return; |
755 |
Object[] shape = shapeAdvisor.getFinalShape(features[i]); |
|
|
756 |
fileSets.add(new ZipFileSet(Utils.getPropertyFormat(PROPERTY_ECLIPSE_BASE) + '/' + DEFAULT_FEATURE_LOCATION + '/' + (String) shape[0], shape[1] == ShapeAdvisor.FILE, null, null, null, null, null, Utils.getPropertyFormat(PROPERTY_FEATURE_ARCHIVE_PREFIX) + '/' + (String) shape[0], null, null)); |
| 757 |
} |
| 721 |
|
758 |
|
| 722 |
if (groupConfigs) { |
759 |
if (rootFileProviders.size() > 0) { |
| 723 |
List allConfigs = getConfigInfos(); |
760 |
if (groupConfigs) { |
| 724 |
FileSet[] rootFiles = new FileSet[allConfigs.size()]; |
761 |
List allConfigs = getConfigInfos(); |
| 725 |
int i = 0; |
762 |
for (Iterator iter = allConfigs.iterator(); iter.hasNext();) { |
| 726 |
for (Iterator iter = allConfigs.iterator(); iter.hasNext();) { |
763 |
Config elt = (Config) iter.next(); |
| 727 |
Config elt = (Config) iter.next(); |
764 |
fileSets.add(new ZipFileSet(Utils.getPropertyFormat(PROPERTY_ECLIPSE_BASE) + '/' + elt.toStringReplacingAny(".", ANY_STRING), false, null, "**/**", null, null, null, elt.toStringReplacingAny(".", ANY_STRING), null, null)); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ |
| 728 |
rootFiles[i++] = new ZipFileSet(Utils.getPropertyFormat(PROPERTY_ECLIPSE_BASE) + '/' + elt.toStringReplacingAny(".", ANY_STRING), false, null, "**/**", null, null, null, elt.toStringReplacingAny(".", ANY_STRING), null, null); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ |
765 |
} |
|
|
766 |
} else { |
| 767 |
FileSet[] permissions = generatePermissions(true); |
| 768 |
String toExcludeFromArchive = Utils.getStringFromCollection(this.addedByPermissions, ","); //$NON-NLS-1$ |
| 769 |
fileSets.add(new ZipFileSet(rootFolder, false, null, "**/**", null, toExcludeFromArchive, null, Utils.getPropertyFormat(PROPERTY_ARCHIVE_PREFIX), null, null)); //$NON-NLS-1$ |
| 770 |
fileSets.addAll(Arrays.asList(permissions)); |
| 771 |
} |
| 729 |
} |
772 |
} |
| 730 |
script.printZipTask(Utils.getPropertyFormat(PROPERTY_ARCHIVE_FULLPATH), null, false, true, rootFiles); |
773 |
} |
| 731 |
} else { |
774 |
if (fileSets.size() > 0) { |
| 732 |
FileSet[] permissionSets = generatePermissions(true); |
775 |
FileSet[] sets = (FileSet[]) fileSets.toArray(new FileSet[fileSets.size()]); |
| 733 |
FileSet[] rootFiles = new FileSet[permissionSets.length + 1]; |
776 |
script.printZipTask(Utils.getPropertyFormat(PROPERTY_ARCHIVE_FULLPATH), null, false, true, sets); |
| 734 |
String toExcludeFromArchive = Utils.getStringFromCollection(this.addedByPermissions, ","); //$NON-NLS-1$ |
|
|
| 735 |
System.arraycopy(permissionSets, 0, rootFiles, 1, permissionSets.length); |
| 736 |
rootFiles[0] = new ZipFileSet(rootFolder, false, null, "**/**", null, toExcludeFromArchive, null, Utils.getPropertyFormat(PROPERTY_ARCHIVE_PREFIX), null, null); //$NON-NLS-1$ |
| 737 |
script.printZipTask(Utils.getPropertyFormat(PROPERTY_ARCHIVE_FULLPATH), null, false, true, rootFiles); |
| 738 |
} |
777 |
} |
| 739 |
} |
778 |
} |
| 740 |
|
779 |
|