01: /*******************************************************************************
02: * Copyright (c) 2005 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM - Initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.build.packager;
11:
12: import java.util.*;
13: import org.eclipse.core.runtime.CoreException;
14: import org.eclipse.pde.internal.build.*;
15: import org.eclipse.pde.internal.build.builder.FeatureBuildScriptGenerator;
16: import org.eclipse.update.core.IFeature;
17: import org.eclipse.update.core.IIncludedFeatureReference;
18: import org.eclipse.update.core.model.IncludedFeatureReferenceModel;
19:
20: public class ElementCollector extends FeatureBuildScriptGenerator {
21: public ElementCollector(String featureId,
22: AssemblyInformation assemblageInformation)
23: throws CoreException {
24: super (featureId, null, assemblageInformation);
25: }
26:
27: protected void generateIncludedFeatureBuildFile()
28: throws CoreException {
29: IIncludedFeatureReference[] referencedFeatures = feature
30: .getIncludedFeatureReferences();
31: for (int i = 0; i < referencedFeatures.length; i++) {
32: String featureId = ((IncludedFeatureReferenceModel) referencedFeatures[i])
33: .getFeatureIdentifier();
34: FeatureBuildScriptGenerator generator = new ElementCollector(
35: featureId, assemblyData);
36: generator.setGenerateIncludedFeatures(true);
37: generator.setAnalyseChildren(true);
38: generator.setSourceFeatureGeneration(false);
39: generator.setBinaryFeatureGeneration(true);
40: generator.setScriptGeneration(false);
41: generator.setPluginPath(pluginPath);
42: generator.setBuildSiteFactory(siteFactory);
43: generator.setDevEntries(devEntries);
44: generator.setCompiledElements(getCompiledElements());
45: generator.setBuildingOSGi(isBuildingOSGi());
46: generator
47: .includePlatformIndependent(isPlatformIndependentIncluded());
48: generator
49: .setIgnoreMissingPropertiesFile(isIgnoreMissingPropertiesFile());
50: try {
51: generator.generate();
52: } catch (CoreException exception) {
53: //If the referenced feature is not optional, there is a real problem and the exception is re-thrown.
54: if (exception.getStatus().getCode() != EXCEPTION_FEATURE_MISSING
55: || (exception.getStatus().getCode() == EXCEPTION_FEATURE_MISSING && !referencedFeatures[i]
56: .isOptional()))
57: throw exception;
58: }
59: }
60: }
61:
62: protected void collectElementToAssemble(IFeature featureToCollect) {
63: if (assemblyData == null)
64: return;
65: List correctConfigs = selectConfigs(featureToCollect);
66: // Here, we could sort if the feature is a common one or not by comparing the size of correctConfigs
67: for (Iterator iter = correctConfigs.iterator(); iter.hasNext();) {
68: Config config = (Config) iter.next();
69: assemblyData.addFeature(config, feature);
70: }
71: }
72:
73: }
|