Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 243582 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/pde/build/Constants.java (-5 / +42 lines)
Lines 1-5 Link Here
1
/**********************************************************************
1
/**********************************************************************
2
 * Copyright (c) 2006 Eclipse Foundation and others.
2
 * Copyright (c) 2006, 2010 Eclipse Foundation and others.
3
 * All rights reserved.   This program and the accompanying materials
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 9-15 Link Here
9
 *     Gunnar Wagenknecht - Initial API and implementation
9
 *     Gunnar Wagenknecht - Initial API and implementation
10
 *     IBM Corporation - Initial API and implementation
10
 *     IBM Corporation - Initial API and implementation
11
 **********************************************************************/
11
 **********************************************************************/
12
 package org.eclipse.pde.build;
12
package org.eclipse.pde.build;
13
13
14
/**
14
/**
15
 * Constants for the files usually manipulated by the fetch factory.
15
 * Constants for the files usually manipulated by the fetch factory.
Lines 19-31 Link Here
19
public interface Constants {
19
public interface Constants {
20
	/** Constant for the string <code>feature.xml</code> */
20
	/** Constant for the string <code>feature.xml</code> */
21
	public final static String FEATURE_FILENAME_DESCRIPTOR = "feature.xml"; //$NON-NLS-1$
21
	public final static String FEATURE_FILENAME_DESCRIPTOR = "feature.xml"; //$NON-NLS-1$
22
	
22
23
	/** Constant for the string <code>fragment.xml</code> */
23
	/** Constant for the string <code>fragment.xml</code> */
24
	public final static String FRAGMENT_FILENAME_DESCRIPTOR = "fragment.xml"; //$NON-NLS-1$
24
	public final static String FRAGMENT_FILENAME_DESCRIPTOR = "fragment.xml"; //$NON-NLS-1$
25
	
25
26
	/** Constant for the string <code>plugin.xml</code> */
26
	/** Constant for the string <code>plugin.xml</code> */
27
	public final static String PLUGIN_FILENAME_DESCRIPTOR = "plugin.xml"; //$NON-NLS-1$
27
	public final static String PLUGIN_FILENAME_DESCRIPTOR = "plugin.xml"; //$NON-NLS-1$
28
	
28
29
	/** Constant for the string <code>META-INF/MANIFEST.MF</code> */
29
	/** Constant for the string <code>META-INF/MANIFEST.MF</code> */
30
	public final static String BUNDLE_FILENAME_DESCRIPTOR = "META-INF/MANIFEST.MF"; //$NON-NLS-1$
30
	public final static String BUNDLE_FILENAME_DESCRIPTOR = "META-INF/MANIFEST.MF"; //$NON-NLS-1$
31
32
	/**
33
	 * Key used to specify directives for the {@link #KEY_SOURCE_REFERENCE}.
34
	 * 
35
	 *  For {@link #KEY_SOURCE_REFERENCE_TYPE} == "psf", a "provider" directive is required specifying the value of 
36
	 *  an <code>org.eclipse.team.core.repository</code> extension identifier that provides a project set 
37
	 *  capability that can interpret the project reference.
38
	 *  <p>
39
	 *  Example: KEY_SOURCE_DIRECTIVES = "provider:=\"org.eclipse.team.cvs.core.cvsnature\""
40
	 *  </p>
41
	 * 
42
	 * @since 3.6
43
	 * @see IFetchFactory
44
	 */
45
	public static final String KEY_SOURCE_DIRECTIVES = "sourceDirectives"; //$NON-NLS-1$
46
47
	/**
48
	 * Key used to store the value of a project reference in the Eclipse-SourceReferences manifest
49
	 * header.  
50
	 * 
51
	 * @since 3.6
52
	 * @see IFetchFactory
53
	 */
54
	public static final String KEY_SOURCE_REFERENCE = "sourceReference"; //$NON-NLS-1$
55
56
	/** 
57
	 * Key used to store the type of the project reference {@link #KEY_SOURCE_REFERENCE}
58
	 * 
59
	 * A type of "psf" is interpreted as repository provider's project set capability to recreate a project
60
	 * in a workspace.  The "psf" reference type requires a {@link #KEY_SOURCE_DIRECTIVES} specifying a "provider" 
61
	 * directive indicating the provider of the project set capability.
62
	 * 
63
	 * @since 3.6
64
	 * @see IFetchFactory
65
	 * @see #KEY_SOURCE_DIRECTIVES
66
	 */
67
	public static final String KEY_SOURCE_REFERENCE_TYPE = "sourceReferenceType"; //$NON-NLS-1$
31
}
68
}
(-)src/org/eclipse/pde/build/IFetchFactory.java (-2 / +10 lines)
Lines 1-5 Link Here
1
/**********************************************************************
1
/**********************************************************************
2
 * Copyright (c) 2004, 2006 Eclipse Foundation and others.
2
 * Copyright (c) 2004, 2010 Eclipse Foundation and others.
3
 * All rights reserved.   This program and the accompanying materials
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 82-88 Link Here
82
	 * infos should be filled with provider specific information that is
82
	 * infos should be filled with provider specific information that is
83
	 * required in later processing to sucessfully generate the fetch script.
83
	 * required in later processing to sucessfully generate the fetch script.
84
	 * </p>
84
	 * </p>
85
	 * 
85
	 * <p>
86
	 * Since 3.6, factories may optionally set {@link Constants#KEY_SOURCE_REFERENCE}, {@link Constants#KEY_SOURCE_REFERENCE_TYPE}, and
87
	 * {@link Constants#KEY_SOURCE_DIRECTIVES} properties in the entry infos map to support the inclusion of source references in the bundle
88
	 * manifest using the Eclipse-SourceRefernces header.<br>
89
	 * Example:<br>
90
	 *     KEY_SOURCE_REFERENCE_TYPE = "psf"<br>
91
	 *     KEY_SOURCE_DIRECTIVES = "provider:=\"org.eclipse.team.cvs.core.cvsnature\""<br>
92
	 *     KEY_SOURCE_REFERENCE = "1.0,:extssh:dev.eclipse.org:/cvsroot/eclipse,pde/build/org.eclipse.pde.build,org.eclipse.pde.build,v20100222"<br>
93
	 * </p>
86
	 * @param rawEntry the arguments as specified in the map file (may not be <code>null</code>).
94
	 * @param rawEntry the arguments as specified in the map file (may not be <code>null</code>).
87
	 * @param overrideTags a key / value containing all the override tags specified for all the repository (maybe <code>null</code> or empty). 
95
	 * @param overrideTags a key / value containing all the override tags specified for all the repository (maybe <code>null</code> or empty). 
88
	 * The values of this map of this are read from the fetchTag property (see file scripts/templates/headless-build/build.properties). 
96
	 * The values of this map of this are read from the fetchTag property (see file scripts/templates/headless-build/build.properties). 
(-)src/org/eclipse/pde/internal/build/FetchScriptGenerator.java (-5 / +22 lines)
Lines 62-67 Link Here
62
	// A property table containing the association between the plugins and the version from the map  
62
	// A property table containing the association between the plugins and the version from the map  
63
	protected Properties repositoryPluginTags = new Properties();
63
	protected Properties repositoryPluginTags = new Properties();
64
	protected Properties repositoryFeatureTags = new Properties();
64
	protected Properties repositoryFeatureTags = new Properties();
65
	protected Properties sourceReferences = new Properties();
65
66
66
	//The registry of the task factories
67
	//The registry of the task factories
67
	private FetchTaskFactoriesRegistry fetchTaskFactories;
68
	private FetchTaskFactoriesRegistry fetchTaskFactories;
Lines 156-161 Link Here
156
	private void saveRepositoryTags() throws CoreException {
157
	private void saveRepositoryTags() throws CoreException {
157
		saveRepositoryTags(repositoryPluginTags, DEFAULT_PLUGIN_REPOTAG_FILENAME_DESCRIPTOR);
158
		saveRepositoryTags(repositoryPluginTags, DEFAULT_PLUGIN_REPOTAG_FILENAME_DESCRIPTOR);
158
		saveRepositoryTags(repositoryFeatureTags, DEFAULT_FEATURE_REPOTAG_FILENAME_DESCRIPTOR);
159
		saveRepositoryTags(repositoryFeatureTags, DEFAULT_FEATURE_REPOTAG_FILENAME_DESCRIPTOR);
160
		saveRepositoryTags(sourceReferences, DEFAULT_SOURCE_REFERENCES_FILENAME_DESCRIPTOR);
159
	}
161
	}
160
162
161
	/**
163
	/**
Lines 362-367 Link Here
362
			factory.generateRetrieveFilesCall(mapFileEntry, computeFinalLocation(type, elementToFetch, (Version) mapFileEntry.get(MATCHED_VERSION)), files, script);
364
			factory.generateRetrieveFilesCall(mapFileEntry, computeFinalLocation(type, elementToFetch, (Version) mapFileEntry.get(MATCHED_VERSION)), files, script);
363
		}
365
		}
364
366
367
		//key to use for version and source references properties files
368
		String key = null;
369
		if (version.getQualifier().endsWith(PROPERTY_QUALIFIER))
370
			key = QualifierReplacer.getQualifierKey(elementToFetch, version.toString());
371
		else
372
			key = elementToFetch + ',' + new Version(version.getMajor(), version.getMinor(), version.getMicro()).toString();
365
		//Keep track of the element that are being fetched. To simplify the lookup in the qualifier replacer, the versioned that was initially looked up is used as key in the file
373
		//Keep track of the element that are being fetched. To simplify the lookup in the qualifier replacer, the versioned that was initially looked up is used as key in the file
366
		Properties tags = null;
374
		Properties tags = null;
367
		if (type.equals(IFetchFactory.ELEMENT_TYPE_FEATURE))
375
		if (type.equals(IFetchFactory.ELEMENT_TYPE_FEATURE))
Lines 369-380 Link Here
369
		else
377
		else
370
			tags = repositoryPluginTags;
378
			tags = repositoryPluginTags;
371
		if (mapFileEntry.get(IFetchFactory.KEY_ELEMENT_TAG) != null) {
379
		if (mapFileEntry.get(IFetchFactory.KEY_ELEMENT_TAG) != null) {
372
			if (version.getQualifier().endsWith(PROPERTY_QUALIFIER)) {
380
			tags.put(key, mapFileEntry.get(IFetchFactory.KEY_ELEMENT_TAG));
373
				String key = QualifierReplacer.getQualifierKey(elementToFetch, version.toString());
381
		}
374
				tags.put(key, mapFileEntry.get(IFetchFactory.KEY_ELEMENT_TAG));
382
375
			} else {
383
		if (mapFileEntry.get(Constants.KEY_SOURCE_REFERENCE) != null) {
376
				tags.put(elementToFetch + ',' + new Version(version.getMajor(), version.getMinor(), version.getMicro()), mapFileEntry.get(IFetchFactory.KEY_ELEMENT_TAG));
384
			StringBuffer buffer = new StringBuffer((String) mapFileEntry.get(Constants.KEY_SOURCE_REFERENCE));
385
			if (mapFileEntry.get(Constants.KEY_SOURCE_REFERENCE_TYPE) != null) {
386
				buffer.append(";type:="); //$NON-NLS-1$
387
				buffer.append(mapFileEntry.get(Constants.KEY_SOURCE_REFERENCE_TYPE));
388
			}
389
			if (mapFileEntry.get(Constants.KEY_SOURCE_DIRECTIVES) != null) {
390
				buffer.append(';');
391
				buffer.append(mapFileEntry.get(Constants.KEY_SOURCE_DIRECTIVES));
377
			}
392
			}
393
394
			sourceReferences.put(key, buffer.toString());
378
		}
395
		}
379
396
380
		return true;
397
		return true;
(-)src/org/eclipse/pde/internal/build/IBuildPropertiesConstants.java (+1 lines)
Lines 34-39 Link Here
34
	public static final String PROPERTY_MANIFEST_PREFIX = "manifest."; //$NON-NLS-1$
34
	public static final String PROPERTY_MANIFEST_PREFIX = "manifest."; //$NON-NLS-1$
35
35
36
	public static final String PROPERTY_CONVERTED_MANIFEST = "convertedManifest"; //$NON-NLS-1$
36
	public static final String PROPERTY_CONVERTED_MANIFEST = "convertedManifest"; //$NON-NLS-1$
37
	public static final String PROPERTY_SOURCE_REFERENCE = "sourceReference"; //$NON-NLS-1$
37
	public static final String PROPERTY_QUALIFIER = "qualifier"; //$NON-NLS-1$
38
	public static final String PROPERTY_QUALIFIER = "qualifier"; //$NON-NLS-1$
38
	public static final String PROPERTY_VERSION_REPLACEMENT = "versionReplacement"; //$NON-NLS-1$
39
	public static final String PROPERTY_VERSION_REPLACEMENT = "versionReplacement"; //$NON-NLS-1$
39
	public static final String PROPERTY_REQUIRED_BUNDLE_IDS = "requiredBundleIds"; //$NON-NLS-1$
40
	public static final String PROPERTY_REQUIRED_BUNDLE_IDS = "requiredBundleIds"; //$NON-NLS-1$
(-)src/org/eclipse/pde/internal/build/IPDEBuildConstants.java (+2 lines)
Lines 58-63 Link Here
58
	public final static String DEFAULT_UNZIPPER_FILENAME_DESCRIPTOR = "unzipper.xml"; //$NON-NLS-1$
58
	public final static String DEFAULT_UNZIPPER_FILENAME_DESCRIPTOR = "unzipper.xml"; //$NON-NLS-1$
59
	public final static String DEFAULT_PLUGIN_REPOTAG_FILENAME_DESCRIPTOR = "pluginVersions.properties"; //$NON-NLS-1$
59
	public final static String DEFAULT_PLUGIN_REPOTAG_FILENAME_DESCRIPTOR = "pluginVersions.properties"; //$NON-NLS-1$
60
	public final static String DEFAULT_FEATURE_REPOTAG_FILENAME_DESCRIPTOR = "featureVersions.properties"; //$NON-NLS-1$
60
	public final static String DEFAULT_FEATURE_REPOTAG_FILENAME_DESCRIPTOR = "featureVersions.properties"; //$NON-NLS-1$
61
	public final static String DEFAULT_SOURCE_REFERENCES_FILENAME_DESCRIPTOR = "sourceReferences.properties"; //$NON-NLS-1$
61
	public final static String DEFAULT_PLUGINS_POSTPROCESSINGSTEPS_FILENAME_DESCRIPTOR = "plugins.postProcessingSteps.properties"; //$NON-NLS-1$
62
	public final static String DEFAULT_PLUGINS_POSTPROCESSINGSTEPS_FILENAME_DESCRIPTOR = "plugins.postProcessingSteps.properties"; //$NON-NLS-1$
62
	public final static String DEFAULT_FEATURES_POSTPROCESSINGSTEPS_FILENAME_DESCRIPTOR = "features.postProcessingSteps.properties"; //$NON-NLS-1$
63
	public final static String DEFAULT_FEATURES_POSTPROCESSINGSTEPS_FILENAME_DESCRIPTOR = "features.postProcessingSteps.properties"; //$NON-NLS-1$
63
	public final static String DEFAULT_CUSTOM_BUILD_CALLBACKS_FILE = "customBuildCallbacks.xml"; //$NON-NLS-1$
64
	public final static String DEFAULT_CUSTOM_BUILD_CALLBACKS_FILE = "customBuildCallbacks.xml"; //$NON-NLS-1$
Lines 120-125 Link Here
120
	public final static String ECLIPSE_SOURCE_BUNDLE = "Eclipse-SourceBundle"; //$NON-NLS-1$
121
	public final static String ECLIPSE_SOURCE_BUNDLE = "Eclipse-SourceBundle"; //$NON-NLS-1$
121
	public final static String ECLIPSE_PLATFORM_FILTER = "Eclipse-PlatformFilter"; //$NON-NLS-1$
122
	public final static String ECLIPSE_PLATFORM_FILTER = "Eclipse-PlatformFilter"; //$NON-NLS-1$
122
	public final static String ECLIPSE_BUNDLE_SHAPE = "Eclipse-BundleShape"; //$NON-NLS-1$
123
	public final static String ECLIPSE_BUNDLE_SHAPE = "Eclipse-BundleShape"; //$NON-NLS-1$
124
	public final static String ECLIPSE_SOURCE_REFERENCES = "Eclipse-SourceReferences"; //$NON-NLS-1$
123
125
124
	//Some Bundle IDs we care about
126
	//Some Bundle IDs we care about
125
	public final static String BUNDLE_OSGI = "org.eclipse.osgi"; //$NON-NLS-1$
127
	public final static String BUNDLE_OSGI = "org.eclipse.osgi"; //$NON-NLS-1$
(-)src/org/eclipse/pde/internal/build/builder/ModelBuildScriptGenerator.java (-2 / +10 lines)
Lines 791-799 Link Here
791
			return;
791
			return;
792
792
793
		String qualifier = bundleProperties.getProperty(PROPERTY_QUALIFIER);
793
		String qualifier = bundleProperties.getProperty(PROPERTY_QUALIFIER);
794
		if (qualifier == null)
794
		String sourceReference = bundleProperties.getProperty(PROPERTY_SOURCE_REFERENCE);
795
		if (qualifier == null && sourceReference == null)
795
			return;
796
			return;
796
		script.println("<eclipse.versionReplacer path=\"" + AntScript.getEscaped(location) + "\" version=\"" + model.getVersion() + "\"/>"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
797
798
		Map arguments = new HashMap();
799
		arguments.put("path", AntScript.getEscaped(location)); //$NON-NLS-1$
800
		if (qualifier != null)
801
			arguments.put("version", model.getVersion().toString()); //$NON-NLS-1$
802
		if (sourceReference != null)
803
			arguments.put("attributes", ECLIPSE_SOURCE_REFERENCES + '|' + sourceReference); //$NON-NLS-1$
804
		script.printElement("eclipse.versionReplacer", arguments); //$NON-NLS-1$
797
	}
805
	}
798
806
799
	private void generatePermissionProperties(String directory) throws CoreException {
807
	private void generatePermissionProperties(String directory) throws CoreException {
(-)src/org/eclipse/pde/internal/build/fetch/CVSFetchTaskFactory.java (-1 / +45 lines)
Lines 59-64 Link Here
59
	private static final String PROP_FILETOCHECK = "fileToCheck"; //$NON-NLS-1$
59
	private static final String PROP_FILETOCHECK = "fileToCheck"; //$NON-NLS-1$
60
	private static final String PROP_ELEMENTNAME = "elementName"; //$NON-NLS-1$
60
	private static final String PROP_ELEMENTNAME = "elementName"; //$NON-NLS-1$
61
61
62
	//Associated repository provider
63
	private static final String PSF = "psf"; //$NON-NLS-1$
64
	private static final String CVS_DIRECTIVE = "provider:=\"org.eclipse.team.cvs.core.cvsnature\""; //$NON-NLS-1$
65
62
	private void generateAuthentificationAntTask(Map entryInfos, IAntScript script) {
66
	private void generateAuthentificationAntTask(Map entryInfos, IAntScript script) {
63
		String password = (String) entryInfos.get(KEY_PASSWORD);
67
		String password = (String) entryInfos.get(KEY_PASSWORD);
64
		String cvsPassFileLocation = (String) entryInfos.get(KEY_CVSPASSFILE);
68
		String cvsPassFileLocation = (String) entryInfos.get(KEY_CVSPASSFILE);
Lines 139-145 Link Here
139
			String tag = (String) entryInfos.get(IFetchFactory.KEY_ELEMENT_TAG);
143
			String tag = (String) entryInfos.get(IFetchFactory.KEY_ELEMENT_TAG);
140
			String cvsRoot = (String) entryInfos.get(KEY_CVSROOT);
144
			String cvsRoot = (String) entryInfos.get(KEY_CVSROOT);
141
			String dest = "true".equalsIgnoreCase((String) entryInfos.get(KEY_PREBUILT)) ? destination.removeLastSegments(1).toString() : destination.toString(); //$NON-NLS-1$
145
			String dest = "true".equalsIgnoreCase((String) entryInfos.get(KEY_PREBUILT)) ? destination.removeLastSegments(1).toString() : destination.toString(); //$NON-NLS-1$
142
			printCVSTask("export -r " + tag + ' ' + filePath.toString(), cvsRoot, dest, null, null, "true", Utils.getPropertyFormat(PROP_REALLYQUIET), null, null, "${fetch.failonerror}", script); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-5$
146
			printCVSTask("export -r " + tag + ' ' + filePath.toString(), cvsRoot, dest, null, null, "true", Utils.getPropertyFormat(PROP_REALLYQUIET), null, null, "${fetch.failonerror}", script); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
143
			script.println("<move file=\"" + destination + '/' + filePath + "\"" + " tofile=\"" + destination.append(file) + "\" failonerror=\"false\" />"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
147
			script.println("<move file=\"" + destination + '/' + filePath + "\"" + " tofile=\"" + destination.append(file) + "\" failonerror=\"false\" />"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
144
		}
148
		}
145
	}
149
	}
Lines 180-185 Link Here
180
			int index = arg.indexOf('=');
184
			int index = arg.indexOf('=');
181
			if (index == -1) {
185
			if (index == -1) {
182
				legacyParseMapFileEntry(arguments, overrideTags, entryInfos);
186
				legacyParseMapFileEntry(arguments, overrideTags, entryInfos);
187
				addProjectReference(entryInfos);
183
				return;
188
				return;
184
			}
189
			}
185
			String key = arg.substring(0, index);
190
			String key = arg.substring(0, index);
Lines 197-202 Link Here
197
		entryInfos.put(KEY_PASSWORD, table.get(KEY_PASSWORD));
202
		entryInfos.put(KEY_PASSWORD, table.get(KEY_PASSWORD));
198
		entryInfos.put(KEY_PATH, table.get(KEY_PATH));
203
		entryInfos.put(KEY_PATH, table.get(KEY_PATH));
199
		entryInfos.put(KEY_PREBUILT, table.get(KEY_PREBUILT));
204
		entryInfos.put(KEY_PREBUILT, table.get(KEY_PREBUILT));
205
		addProjectReference(entryInfos);
206
	}
207
208
	private void addProjectReference(Map entryInfos) {
209
		String repoLocation = (String) entryInfos.get(KEY_CVSROOT);
210
		String module = (String) entryInfos.get(KEY_PATH);
211
		String projectName = (String) entryInfos.get(KEY_ELEMENT_NAME);
212
		String tag = (String) entryInfos.get(IFetchFactory.KEY_ELEMENT_TAG);
213
		if (repoLocation != null && module != null && projectName != null) {
214
			entryInfos.put(Constants.KEY_SOURCE_REFERENCE_TYPE, PSF);
215
			entryInfos.put(Constants.KEY_SOURCE_DIRECTIVES, CVS_DIRECTIVE);
216
			entryInfos.put(Constants.KEY_SOURCE_REFERENCE, asReference(repoLocation, module, projectName, tag));
217
		}
218
	}
219
220
	/**
221
	 * Creates a project reference memento.
222
	 * 
223
	 * @param repoLocation
224
	 * @param module
225
	 * @param projectName
226
	 * @return project reference string
227
	 */
228
	private String asReference(String repoLocation, String module, String projectName, String tagName) {
229
		StringBuffer buffer = new StringBuffer();
230
		buffer.append("1.0,"); //$NON-NLS-1$
231
232
		buffer.append(repoLocation);
233
		buffer.append(","); //$NON-NLS-1$
234
235
		buffer.append(module);
236
		buffer.append(","); //$NON-NLS-1$
237
238
		buffer.append(projectName);
239
		if (tagName != null) {
240
			buffer.append(","); //$NON-NLS-1$
241
			buffer.append(tagName);
242
		}
243
		return buffer.toString();
200
	}
244
	}
201
245
202
	/**
246
	/**
(-)src/org/eclipse/pde/internal/build/site/PDEState.java (-5 / +37 lines)
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
	/**
(-)src_ant/org/eclipse/pde/internal/build/tasks/GenericVersionReplacer.java (+7 lines)
Lines 24-29 Link Here
24
	private static final String MANIFEST = "META-INF/MANIFEST.MF"; //$NON-NLS-1$
24
	private static final String MANIFEST = "META-INF/MANIFEST.MF"; //$NON-NLS-1$
25
	private String rootPath;
25
	private String rootPath;
26
	private String version;
26
	private String version;
27
	private String attributes;
27
28
28
	public void execute() {
29
	public void execute() {
29
		File root = new File(rootPath);
30
		File root = new File(rootPath);
Lines 58-63 Link Here
58
		modifier.setProject(getProject());
59
		modifier.setProject(getProject());
59
		modifier.setManifestLocation(path);
60
		modifier.setManifestLocation(path);
60
		modifier.setKeyValue("Bundle-Version|" + version); //$NON-NLS-1$
61
		modifier.setKeyValue("Bundle-Version|" + version); //$NON-NLS-1$
62
		if (attributes != null)
63
			modifier.setKeyValue(attributes);
61
		modifier.execute();
64
		modifier.execute();
62
	}
65
	}
63
66
Lines 76-79 Link Here
76
	public void setVersion(String version) {
79
	public void setVersion(String version) {
77
		this.version = version;
80
		this.version = version;
78
	}
81
	}
82
83
	public void setAttributes(String attributes) {
84
		this.attributes = attributes;
85
	}
79
}
86
}

Return to bug 243582