|
Lines 26-37
Link Here
|
| 26 |
|
26 |
|
| 27 |
// This class provides a higher level API on the state |
27 |
// This class provides a higher level API on the state |
| 28 |
public class PDEState implements IPDEBuildConstants, IBuildPropertiesConstants { |
28 |
public class PDEState implements IPDEBuildConstants, IBuildPropertiesConstants { |
| 29 |
private static final String[] MANIFEST_ENTRIES = {Constants.BUNDLE_LOCALIZATION, Constants.BUNDLE_NAME, Constants.BUNDLE_VENDOR, ECLIPSE_BUNDLE_SHAPE, ECLIPSE_SOURCE_BUNDLE}; |
29 |
private static final String[] MANIFEST_ENTRIES = {Constants.BUNDLE_LOCALIZATION, Constants.BUNDLE_NAME, Constants.BUNDLE_VENDOR, ECLIPSE_BUNDLE_SHAPE, ECLIPSE_SOURCE_BUNDLE, ECLIPSE_SOURCE_REFERENCES}; |
| 30 |
|
30 |
|
| 31 |
private StateObjectFactory factory; |
31 |
private StateObjectFactory factory; |
| 32 |
protected State state; |
32 |
protected State state; |
| 33 |
private long id; |
33 |
private long id; |
| 34 |
private Properties repositoryVersions; |
34 |
private Properties repositoryVersions; |
|
|
35 |
private Properties sourceReferences; |
| 35 |
private HashMap bundleClasspaths; |
36 |
private HashMap bundleClasspaths; |
| 36 |
private ProfileManager profileManager; |
37 |
private ProfileManager profileManager; |
| 37 |
private Map patchBundles; |
38 |
private Map patchBundles; |
|
Lines 68-73
Link Here
|
| 68 |
patchBundles = new HashMap(); |
69 |
patchBundles = new HashMap(); |
| 69 |
convertedManifests = new HashSet(2); |
70 |
convertedManifests = new HashSet(2); |
| 70 |
loadPluginTagFile(); |
71 |
loadPluginTagFile(); |
|
|
72 |
loadSourceReferences(); |
| 71 |
} |
73 |
} |
| 72 |
|
74 |
|
| 73 |
public StateObjectFactory getFactory() { |
75 |
public StateObjectFactory getFactory() { |
|
Lines 84-90
Link Here
|
| 84 |
|
86 |
|
| 85 |
//Add a bundle to the state, updating the version number |
87 |
//Add a bundle to the state, updating the version number |
| 86 |
public boolean addBundle(Dictionary enhancedManifest, File bundleLocation) { |
88 |
public boolean addBundle(Dictionary enhancedManifest, File bundleLocation) { |
| 87 |
updateVersionNumber(enhancedManifest); |
89 |
String oldVersion = updateVersionNumber(enhancedManifest); |
| 88 |
try { |
90 |
try { |
| 89 |
BundleDescription descriptor; |
91 |
BundleDescription descriptor; |
| 90 |
descriptor = factory.createBundleDescription(state, enhancedManifest, bundleLocation.getAbsolutePath(), getNextId()); |
92 |
descriptor = factory.createBundleDescription(state, enhancedManifest, bundleLocation.getAbsolutePath(), getNextId()); |
|
Lines 95-100
Link Here
|
| 95 |
rememberQualifierTagPresence(descriptor); |
97 |
rememberQualifierTagPresence(descriptor); |
| 96 |
rememberManifestConversion(descriptor, enhancedManifest); |
98 |
rememberManifestConversion(descriptor, enhancedManifest); |
| 97 |
rememberManifestEntries(descriptor, enhancedManifest, MANIFEST_ENTRIES); |
99 |
rememberManifestEntries(descriptor, enhancedManifest, MANIFEST_ENTRIES); |
|
|
100 |
rememberSourceReference(descriptor, oldVersion); |
| 98 |
if (addBundleDescription(descriptor) == true && addedBundle != null) |
101 |
if (addBundleDescription(descriptor) == true && addedBundle != null) |
| 99 |
addedBundle.add(descriptor); |
102 |
addedBundle.add(descriptor); |
| 100 |
} catch (BundleException e) { |
103 |
} catch (BundleException e) { |
|
Lines 115-120
Link Here
|
| 115 |
bundleProperties.setProperty(PROPERTY_QUALIFIER, "marker"); //$NON-NLS-1$ |
118 |
bundleProperties.setProperty(PROPERTY_QUALIFIER, "marker"); //$NON-NLS-1$ |
| 116 |
} |
119 |
} |
| 117 |
|
120 |
|
|
|
121 |
private void rememberSourceReference(BundleDescription descriptor, String oldVersion) { |
| 122 |
String key = QualifierReplacer.getQualifierKey(descriptor.getSymbolicName(), oldVersion); |
| 123 |
if (key != null && sourceReferences != null && sourceReferences.containsKey(key)) { |
| 124 |
Properties bundleProperties = (Properties) descriptor.getUserObject(); |
| 125 |
if (bundleProperties == null) { |
| 126 |
bundleProperties = new Properties(); |
| 127 |
descriptor.setUserObject(bundleProperties); |
| 128 |
} |
| 129 |
bundleProperties.setProperty(PROPERTY_SOURCE_REFERENCE, sourceReferences.getProperty(key)); |
| 130 |
} |
| 131 |
} |
| 132 |
|
| 118 |
private void rememberManifestEntries(BundleDescription descriptor, Dictionary manifest, String[] entries) { |
133 |
private void rememberManifestEntries(BundleDescription descriptor, Dictionary manifest, String[] entries) { |
| 119 |
if (entries == null || entries.length == 0) |
134 |
if (entries == null || entries.length == 0) |
| 120 |
return; |
135 |
return; |
|
Lines 181-186
Link Here
|
| 181 |
} |
196 |
} |
| 182 |
} |
197 |
} |
| 183 |
|
198 |
|
|
|
199 |
private void loadSourceReferences() { |
| 200 |
sourceReferences = new Properties(); |
| 201 |
try { |
| 202 |
InputStream input = new BufferedInputStream(new FileInputStream(AbstractScriptGenerator.getWorkingDirectory() + '/' + DEFAULT_SOURCE_REFERENCES_FILENAME_DESCRIPTOR)); |
| 203 |
try { |
| 204 |
sourceReferences.load(input); |
| 205 |
} finally { |
| 206 |
input.close(); |
| 207 |
} |
| 208 |
} catch (IOException e) { |
| 209 |
//Ignore |
| 210 |
} |
| 211 |
} |
| 212 |
|
| 184 |
public boolean addBundle(File bundleLocation) { |
213 |
public boolean addBundle(File bundleLocation) { |
| 185 |
Dictionary manifest; |
214 |
Dictionary manifest; |
| 186 |
manifest = loadManifest(bundleLocation); |
215 |
manifest = loadManifest(bundleLocation); |
|
Lines 194-213
Link Here
|
| 194 |
return addBundle(manifest, bundleLocation); |
223 |
return addBundle(manifest, bundleLocation); |
| 195 |
} |
224 |
} |
| 196 |
|
225 |
|
| 197 |
private void updateVersionNumber(Dictionary manifest) { |
226 |
private String updateVersionNumber(Dictionary manifest) { |
| 198 |
String newVersion = null; |
227 |
String newVersion = null; |
|
|
228 |
String oldVersion = null; |
| 199 |
try { |
229 |
try { |
| 200 |
String symbolicName = (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME); |
230 |
String symbolicName = (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME); |
| 201 |
if (symbolicName == null) |
231 |
if (symbolicName == null) |
| 202 |
return; |
232 |
return null; |
| 203 |
|
233 |
|
| 204 |
symbolicName = ManifestElement.parseHeader(Constants.BUNDLE_SYMBOLICNAME, symbolicName)[0].getValue(); |
234 |
symbolicName = ManifestElement.parseHeader(Constants.BUNDLE_SYMBOLICNAME, symbolicName)[0].getValue(); |
| 205 |
newVersion = QualifierReplacer.replaceQualifierInVersion((String) manifest.get(Constants.BUNDLE_VERSION), symbolicName, (String) manifest.get(PROPERTY_QUALIFIER), repositoryVersions); |
235 |
oldVersion = (String) manifest.get(Constants.BUNDLE_VERSION); |
|
|
236 |
newVersion = QualifierReplacer.replaceQualifierInVersion(oldVersion, symbolicName, (String) manifest.get(PROPERTY_QUALIFIER), repositoryVersions); |
| 206 |
} catch (BundleException e) { |
237 |
} catch (BundleException e) { |
| 207 |
//ignore |
238 |
//ignore |
| 208 |
} |
239 |
} |
| 209 |
if (newVersion != null) |
240 |
if (newVersion != null) |
| 210 |
manifest.put(Constants.BUNDLE_VERSION, newVersion); |
241 |
manifest.put(Constants.BUNDLE_VERSION, newVersion); |
|
|
242 |
return oldVersion; |
| 211 |
} |
243 |
} |
| 212 |
|
244 |
|
| 213 |
/** |
245 |
/** |