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 34757 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/pde/internal/build/IXMLConstants.java (-1 / +1 lines)
Lines 53-59 Link Here
53
	public static final String TARGET_FETCH_ELEMENT = "fetch.element"; //$NON-NLS-1$
53
	public static final String TARGET_FETCH_ELEMENT = "fetch.element"; //$NON-NLS-1$
54
	public static final String TARGET_FETCH_PLUGINS = "fetch.plugins"; //$NON-NLS-1$
54
	public static final String TARGET_FETCH_PLUGINS = "fetch.plugins"; //$NON-NLS-1$
55
	public static final String TARGET_FETCH_RECURSIVELY = "fetch.recursively"; //$NON-NLS-1$
55
	public static final String TARGET_FETCH_RECURSIVELY = "fetch.recursively"; //$NON-NLS-1$
56
	public static final String TARGET_GET_FROM_CVS = "getFromCVS"; //$NON-NLS-1$
56
	public static final String TARGET_FETCH_FROM_REPOSITORY = "fetchFromRepository"; //$NON-NLS-1$
57
	public static final String TARGET_EFFECTIVE_FETCH = "effectiveFetch"; //$NON-NLS-1$
57
	public static final String TARGET_EFFECTIVE_FETCH = "effectiveFetch"; //$NON-NLS-1$
58
	public static final String TARGET_JARUP = "jarUp"; //$NON-NLS-1$
58
	public static final String TARGET_JARUP = "jarUp"; //$NON-NLS-1$
59
	public static final String TARGET_JARING = "jarIng"; //$NON-NLS-1$
59
	public static final String TARGET_JARING = "jarIng"; //$NON-NLS-1$
(-)src/org/eclipse/pde/internal/build/IPDEBuildConstants.java (+6 lines)
Lines 113-116 Link Here
113
	public final static String OSGI_OS = "osgi.os";  //$NON-NLS-1$
113
	public final static String OSGI_OS = "osgi.os";  //$NON-NLS-1$
114
	public final static String OSGI_ARCH = "osgi.arch";  //$NON-NLS-1$
114
	public final static String OSGI_ARCH = "osgi.arch";  //$NON-NLS-1$
115
	public final static String OSGI_NL = "osgi.nl";  //$NON-NLS-1$
115
	public final static String OSGI_NL = "osgi.nl";  //$NON-NLS-1$
116
	
117
	// fetch task extension point
118
	public final static String EXT_FETCH_TASK_FACTORIES = "org.eclipse.pde.build.fetchTaskFactories"; //$NON-NLS-1$
119
	public final static String ATTR_ID = "id"; //$NON-NLS-1$
120
	public final static String ATTR_CLASS = "class"; //$NON-NLS-1$
121
	public final static String ELEM_FACTORY = "factory"; //$NON-NLS-1$
116
}
122
}
(-)src/org/eclipse/pde/internal/build/BuildActivator.java (+1 lines)
Lines 20-24 Link Here
20
20
21
	public void stop(BundleContext ctx) throws Exception {
21
	public void stop(BundleContext ctx) throws Exception {
22
		BundleHelper.close();
22
		BundleHelper.close();
23
        FetchTaskFactoriesRegistry.shutdown();
23
	}
24
	}
24
}
25
}
(-)src/org/eclipse/pde/internal/build/FetchScriptGenerator.java (-91 / +120 lines)
Lines 15-44 Link Here
15
import org.eclipse.ant.core.AntRunner;
15
import org.eclipse.ant.core.AntRunner;
16
import org.eclipse.core.runtime.*;
16
import org.eclipse.core.runtime.*;
17
import org.eclipse.osgi.util.NLS;
17
import org.eclipse.osgi.util.NLS;
18
import org.eclipse.pde.build.FetchTaskFactory;
18
import org.eclipse.pde.internal.build.ant.AntScript;
19
import org.eclipse.pde.internal.build.ant.AntScript;
20
import org.eclipse.pde.internal.build.fetch.CVSFetchTaskFactory;
19
import org.eclipse.update.core.*;
21
import org.eclipse.update.core.*;
20
import org.eclipse.update.internal.core.FeatureExecutableFactory;
22
import org.eclipse.update.internal.core.FeatureExecutableFactory;
21
23
22
/**
24
/**
23
 * Generates Ant scripts which will use the CVS "fetch" element
25
 * Generates Ant scripts with a repository specific factory
24
 * to retrieve plug-ins and features from the CVS repository.
26
 * to retrieve plug-ins and features from a repository.
25
 */
27
 */
26
public class FetchScriptGenerator extends AbstractScriptGenerator {
28
public class FetchScriptGenerator extends AbstractScriptGenerator {
27
	private static final String BUNDLE = "bundle"; //$NON-NLS-1$
29
	private static final String BUNDLE = FetchTaskFactory.ELEMENT_TYPE_BUNDLE;
28
	private static final String FRAGMENT = "fragment"; //$NON-NLS-1$
30
	private static final String FRAGMENT = FetchTaskFactory.ELEMENT_TYPE_FRAGMENT;
29
	private static final String PLUGIN = "plugin"; //$NON-NLS-1$
31
	private static final String PLUGIN = FetchTaskFactory.ELEMENT_TYPE_PLUGIN;
30
	private static final String FEATURE = "feature"; //$NON-NLS-1$
32
	private static final String FEATURE = FetchTaskFactory.ELEMENT_TYPE_FEATURE;
31
	private static final String ELEMENT = "element"; //$NON-NLS-1$
33
	private static final String ELEMENT = FetchTaskFactory.KEY_ELEMENT_NAME;
32
	private static final String TYPE = "type"; //$NON-NLS-1$
34
	private static final String TYPE = FetchTaskFactory.KEY_ELEMENT_TYPE;
33
	private static final String PATH = "path"; //$NON-NLS-1$
35
	private static final String FETCH_TASK_FACTORY = FetchTaskFactory.KEY_FACTORY;
34
	private static final String PASSWORD = "password"; //$NON-NLS-1$
35
	private static final String CVSROOT = "cvsRoot"; //$NON-NLS-1$
36
	private static final String TAG = "tag"; //$NON-NLS-1$
37
36
38
	// flag saying if we want to recursively generate the scripts	
37
	// flag saying if we want to recursively generate the scripts	
39
	protected boolean recursiveGeneration = true;
38
	protected boolean recursiveGeneration = true;
40
39
41
	// Points to the map files containing references to cvs repository
40
	// Points to the map files containing references to repository
42
	protected String directoryLocation;
41
	protected String directoryLocation;
43
	protected Properties directory;
42
	protected Properties directory;
44
43
Lines 101-107 Link Here
101
			closeScript();
100
			closeScript();
102
		}
101
		}
103
102
104
		if (recursiveGeneration && mapInfos.get(TYPE).equals(FEATURE)) 
103
		if (recursiveGeneration && mapInfos.get(TYPE).equals(FEATURE))
105
			generateFetchFilesForIncludedFeatures();
104
			generateFetchFilesForIncludedFeatures();
106
105
107
		saveRepositoryTags();
106
		saveRepositoryTags();
Lines 109-115 Link Here
109
108
110
	private void saveRepositoryTags(Properties properties, String fileName) throws CoreException {
109
	private void saveRepositoryTags(Properties properties, String fileName) throws CoreException {
111
		try {
110
		try {
112
			InputStream input = new BufferedInputStream(new FileInputStream(workingDirectory + '/' + fileName)); 
111
			InputStream input = new BufferedInputStream(new FileInputStream(workingDirectory + '/' + fileName));
113
			try {
112
			try {
114
				properties.load(input);
113
				properties.load(input);
115
			} finally {
114
			} finally {
Lines 131-137 Link Here
131
			throw new CoreException(new Status(IStatus.ERROR, PI_PDEBUILD, EXCEPTION_WRITING_FILE, message, null));
130
			throw new CoreException(new Status(IStatus.ERROR, PI_PDEBUILD, EXCEPTION_WRITING_FILE, message, null));
132
		}
131
		}
133
	}
132
	}
134
	
133
135
	private void saveRepositoryTags() throws CoreException {
134
	private void saveRepositoryTags() throws CoreException {
136
		saveRepositoryTags(repositoryPluginTags, DEFAULT_PLUGIN_REPOTAG_FILENAME_DESCRIPTOR);
135
		saveRepositoryTags(repositoryPluginTags, DEFAULT_PLUGIN_REPOTAG_FILENAME_DESCRIPTOR);
137
		saveRepositoryTags(repositoryFeatureTags, DEFAULT_FEATURE_REPOTAG_FILENAME_DESCRIPTOR);
136
		saveRepositoryTags(repositoryFeatureTags, DEFAULT_FEATURE_REPOTAG_FILENAME_DESCRIPTOR);
Lines 169-179 Link Here
169
		generatePrologue();
168
		generatePrologue();
170
		generateFetchTarget();
169
		generateFetchTarget();
171
		generateFetchElementTarget();
170
		generateFetchElementTarget();
172
		if (mapInfos.get(TYPE).equals(FEATURE)) { 
171
		if (mapInfos.get(TYPE).equals(FEATURE)) {
173
			generateFetchPluginsTarget();
172
			generateFetchPluginsTarget();
174
			generateFetchRecusivelyTarget();
173
			generateFetchRecusivelyTarget();
175
		}
174
		}
176
		generateGetFromCVSTarget();
175
		generateGetFromRepositoryTarget();
177
		generateEpilogue();
176
		generateEpilogue();
178
	}
177
	}
179
178
Lines 184-190 Link Here
184
		script.println();
183
		script.println();
185
		script.printTargetDeclaration(TARGET_FETCH, null, null, null, null);
184
		script.printTargetDeclaration(TARGET_FETCH, null, null, null, null);
186
		script.printAntCallTask(TARGET_FETCH_ELEMENT, null, null);
185
		script.printAntCallTask(TARGET_FETCH_ELEMENT, null, null);
187
		if (mapInfos.get(TYPE).equals(FEATURE)) { 
186
		if (mapInfos.get(TYPE).equals(FEATURE)) {
188
			script.printAntCallTask(TARGET_FETCH_PLUGINS, null, null);
187
			script.printAntCallTask(TARGET_FETCH_PLUGINS, null, null);
189
			script.printAntCallTask(TARGET_FETCH_RECURSIVELY, null, null);
188
			script.printAntCallTask(TARGET_FETCH_RECURSIVELY, null, null);
190
		}
189
		}
Lines 204-210 Link Here
204
203
205
	protected void generateFetchPluginsTarget() throws CoreException {
204
	protected void generateFetchPluginsTarget() throws CoreException {
206
		script.printTargetDeclaration(TARGET_FETCH_PLUGINS, null, FEATURE_AND_PLUGINS, null, null);
205
		script.printTargetDeclaration(TARGET_FETCH_PLUGINS, null, FEATURE_AND_PLUGINS, null, null);
207
		retrieveFeature((String) mapInfos.get(ELEMENT), (String) mapInfos.get(CVSROOT), (String) mapInfos.get(TAG), (String) mapInfos.get(PASSWORD), (String) mapInfos.get(PATH)); 
206
		retrieveFeature((String) mapInfos.get(ELEMENT), (String) mapInfos.get(TYPE), mapInfos);
208
		generateChildrenFetchScript();
207
		generateChildrenFetchScript();
209
		script.printTargetEnd();
208
		script.printTargetEnd();
210
	}
209
	}
Lines 219-246 Link Here
219
	private Map processMapFileEntry(String entry) throws CoreException {
218
	private Map processMapFileEntry(String entry) throws CoreException {
220
		Map entryInfos = new HashMap(5);
219
		Map entryInfos = new HashMap(5);
221
220
222
		String cvsInfo = getCVSInfo(entry);
221
		// extract type and element from entry
223
		if (cvsInfo == null) {
222
		int index = entry.indexOf('@');
223
		String type = entry.substring(0, index);
224
		String currentElement = entry.substring(index + 1);
225
226
		// read and validate the repository info
227
		String repositoryInfo = getRepositoryInfo(entry);
228
		if (repositoryInfo == null) {
224
			String message = NLS.bind(Messages.error_missingDirectoryEntry, entry);
229
			String message = NLS.bind(Messages.error_missingDirectoryEntry, entry);
225
			BundleHelper.getDefault().getLog().log(new Status(IStatus.ERROR, PI_PDEBUILD, EXCEPTION_ENTRY_MISSING, message, null));
230
			BundleHelper.getDefault().getLog().log(new Status(IStatus.ERROR, PI_PDEBUILD, EXCEPTION_ENTRY_MISSING, message, null));
226
			return null;
231
			return null;
227
		}
232
		}
228
233
229
		String[] cvsFields = Utils.getArrayFromStringWithBlank(cvsInfo, ","); //$NON-NLS-1$
234
		// collect and validate the repository info
230
		if (cvsFields.length < 2) {
235
		String[] repositoryFields = Utils.getArrayFromStringWithBlank(repositoryInfo, ","); //$NON-NLS-1$
231
			String message = NLS.bind(Messages.error_incorrectDirectoryEntry, element);
236
		if (repositoryFields.length < 2) {
237
			String message = NLS.bind(Messages.error_incorrectDirectoryEntry, currentElement);
232
			throw new CoreException(new Status(IStatus.ERROR, PI_PDEBUILD, EXCEPTION_ENTRY_MISSING, message, null));
238
			throw new CoreException(new Status(IStatus.ERROR, PI_PDEBUILD, EXCEPTION_ENTRY_MISSING, message, null));
233
		}
239
		}
234
240
235
		entryInfos.put(TAG, fetchTag.length() == 0 ? cvsFields[0] : fetchTag); 
241
		// determine fetch script builder
236
		entryInfos.put(CVSROOT, cvsFields[1]); 
242
		FetchTaskFactory fetchTaskFactory = null;
237
		entryInfos.put(PASSWORD, (cvsFields.length > 2 && !cvsFields[2].equals("")) ? cvsFields[2] : null); //$NON-NLS-1$ 
243
		String[] arguments = null;
238
244
239
		entryInfos.put(PATH, (cvsFields.length > 3 && !cvsFields[3].equals("")) ? cvsFields[3] : null); //$NON-NLS-1$ 
245
		// check if first repository field matches a builder id
240
246
		if (FetchTaskFactoriesRegistry.getRegistry().getFactoryIds().contains(repositoryFields[0])) {
241
		int index = entry.indexOf('@'); 
247
			fetchTaskFactory = FetchTaskFactoriesRegistry.getRegistry().getFactory(repositoryFields[0]);
242
		entryInfos.put(TYPE, entry.substring(0, index)); 
248
243
		entryInfos.put(ELEMENT, entry.substring(index + 1)); 
249
			// construct arguments array for registered builder
250
			arguments = new String[repositoryFields.length - 1];
251
			System.arraycopy(repositoryFields, 1, arguments, 0, repositoryFields.length - 1);
252
		}
253
254
		// default to CVS builder (to be compatible)
255
		if (null == fetchTaskFactory) {
256
			// fall back to CVS
257
			fetchTaskFactory = new CVSFetchTaskFactory();
258
259
			// construct arguments array for CVS builder
260
			arguments = repositoryFields;
261
		}
262
263
		// add infos from registered builder
264
		fetchTaskFactory.processMapFileEntry(currentElement, type, arguments, fetchTag, entryInfos);
265
266
		// store builder
267
		entryInfos.put(FETCH_TASK_FACTORY, fetchTaskFactory);
268
269
		// add general infos (will override builder specific infos)
270
		entryInfos.put(TYPE, type);
271
		entryInfos.put(ELEMENT, currentElement);
244
		return entryInfos;
272
		return entryInfos;
245
	}
273
	}
246
274
Lines 257-265 Link Here
257
				}
285
				}
258
				continue;
286
				continue;
259
			}
287
			}
260
			
288
261
			//Included features can be available in the baseLocation.
289
			//Included features can be available in the baseLocation.
262
			if (getCVSInfo(FEATURE + '@' + featureId) != null)
290
			if (getRepositoryInfo(FEATURE + '@' + featureId) != null)
263
				script.printAntTask(Utils.getPropertyFormat(PROPERTY_BUILD_DIRECTORY) + '/' + FETCH_FILE_PREFIX + featureId + ".xml", null, TARGET_FETCH, null, null, null); //$NON-NLS-1$
291
				script.printAntTask(Utils.getPropertyFormat(PROPERTY_BUILD_DIRECTORY) + '/' + FETCH_FILE_PREFIX + featureId + ".xml", null, TARGET_FETCH, null, null, null); //$NON-NLS-1$
264
			else if (getSite(false).findFeature(featureId, null, false) == null) {
292
			else if (getSite(false).findFeature(featureId, null, false) == null) {
265
				String message = NLS.bind(Messages.error_cannotFetchNorFindFeature, featureId);
293
				String message = NLS.bind(Messages.error_cannotFetchNorFindFeature, featureId);
Lines 277-333 Link Here
277
				return false;
305
				return false;
278
		}
306
		}
279
307
280
		String password = (String) mapFileEntry.get(PASSWORD);
308
		FetchTaskFactory factory = (FetchTaskFactory) mapFileEntry.get(FETCH_TASK_FACTORY);
281
		if (password != null)
309
		String elementToFetch = (String) mapFileEntry.get(ELEMENT);
282
			script.printCVSPassTask((String) mapFileEntry.get(CVSROOT), password, cvsPassFileLocation); 
283
284
		String type = (String) mapFileEntry.get(TYPE);
310
		String type = (String) mapFileEntry.get(TYPE);
311
312
		// print authentification task if one is provided
313
		CharSequence authTask = factory.generateAuthentificationTask(elementToFetch, type, mapFileEntry);
314
		if (null != authTask)
315
			script.print(authTask);
316
317
		// the location
285
		String location = getElementLocation(type);
318
		String location = getElementLocation(type);
286
		Map params = new HashMap(5);
287
319
288
		//We directly export the CVS content into the correct directory 
320
		// the destination
289
		params.put("destination", mapFileEntry.get(ELEMENT)); //$NON-NLS-1$ 
321
		// we directly export the content into the correct directory 
290
		params.put(TAG, mapFileEntry.get(TAG)); 
322
		String destination = elementToFetch;
291
		params.put(CVSROOT, mapFileEntry.get(CVSROOT)); 
323
292
		params.put("quiet", "${quiet}"); //$NON-NLS-1$ //$NON-NLS-2$
324
		// get params from builder
325
		Map params = new HashMap(factory.generatePropertiesForFetchTask(elementToFetch, type, mapFileEntry, destination, manifestFileOnly));
293
326
294
		String cvsPackage = ((String) mapFileEntry.get(PATH) == null ? (String) mapFileEntry.get(ELEMENT) : (String) mapFileEntry.get(PATH)); 
295
		String fullLocation = null;
327
		String fullLocation = null;
296
		if (type.equals(FEATURE)) {
328
		if (type.equals(FEATURE)) {
297
			fullLocation = location + '/' + (String) mapFileEntry.get(ELEMENT) + '/' + DEFAULT_FEATURE_FILENAME_DESCRIPTOR; 
329
			fullLocation = location + '/' + (String) mapFileEntry.get(ELEMENT) + '/' + DEFAULT_FEATURE_FILENAME_DESCRIPTOR;
298
			params.put("fileToCheck", fullLocation); //$NON-NLS-1$
330
			params.put("fileToCheck", fullLocation); //$NON-NLS-1$
299
			cvsPackage += manifestFileOnly ? '/' + DEFAULT_FEATURE_FILENAME_DESCRIPTOR : ""; //$NON-NLS-1$
331
			repositoryFeatureTags.put(elementToFetch, factory.getTagToFetch(elementToFetch, type, mapFileEntry));
300
			repositoryFeatureTags.put(mapFileEntry.get(ELEMENT), mapFileEntry.get(TAG));
301
		} else if (type.equals(PLUGIN)) {
332
		} else if (type.equals(PLUGIN)) {
302
			fullLocation = location + '/' + (String) mapFileEntry.get(ELEMENT) + '/' + DEFAULT_PLUGIN_FILENAME_DESCRIPTOR; 
333
			fullLocation = location + '/' + elementToFetch + '/' + DEFAULT_PLUGIN_FILENAME_DESCRIPTOR;
303
			params.put("fileToCheck", fullLocation); //$NON-NLS-1$
334
			params.put("fileToCheck", fullLocation); //$NON-NLS-1$
304
			cvsPackage += manifestFileOnly ? '/' + DEFAULT_PLUGIN_FILENAME_DESCRIPTOR : ""; //$NON-NLS-1$
335
			repositoryPluginTags.put(elementToFetch, factory.getTagToFetch(elementToFetch, type, mapFileEntry));
305
			repositoryPluginTags.put(mapFileEntry.get(ELEMENT), mapFileEntry.get(TAG));
306
		} else if (type.equals(FRAGMENT)) {
336
		} else if (type.equals(FRAGMENT)) {
307
			fullLocation = location + '/' + (String) mapFileEntry.get(ELEMENT) + '/' + DEFAULT_FRAGMENT_FILENAME_DESCRIPTOR; 
337
			fullLocation = location + '/' + elementToFetch + '/' + DEFAULT_FRAGMENT_FILENAME_DESCRIPTOR;
308
			params.put("fileToCheck", fullLocation); //$NON-NLS-1$
338
			params.put("fileToCheck", fullLocation); //$NON-NLS-1$
309
			cvsPackage += manifestFileOnly ? '/' + DEFAULT_FRAGMENT_FILENAME_DESCRIPTOR : ""; //$NON-NLS-1$
339
			repositoryPluginTags.put(elementToFetch, factory.getTagToFetch(elementToFetch, type, mapFileEntry));
310
			repositoryPluginTags.put(mapFileEntry.get(ELEMENT), mapFileEntry.get(TAG));
311
		} else if (type.equals(BUNDLE)) {
340
		} else if (type.equals(BUNDLE)) {
312
			fullLocation = location + '/' + (String) mapFileEntry.get(ELEMENT) + '/' + DEFAULT_BUNDLE_FILENAME_DESCRIPTOR;
341
			fullLocation = location + '/' + (String) mapFileEntry.get(ELEMENT) + '/' + DEFAULT_BUNDLE_FILENAME_DESCRIPTOR;
313
			params.put("fileToCheck", fullLocation); //$NON-NLS-1$
342
			params.put("fileToCheck", fullLocation); //$NON-NLS-1$
314
			cvsPackage += manifestFileOnly ? '/' + DEFAULT_BUNDLE_FILENAME_DESCRIPTOR : "";//$NON-NLS-1$ 
343
			repositoryPluginTags.put(elementToFetch, factory.getTagToFetch(elementToFetch, type, mapFileEntry));
315
			repositoryPluginTags.put(mapFileEntry.get(ELEMENT), mapFileEntry.get(TAG));   
316
		}
344
		}
317
		params.put("package", cvsPackage); //$NON-NLS-1$
318
345
319
		// This call create a new property for every feature, plugins or fragments that we must check the existence of 
346
		// This call create a new property for every feature, plugins or fragments that we must check the existence of 
320
		script.printAvailableTask(fullLocation, fullLocation);
347
		script.printAvailableTask(fullLocation, fullLocation);
321
		if (type.equals(PLUGIN) || type.equals(FRAGMENT)) {
348
		if (type.equals(PLUGIN) || type.equals(FRAGMENT)) {
322
			script.printAvailableTask(fullLocation, location + '/' + (String) mapFileEntry.get(ELEMENT) + '/' + DEFAULT_BUNDLE_FILENAME_DESCRIPTOR);
349
			script.printAvailableTask(fullLocation, location + '/' + elementToFetch + '/' + DEFAULT_BUNDLE_FILENAME_DESCRIPTOR);
323
		}
350
		}
324
		script.printAntTask("../" + scriptName, Utils.getPropertyFormat(PROPERTY_BUILD_DIRECTORY) + '/' + (type.equals(FEATURE) ? DEFAULT_FEATURE_LOCATION : DEFAULT_PLUGIN_LOCATION), TARGET_GET_FROM_CVS, null, null, params); //$NON-NLS-1$ 
351
		script.printAntTask("../" + scriptName, Utils.getPropertyFormat(PROPERTY_BUILD_DIRECTORY) + '/' + (type.equals(FEATURE) ? DEFAULT_FEATURE_LOCATION : DEFAULT_PLUGIN_LOCATION), TARGET_FETCH_FROM_REPOSITORY, null, null, params); //$NON-NLS-1$ 
325
		return true;
352
		return true;
326
	}
353
	}
327
354
328
	protected void generateGetFromCVSTarget() {
355
	protected void generateGetFromRepositoryTarget() throws CoreException {
329
		script.printTargetDeclaration(TARGET_GET_FROM_CVS, null, null, "${fileToCheck}", "{destination}"); //$NON-NLS-1$ //$NON-NLS-2$
356
		script.printTargetDeclaration(TARGET_FETCH_FROM_REPOSITORY, null, null, "${fileToCheck}", null); //$NON-NLS-1$
330
		script.printCVSTask("export -d ${destination} -r ${tag} ${package}", "${cvsRoot}", null, null, null, "${quiet}", null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
357
		if (null != mapInfos) {
358
			FetchTaskFactory factory = (FetchTaskFactory) mapInfos.get(FETCH_TASK_FACTORY);
359
			if (null != factory) {
360
				CharSequence getTask = factory.getFetchTask();
361
				if (null != getTask) {
362
					script.print(getTask);
363
				}
364
			}
365
		}
331
		script.printTargetEnd();
366
		script.printTargetEnd();
332
	}
367
	}
333
368
Lines 365-375 Link Here
365
400
366
			boolean generated = true;
401
			boolean generated = true;
367
			if (allChildren[i].isFragment())
402
			if (allChildren[i].isFragment())
368
				generated = generateFetchEntry(FRAGMENT + '@' + elementId, !Utils.isIn(compiledChildren, allChildren[i])); 
403
				generated = generateFetchEntry(FRAGMENT + '@' + elementId, !Utils.isIn(compiledChildren, allChildren[i]));
369
			else
404
			else
370
				generated = generateFetchEntry(PLUGIN + '@' + elementId, !Utils.isIn(compiledChildren, allChildren[i])); 
405
				generated = generateFetchEntry(PLUGIN + '@' + elementId, !Utils.isIn(compiledChildren, allChildren[i]));
371
			if (generated == false)
406
			if (generated == false)
372
				generateFetchEntry(BUNDLE + '@' + elementId, !Utils.isIn(compiledChildren, allChildren[i])); 
407
				generateFetchEntry(BUNDLE + '@' + elementId, !Utils.isIn(compiledChildren, allChildren[i]));
373
		}
408
		}
374
	}
409
	}
375
410
Lines 379-415 Link Here
379
	 * constructor from Update.
414
	 * constructor from Update.
380
	 * 
415
	 * 
381
	 * @param elementName the feature to retrieve
416
	 * @param elementName the feature to retrieve
382
	 * @param cvsRoot the root in CVS
417
	 * @param elementType the element type
383
	 * @param tag the CVS tag
418
	 * @param elementInfos the element information
384
	 * @param password the CVS password
385
	 * @throws CoreException
419
	 * @throws CoreException
386
	 */
420
	 */
387
	protected void retrieveFeature(String elementName, String cvsRoot, String tag, String password, String path) throws CoreException {
421
	protected void retrieveFeature(String elementName, String elementType, Map elementInfos) throws CoreException {
388
		// Generate a temporary Ant script which retrieves the feature.xml for this
422
		// Generate a temporary Ant script which retrieves the feature.xml for this
389
		// feature from CVS
423
		// feature from CVS
390
		File root = new File(workingDirectory);
424
		File root = new File(workingDirectory);
391
		File target = new File(root, DEFAULT_RETRIEVE_FILENAME_DESCRIPTOR); 
425
		File target = new File(root, DEFAULT_RETRIEVE_FILENAME_DESCRIPTOR);
392
		try {
426
		try {
393
			AntScript retrieve = new AntScript(new FileOutputStream(target));
427
			AntScript retrieve = new AntScript(new FileOutputStream(target));
394
			try {
428
			try {
395
				retrieve.printProjectDeclaration("RetrieveFeature", "main", "."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
429
				retrieve.printProjectDeclaration("RetrieveFeature", "main", "."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
396
				retrieve.printTargetDeclaration(TARGET_MAIN, null, null, null, null); 
430
				retrieve.printTargetDeclaration(TARGET_MAIN, null, null, null, null);
397
431
398
				IPath moduleFeatureFile;
432
				String destination = elementName;
399
				IPath moduleFeatureProperties;
433
				String[] files = new String[] {DEFAULT_FEATURE_FILENAME_DESCRIPTOR, PROPERTIES_FILE};
400
				if (path != null) {
434
				FetchTaskFactory factory = (FetchTaskFactory) elementInfos.get(FETCH_TASK_FACTORY);
401
					moduleFeatureFile = new Path(path).append(DEFAULT_FEATURE_FILENAME_DESCRIPTOR);
435
				CharSequence retrieveFeatureTask = factory.generateRetrieveFilesTask(elementName, elementType, elementInfos, destination, files);
402
					moduleFeatureProperties = new Path(path).append(PROPERTIES_FILE);
436
				if (null == retrieveFeatureTask) {
403
				} else {
437
					String message = NLS.bind(Messages.error_noRetrieveFeatureTask, elementName);
404
					moduleFeatureFile = new Path(elementName).append(DEFAULT_FEATURE_FILENAME_DESCRIPTOR);
438
					throw new CoreException(new Status(IStatus.ERROR, PI_PDEBUILD, EXCEPTION_ENTRY_MISSING, message, null));
405
					moduleFeatureProperties = new Path(elementName).append(PROPERTIES_FILE);
406
				}
439
				}
407
440
				retrieve.print(retrieveFeatureTask);
408
				if (password != null)
409
					retrieve.printCVSPassTask(cvsRoot, password, cvsPassFileLocation);
410
411
				retrieve.printCVSTask("export -r " + tag + " " + moduleFeatureFile.toString(), cvsRoot, null, null, null, "true", null); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
412
				retrieve.printCVSTask("export -r " + tag + " " + moduleFeatureProperties.toString(), cvsRoot, null, null, null, "true", null); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
413
441
414
				retrieve.printTargetEnd();
442
				retrieve.printTargetEnd();
415
				retrieve.printProjectEnd();
443
				retrieve.printProjectEnd();
Lines 427-440 Link Here
427
			AntRunner runner = new AntRunner();
455
			AntRunner runner = new AntRunner();
428
			runner.setBuildFileLocation(target.getAbsolutePath());
456
			runner.setBuildFileLocation(target.getAbsolutePath());
429
			runner.run();
457
			runner.run();
458
			String destination = elementName;
430
			FeatureExecutableFactory factory = new FeatureExecutableFactory();
459
			FeatureExecutableFactory factory = new FeatureExecutableFactory();
431
			File featureFolder = new File(root, (path == null ? elementName : path));
460
			File featureFolder = new File(root, destination);
432
			feature = factory.createFeature(featureFolder.toURL(), null, null);
461
			feature = factory.createFeature(featureFolder.toURL(), null, null);
433
462
434
			//We only delete here, so if an exception is thrown the user can still see the retrieve.xml 
463
			//We only delete here, so if an exception is thrown the user can still see the retrieve.xml 
435
			target.delete();
464
			target.delete();
436
			featureProperties = new Properties();
465
			featureProperties = new Properties();
437
			InputStream featureStream = new FileInputStream(new File(root, (path == null ? elementName : path) + '/' + PROPERTIES_FILE));
466
			InputStream featureStream = new FileInputStream(new File(root, destination + '/' + PROPERTIES_FILE));
438
			featureProperties.load(featureStream);
467
			featureProperties.load(featureStream);
439
			featureStream.close();
468
			featureStream.close();
440
			clear(featureFolder);
469
			clear(featureFolder);
Lines 484-490 Link Here
484
	 */
513
	 */
485
	protected String getElementLocation(String type) {
514
	protected String getElementLocation(String type) {
486
		IPath location = new Path(Utils.getPropertyFormat(PROPERTY_BUILD_DIRECTORY));
515
		IPath location = new Path(Utils.getPropertyFormat(PROPERTY_BUILD_DIRECTORY));
487
		if (type.equals(FEATURE)) 
516
		if (type.equals(FEATURE))
488
			location = location.append(DEFAULT_FEATURE_LOCATION);
517
			location = location.append(DEFAULT_FEATURE_LOCATION);
489
		else
518
		else
490
			location = location.append(DEFAULT_PLUGIN_LOCATION);
519
			location = location.append(DEFAULT_PLUGIN_LOCATION);
Lines 498-504 Link Here
498
	 * @return String
527
	 * @return String
499
	 * @throws CoreException
528
	 * @throws CoreException
500
	 */
529
	 */
501
	protected String getCVSInfo(String elementName) throws CoreException {
530
	protected String getRepositoryInfo(String elementName) throws CoreException {
502
		if (directory == null)
531
		if (directory == null)
503
			directory = readProperties(directoryLocation, "", IStatus.ERROR); //$NON-NLS-1$
532
			directory = readProperties(directoryLocation, "", IStatus.ERROR); //$NON-NLS-1$
504
		return directory.getProperty(elementName);
533
		return directory.getProperty(elementName);
(-)src/org/eclipse/pde/internal/build/Messages.java (-1 / +2 lines)
Lines 33-39 Link Here
33
	public static String error_configWrongFormat;
33
	public static String error_configWrongFormat;
34
	public static String error_missingCustomBuildFile;
34
	public static String error_missingCustomBuildFile;
35
	public static String error_missingSourceFolder;
35
	public static String error_missingSourceFolder;
36
	
36
	public static String error_noRetrieveFeatureTask;
37
37
	// exception
38
	// exception
38
	public static String exception_missingElement;
39
	public static String exception_missingElement;
39
	public static String exception_missingFeature;
40
	public static String exception_missingFeature;
(-)src/org/eclipse/pde/internal/build/messages.properties (-1 / +2 lines)
Lines 29-35 Link Here
29
error_configWrongFormat = {0} is not a valid configuration.
29
error_configWrongFormat = {0} is not a valid configuration.
30
error_missingCustomBuildFile = No custom build file found in {0}.
30
error_missingCustomBuildFile = No custom build file found in {0}.
31
error_missingSourceFolder = In plugin {0}, the value for property {1} is not set.
31
error_missingSourceFolder = In plugin {0}, the value for property {1} is not set.
32
32
error_noRetrieveFeatureTask = No fetch task available for element {0}, check your map files.
33
  
33
### exception
34
### exception
34
exception_missingElement = Unable to find element: {0}.
35
exception_missingElement = Unable to find element: {0}.
35
exception_missingFeature = Unable to find feature: {0}.
36
exception_missingFeature = Unable to find feature: {0}.
(-)src/org/eclipse/pde/internal/build/ant/AntScript.java (-381 / +429 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
2
 * Copyright (c) 2000, 2006 IBM Corporation 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 12-40 Link Here
12
12
13
import java.io.*;
13
import java.io.*;
14
import java.util.*;
14
import java.util.*;
15
import org.eclipse.core.runtime.*;
16
import org.eclipse.pde.internal.build.IPDEBuildConstants;
15
17
16
/**
18
/**
17
 * Class for producing Ant scripts. Contains convenience methods for creating the
19
 * Class for producing Ant scripts. 
20
 * <p>
21
 * Contains convenience methods for creating the
18
 * XML elements required for Ant scripts. See the <a href="http://jakarta.apache.org/ant">Ant</a> 
22
 * XML elements required for Ant scripts. See the <a href="http://jakarta.apache.org/ant">Ant</a> 
19
 * website for more details on Ant scripts and the particular Ant tasks.
23
 * website for more details on Ant scripts and the particular Ant tasks.
24
 * </p>
20
 */
25
 */
21
public class AntScript {
26
public class AntScript {
22
27
28
	/**
29
	 * Converts the specified task to a String.
30
	 * @param task
31
	 * @return a String reprecentation of an ITask.
32
	 */
33
	public static String taskAsString(ITask task) throws CoreException {
34
		if (null == task)
35
			return null;
36
	
37
		ByteArrayOutputStream out = new ByteArrayOutputStream();
38
		try {
39
			AntScript script = new AntScript(out, false);
40
			task.print(script);
41
			script.close();
42
			return out.toString("UTF8"); //$NON-NLS-1$
43
		} catch (IOException e) {
44
			String message = e.getMessage();
45
			throw new CoreException(new Status(IStatus.ERROR, IPDEBuildConstants.PI_PDEBUILD, IPDEBuildConstants.EXCEPTION_WRITING_SCRIPT, message, null));
46
		}
47
	}
48
	
23
	protected OutputStream out;
49
	protected OutputStream out;
24
	protected PrintWriter output;
50
	protected PrintWriter output;
25
	protected final String XML_PROLOG = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; //$NON-NLS-1$
51
	protected final String XML_PROLOG = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; //$NON-NLS-1$
52
26
	protected int indent = 0;
53
	protected int indent = 0;
27
54
28
	/**
55
	/**
29
	 * Constructor for the class.
56
	 * Creates a new Ant script including the XML prolog <code>&lt;?xml ... ?&gt;</code>.
30
	 * 
57
	 * 
31
	 * @param out the output stream to write the script to
58
	 * @param out the output stream to write the script to
32
	 * @throws IOException
59
	 * @throws IOException
33
	 */
60
	 */
34
	public AntScript(OutputStream out) throws IOException {
61
	public AntScript(OutputStream out) throws IOException {
62
		this(out, true);
63
	}
64
65
	/**
66
	 * Constructor for the class.
67
	 * 
68
	 * @param out the output stream to write the script to
69
	 * @param writeXMLProlog indicates if the XML prolog should be written
70
	 * @throws IOException
71
	 */
72
	public AntScript(OutputStream out, boolean writeXMLProlog) throws IOException {
35
		this.out = out;
73
		this.out = out;
36
		output = new PrintWriter(new OutputStreamWriter(out, "UTF8")); //$NON-NLS-1$
74
		output = new PrintWriter(new OutputStreamWriter(out, "UTF8")); //$NON-NLS-1$
37
		output.println(XML_PROLOG);
75
		if(writeXMLProlog)
76
			output.println(XML_PROLOG);
38
	}
77
	}
39
78
40
	/**
79
	/**
Lines 53-58 Link Here
53
	}
92
	}
54
93
55
	/**
94
	/**
95
	 * Print the given char sequence to the Ant script.
96
	 * 
97
	 * @param charSequence the char sequence to print
98
	 */
99
	public void print(CharSequence charSequence) {
100
		output.print(charSequence.toString());
101
	}
102
103
	/**
104
	 * Print the given task to the Ant script.
105
	 * 
106
	 * @param task the task to print
107
	 */
108
	public void print(ITask task) {
109
		task.print(this);
110
	}
111
112
	/**
113
	 * Print the given string to the Ant script.
114
	 * 
115
	 * @param message
116
	 */
117
	public void print(String message) {
118
		output.print(message);
119
	}
120
	
121
	/**
56
	 * Print an <code>antcall</code> task to the script. This calls Ant on the given 
122
	 * Print an <code>antcall</code> task to the script. This calls Ant on the given 
57
	 * target which is located within the same build file. 
123
	 * target which is located within the same build file. 
58
	 * 
124
	 * 
Lines 81-133 Link Here
81
			output.println("</antcall>"); //$NON-NLS-1$
147
			output.println("</antcall>"); //$NON-NLS-1$
82
		}
148
		}
83
	}
149
	}
84
85
	/**
86
	 * Print a <code>jar</code> Ant task to this script. This jars together a group of 
87
	 * files into a single file.
88
	 * 
89
	 * @param jarFile the destination file name
90
	 * @param basedir the base directory
91
	 */
92
	public void printJarTask(String jarFile, String basedir, String manifestAttribute) {
93
		printTab();
94
		output.print("<jar"); //$NON-NLS-1$
95
		printAttribute("destfile", jarFile, true); //$NON-NLS-1$
96
		printAttribute("basedir", basedir, false); //$NON-NLS-1$
97
		printAttribute("manifest", manifestAttribute, false); //$NON-NLS-1$
98
		output.println("/>"); //$NON-NLS-1$
99
	}
100
101
	/**
102
	 * Print the <code>available</code> Ant task to this script. This task sets a property
103
	 * value if the given file exists at runtime.
104
	 * 
105
	 * @param property the property to set
106
	 * @param file the file to look for
107
	 */
108
	public void printAvailableTask(String property, String file) {
109
		printTab();
110
		output.print("<available"); //$NON-NLS-1$
111
		printAttribute("property", property, true); //$NON-NLS-1$
112
		printAttribute("file", file, false); //$NON-NLS-1$
113
		output.println("/>"); //$NON-NLS-1$
114
	}
115
116
	/**
117
	 * Print the <code>available</code> Ant task to this script. This task sets a property
118
	 * to the given value if the given file exists at runtime.
119
	 * 
120
	 * @param property the property to set
121
	 * @param file the file to look for
122
	 */
123
	public void printAvailableTask(String property, String file, String value){
124
		printTab();
125
		output.print("<available"); //$NON-NLS-1$
126
		printAttribute("property", property, true); //$NON-NLS-1$
127
		printAttribute("file", file, false); //$NON-NLS-1$
128
		printAttribute("value", value, false); //$NON-NLS-1$
129
		output.println("/>"); //$NON-NLS-1$
130
	}
131
	
150
	
132
	/**
151
	/**
133
	 * Print an <code>ant</code> task to this script. This calls Ant on the specified 
152
	 * Print an <code>ant</code> task to this script. This calls Ant on the specified 
Lines 144-150 Link Here
144
	public void printAntTask(String antfile, String dir, String target, String outputParam, String inheritAll, Map properties ) {
163
	public void printAntTask(String antfile, String dir, String target, String outputParam, String inheritAll, Map properties ) {
145
		printAntTask(antfile, dir, target, outputParam, inheritAll, properties, null );
164
		printAntTask(antfile, dir, target, outputParam, inheritAll, properties, null );
146
	}
165
	}
147
	
166
148
	/**
167
	/**
149
	 * Print an <code>ant</code> task to this script. This calls Ant on the specified 
168
	 * Print an <code>ant</code> task to this script. This calls Ant on the specified 
150
	 * target contained in the specified Ant file with the given parameters.
169
	 * target contained in the specified Ant file with the given parameters.
Lines 196-290 Link Here
196
			output.println("</ant>"); //$NON-NLS-1$
215
			output.println("</ant>"); //$NON-NLS-1$
197
		}
216
		}
198
	}
217
	}
199
200
	public void printSubantTask(String antfile, String target, String buildpath, String failOnError, Map properties, Map references) {
201
		printTab();
202
		output.print("<subant"); //$NON-NLS-1$
203
		printAttribute("antfile", antfile, false); //$NON-NLS-1$
204
		printAttribute("target", target, false); //$NON-NLS-1$
205
		printAttribute("failonerror", failOnError, false);   //$NON-NLS-1$
206
		printAttribute("buildpath", buildpath, false);  //$NON-NLS-1$
207
		if (properties == null && references == null)
208
			output.println("/>"); //$NON-NLS-1$
209
		else {
210
			output.println(">"); //$NON-NLS-1$
211
			indent++;
212
			if( properties != null ) {
213
				Set entries = properties.entrySet();
214
				for (Iterator iter = entries.iterator(); iter.hasNext();) {
215
					Map.Entry entry = (Map.Entry) iter.next();
216
					printProperty((String) entry.getKey(), (String) entry.getValue());
217
				}
218
			}
219
			if( references != null ){
220
				Set entries = references.entrySet();
221
				for (Iterator iter = entries.iterator(); iter.hasNext();) {
222
					Map.Entry entry = (Map.Entry) iter.next();
223
					printTab();
224
					print("<reference refid=\"" + (String)entry.getKey() + "\""); //$NON-NLS-1$ //$NON-NLS-2$
225
					if( entry.getValue() != null ){
226
						print(" torefid=\"" + (String) entry.getValue() + "\""); //$NON-NLS-1$ //$NON-NLS-2$
227
					}
228
					print("/>"); //$NON-NLS-1$
229
					println();
230
				}
231
			}
232
			indent--;
233
			printTab();
234
			output.println("</subant>"); //$NON-NLS-1$
235
		}
236
	}
237
	/**
238
	 * Print a <code>zip</code> task to this script.
239
	 * 
240
	 * @param zipfile the destination file name
241
	 * @param basedir the source directory to start the zip
242
	 * @param filesOnly <code>true</code> if the resulting zip file should contain only files and not directories
243
	 * @param update ndicates whether to update or overwrite the destination file if it already exists
244
	 * @param fileSets the inclusion/exclusion rules to use when zipping
245
	 */
246
	public void printZipTask(String zipfile, String basedir, boolean filesOnly, boolean update, FileSet[] fileSets) {
247
		printTab();
248
		output.print("<zip"); //$NON-NLS-1$
249
		printAttribute("destfile", zipfile, true); //$NON-NLS-1$
250
		printAttribute("basedir", basedir, false); //$NON-NLS-1$
251
		printAttribute("filesonly", filesOnly ? "true" : "false", true); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
252
		printAttribute("whenempty", "skip", true); //$NON-NLS-1$//$NON-NLS-2$
253
		printAttribute("update", update ? "true" : "false", true); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
254
		if (fileSets == null)
255
			output.println("/>"); //$NON-NLS-1$
256
		else {
257
			output.println(">"); //$NON-NLS-1$
258
			indent++;
259
			for (int i = 0; i < fileSets.length; i++)
260
				if (fileSets[i] != null)
261
					fileSets[i].print(this);
262
			indent--;
263
			printTab();
264
			output.println("</zip>"); //$NON-NLS-1$
265
		}
266
	}
267
268
	public void printTarTask(String zipfile, String basedir, boolean filesOnly, boolean update, FileSet[] fileSets) {
269
		printTab();
270
		output.print("<tar"); //$NON-NLS-1$
271
		printAttribute("destfile", zipfile, true); //$NON-NLS-1$
272
		printAttribute("basedir", basedir, false); //$NON-NLS-1$
273
		printAttribute("compression", "gzip", true); //$NON-NLS-1$//$NON-NLS-2$
274
		if (fileSets == null)
275
			output.println("/>"); //$NON-NLS-1$
276
		else {
277
			output.println(">"); //$NON-NLS-1$
278
			indent++;
279
			for (int i = 0; i < fileSets.length; i++)
280
				if (fileSets[i] != null)
281
					fileSets[i].print(this);
282
			indent--;
283
			printTab();
284
			output.println("</tar>"); //$NON-NLS-1$
285
		}
286
	}
287
288
	/**
218
	/**
289
	 * Print an <code>arg</code> element to the Ant file.
219
	 * Print an <code>arg</code> element to the Ant file.
290
	 * 
220
	 * 
Lines 298-325 Link Here
298
	}
228
	}
299
229
300
	/**
230
	/**
301
	 * Print the given string to the Ant script.
302
	 * 
303
	 * @param string the string to write to the file
304
	 */
305
	public void printString(String string) {
306
		printTab();
307
		output.println(string);
308
	}
309
310
	/**
311
	 * Print the given comment to the Ant script.
312
	 * 
313
	 * @param comment the comment to write out
314
	 */
315
	public void printComment(String comment) {
316
		printTab();
317
		output.print("<!-- "); //$NON-NLS-1$
318
		output.print(comment);
319
		output.println(" -->"); //$NON-NLS-1$
320
	}
321
322
	/**
323
	 * Add the given name/value attribute pair to the script. Do not write the attribute
231
	 * Add the given name/value attribute pair to the script. Do not write the attribute
324
	 * if the value is <code>null</code> unless a <code>true</code> is specified
232
	 * if the value is <code>null</code> unless a <code>true</code> is specified
325
	 * indicating that it is mandatory.
233
	 * indicating that it is mandatory.
Lines 341-386 Link Here
341
	}
249
	}
342
250
343
	/**
251
	/**
344
	 * Print a <code>copy</code> task to the script. The source file is specified 
252
	 * Print the <code>available</code> Ant task to this script. This task sets a property
345
	 * by the <code>file</code> parameter. The destination directory is specified by 
253
	 * value if the given file exists at runtime.
346
	 * the <code>todir</code> parameter. 
254
	 * 
347
	 * @param file the source file
255
	 * @param property the property to set
348
	 * @param todir the destination directory
256
	 * @param file the file to look for
349
	 * @param fileSets the inclusion/exclusion rules to use when copying
350
	 * @param overwrite TODO
351
	 */
257
	 */
352
	public void printCopyTask(String file, String todir, FileSet[] fileSets, boolean failOnError, boolean overwrite) {
258
	public void printAvailableTask(String property, String file) {
353
		printTab();
259
		printTab();
354
		output.print("<copy"); //$NON-NLS-1$
260
		output.print("<available"); //$NON-NLS-1$
261
		printAttribute("property", property, true); //$NON-NLS-1$
355
		printAttribute("file", file, false); //$NON-NLS-1$
262
		printAttribute("file", file, false); //$NON-NLS-1$
356
		printAttribute("todir", todir, false); //$NON-NLS-1$
263
		output.println("/>"); //$NON-NLS-1$
357
		printAttribute("failonerror", failOnError ? "true" : "false", true); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
358
		printAttribute("overwrite", overwrite ? "true" : "false", true); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
359
		if (fileSets == null)
360
			output.println("/>"); //$NON-NLS-1$
361
		else {
362
			output.println(">"); //$NON-NLS-1$
363
			indent++;
364
			for (int i = 0; i < fileSets.length; i++)
365
				fileSets[i].print(this);
366
			indent--;
367
			printTab();
368
			output.println("</copy>"); //$NON-NLS-1$
369
		}
370
	}
264
	}
371
265
372
	public void printMoveTask(String todir, FileSet[] fileSets, boolean failOnError) {
266
	/**
373
		printTab();
267
	 * Print the <code>available</code> Ant task to this script. This task sets a property
374
		output.print("<move"); //$NON-NLS-1$
268
	 * to the given value if the given file exists at runtime.
375
		printAttribute("todir", todir, false); //$NON-NLS-1$
269
	 * 
376
		printAttribute("failonerror", failOnError ? "true" : "false", true); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
270
	 * @param property the property to set
377
		output.println(">"); //$NON-NLS-1$
271
	 * @param file the file to look for
378
		indent++;
272
	 */
379
		for (int i = 0; i < fileSets.length; i++)
273
	public void printAvailableTask(String property, String file, String value){
380
			fileSets[i].print(this);
381
		indent--;
382
		printTab();
274
		printTab();
383
		output.println("</move>"); //$NON-NLS-1$
275
		output.print("<available"); //$NON-NLS-1$
276
		printAttribute("property", property, true); //$NON-NLS-1$
277
		printAttribute("file", file, false); //$NON-NLS-1$
278
		printAttribute("value", value, false); //$NON-NLS-1$
279
		output.println("/>"); //$NON-NLS-1$
280
	}
281
282
	/**
283
	 * Print a <code>brand</code> task to the Ant script.
284
	 * 
285
	 * @param root the location of the launcher to brand.
286
	 * @param icons the list of icons to use in the branding
287
	 * @param name the name of the resultant launcher
288
	 */
289
	public void printBrandTask(String root, String icons, String name, String os) {
290
		printTab();
291
		print("<eclipse.brand"); //$NON-NLS-1$
292
		printAttribute("root", root, true); //$NON-NLS-1$
293
		if (icons != null)
294
			printAttribute("icons", icons, true); //$NON-NLS-1$
295
		printAttribute("name", name, true); //$NON-NLS-1$
296
		printAttribute("os", os, true); //$NON-NLS-1$
297
		println("/>"); //$NON-NLS-1$
298
	}
299
300
	public void printChmod(String dir, String rights, String files) {
301
		printTab();
302
		output.print("<chmod perm=\"" + rights + "\" "); //$NON-NLS-1$//$NON-NLS-2$
303
		output.print("dir=\"" + dir + "\" "); //$NON-NLS-1$//$NON-NLS-2$
304
		output.print("includes=\"" + files + "\" /> "); //$NON-NLS-1$ //$NON-NLS-2$
305
		output.println();
306
	}
307
308
	/**
309
	 * Print the given comment to the Ant script.
310
	 * 
311
	 * @param comment the comment to write out
312
	 */
313
	public void printComment(String comment) {
314
		printTab();
315
		output.print("<!-- "); //$NON-NLS-1$
316
		output.print(comment);
317
		output.println(" -->"); //$NON-NLS-1$
318
	}
319
320
	/**
321
	 * Print a <code>Condition</code> task with isset test to the script
322
	 * @param property		name of the property to set	
323
	 * @param value			value to set the property to
324
	 * @param testProperty	name of the property for the isset test
325
	 */
326
	public void printConditionIsSet(String property, String value, String testProperty) {
327
		println("<condition property=\"" + property + "\" value=\"" + value + "\">"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
328
		indent++;
329
		println("<isset property=\"" + testProperty + "\"/>"); //$NON-NLS-1$ //$NON-NLS-2$
330
		indent--;
331
		printEndTag("condition"); //$NON-NLS-1$
332
	}
333
334
	/**
335
	 * Print a <code> eclipse.convertTask</code> task to the script. This task convert a file path to 
336
	 * an Eclipse resource or vice-versa. 
337
	 *
338
	 * @param toConvert the entry to convert 
339
	 * @param propertyName the property where to store the result of the convertion
340
	 * @param isEclipseResource true if toConvert refers to an eclipse resource. 
341
	 */
342
	public void printConvertPathTask(String toConvert, String propertyName, boolean isEclipseResource) {
343
		printTab();
344
		output.print("<eclipse.convertPath"); //$NON-NLS-1$
345
		if (isEclipseResource == false)
346
			printAttribute("fileSystemPath", toConvert, true); //$NON-NLS-1$
347
		else
348
			printAttribute("resourcePath", toConvert, true); //$NON-NLS-1$
349
		printAttribute("property", propertyName, true); //$NON-NLS-1$
350
		output.println("/>"); //$NON-NLS-1$
384
	}
351
	}
385
352
386
	/**
353
	/**
Lines 400-405 Link Here
400
	}
367
	}
401
368
402
	/**
369
	/**
370
	 * Print a <code>copy</code> task to the script. The source file is specified 
371
	 * by the <code>file</code> parameter. The destination directory is specified by 
372
	 * the <code>todir</code> parameter. 
373
	 * @param file the source file
374
	 * @param todir the destination directory
375
	 * @param fileSets the inclusion/exclusion rules to use when copying
376
	 * @param overwrite TODO
377
	 */
378
	public void printCopyTask(String file, String todir, FileSet[] fileSets, boolean failOnError, boolean overwrite) {
379
		printTab();
380
		output.print("<copy"); //$NON-NLS-1$
381
		printAttribute("file", file, false); //$NON-NLS-1$
382
		printAttribute("todir", todir, false); //$NON-NLS-1$
383
		printAttribute("failonerror", failOnError ? "true" : "false", true); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
384
		printAttribute("overwrite", overwrite ? "true" : "false", true); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
385
		if (fileSets == null)
386
			output.println("/>"); //$NON-NLS-1$
387
		else {
388
			output.println(">"); //$NON-NLS-1$
389
			indent++;
390
			for (int i = 0; i < fileSets.length; i++)
391
				fileSets[i].print(this);
392
			indent--;
393
			printTab();
394
			output.println("</copy>"); //$NON-NLS-1$
395
		}
396
	}
397
398
	/**
399
	 * Print a <code>cvspass</code> task to the Ant script.
400
	 * 
401
	 * @param cvsRoot the name of the repository
402
	 * @param password the password
403
	 * @param passFile the name of the password file
404
	 */
405
	public void printCVSPassTask(String cvsRoot, String password, String passFile) {
406
		printTab();
407
		output.print("<cvspass"); //$NON-NLS-1$
408
		printAttribute("cvsRoot", cvsRoot, true); //$NON-NLS-1$
409
		printAttribute("password", password, true); //$NON-NLS-1$
410
		printAttribute("passfile", passFile, false); //$NON-NLS-1$
411
		output.println("/>"); //$NON-NLS-1$
412
	}
413
414
	/**
415
	 * Print a <code>cvs</code> task to the Ant script.
416
	 * 
417
	 * @param command the CVS command to run
418
	 * @param cvsRoot value for the CVSROOT variable
419
	 * @param dest the destination directory for the checked out resources
420
	 * @param module the module name to check out
421
	 * @param tag the tag of the module to check out
422
	 * @param quiet whether or not to print informational messages to the output
423
	 * @param passFile the name of the password file
424
	 */
425
	public void printCVSTask(String command, String cvsRoot, String dest, String module, String tag, String quiet, String passFile) {
426
		printTab();
427
		output.print("<cvs"); //$NON-NLS-1$
428
		printAttribute("command", command, false); //$NON-NLS-1$
429
		printAttribute("cvsRoot", cvsRoot, false); //$NON-NLS-1$
430
		printAttribute("dest", dest, false); //$NON-NLS-1$
431
		printAttribute("package", module, false); //$NON-NLS-1$
432
		printAttribute("tag", tag, false); //$NON-NLS-1$
433
		printAttribute("quiet", quiet, false); //$NON-NLS-1$
434
		printAttribute("passfile", passFile, false); //$NON-NLS-1$
435
		output.println("/>"); //$NON-NLS-1$
436
	}
437
438
	/**
403
	 * Print a <code>delete</code> task to the Ant script. At least one of <code>dir</code>
439
	 * Print a <code>delete</code> task to the Ant script. At least one of <code>dir</code>
404
	 * or <code>file</code> is required unless some <code>fileSets</code> are
440
	 * or <code>file</code> is required unless some <code>fileSets</code> are
405
	 * present.
441
	 * present.
Lines 427-432 Link Here
427
	}
463
	}
428
464
429
	/**
465
	/**
466
	 * Print a <code> dirname </code> task to the script.
467
	 * @param property
468
	 * @param file
469
	 */
470
	public void printDirName(String property, String file) {
471
		printTab();
472
		output.print("<dirname"); //$NON-NLS-1$
473
		printAttribute("property", property, true); //$NON-NLS-1$
474
		printAttribute("file", file, true); //$NON-NLS-1$
475
		output.println("/>"); //$NON-NLS-1$
476
	}
477
478
	/**
479
	 * Print an <code>echo</code> task to the Ant script.
480
	 * 
481
	 * @param message the message to echo to the output
482
	 */
483
	public void printEchoTask(String message) {
484
		printTab();
485
		output.print("<echo"); //$NON-NLS-1$
486
		printAttribute("message", message, true); //$NON-NLS-1$
487
		output.println("/>"); //$NON-NLS-1$
488
	}
489
490
	/**
491
	 * Print an end tag in the Ant script for the given element name.
492
	 * 
493
	 * @param tag the name of the element
494
	 */
495
	public void printEndTag(String tag) {
496
		printTab();
497
		output.print("</"); //$NON-NLS-1$
498
		output.print(tag);
499
		output.println(">"); //$NON-NLS-1$
500
	}
501
	
502
	/**
430
	 * Print an <code>exec</code> task to the Ant script.
503
	 * Print an <code>exec</code> task to the Ant script.
431
	 * 
504
	 * 
432
	 * @param executable the program to execute
505
	 * @param executable the program to execute
Lines 452-536 Link Here
452
		}
525
		}
453
	}
526
	}
454
527
528
	public void printGet(String source, String destination, String login, String password, boolean usetimestamp) {
529
		printTab();
530
		output.print("<get "); //$NON-NLS-1$
531
		printAttribute("username", login, false); //$NON-NLS-1$
532
		printAttribute("password", password, false); //$NON-NLS-1$
533
		printAttribute("src", source, true); //$NON-NLS-1$
534
		printAttribute("dest", destination, true); //$NON-NLS-1$
535
		printAttribute("usetimestamp", usetimestamp ? "true" : null, false); //$NON-NLS-1$ //$NON-NLS-2$
536
		output.println("/>"); //$NON-NLS-1$
537
	}
538
539
	public void printGZip(String source, String destination) {
540
		printTab();
541
		output.println("<gzip src=\"" + source + "\" zipfile=\"" + destination + "\"/>"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
542
	}
543
455
	/**
544
	/**
456
	 * Print a <code>mkdir</code> task to the Ant script.
545
	 * Print a <code>jar</code> Ant task to this script. This jars together a group of 
546
	 * files into a single file.
457
	 * 
547
	 * 
458
	 * @param dir the name of the directory to create.
548
	 * @param jarFile the destination file name
549
	 * @param basedir the base directory
459
	 */
550
	 */
460
	public void printMkdirTask(String dir) {
551
	public void printJarTask(String jarFile, String basedir, String manifestAttribute) {
461
		printTab();
552
		printTab();
462
		output.print("<mkdir"); //$NON-NLS-1$
553
		output.print("<jar"); //$NON-NLS-1$
463
		printAttribute("dir", dir, false); //$NON-NLS-1$
554
		printAttribute("destfile", jarFile, true); //$NON-NLS-1$
555
		printAttribute("basedir", basedir, false); //$NON-NLS-1$
556
		printAttribute("manifest", manifestAttribute, false); //$NON-NLS-1$
464
		output.println("/>"); //$NON-NLS-1$
557
		output.println("/>"); //$NON-NLS-1$
465
	}
558
	}
466
559
467
	/**
560
	/**
468
	 * Print a <code>brand</code> task to the Ant script.
561
	 * Print a carriage-return to the Ant script.
469
	 * 
470
	 * @param root the location of the launcher to brand.
471
	 * @param icons the list of icons to use in the branding
472
	 * @param name the name of the resultant launcher
473
	 */
562
	 */
474
	public void printBrandTask(String root, String icons, String name, String os) {
563
	public void println() {
475
		printTab();
564
		output.println();
476
		print("<eclipse.brand"); //$NON-NLS-1$
477
		printAttribute("root", root, true); //$NON-NLS-1$
478
		if (icons != null)
479
			printAttribute("icons", icons, true); //$NON-NLS-1$
480
		printAttribute("name", name, true); //$NON-NLS-1$
481
		printAttribute("os", os, true); //$NON-NLS-1$
482
		println("/>"); //$NON-NLS-1$
483
	}
565
	}
484
566
485
	/**
567
	/**
486
	 * Print an <code>echo</code> task to the Ant script.
568
	 * Print the given string to the Ant script followed by a carriage-return.
487
	 * 
569
	 * 
488
	 * @param message the message to echo to the output
570
	 * @param message the string to print
489
	 */
571
	 */
490
	public void printEchoTask(String message) {
572
	public void println(String message) {
491
		printTab();
573
		printTab();
492
		output.print("<echo"); //$NON-NLS-1$
574
		output.println(message);
493
		printAttribute("message", message, true); //$NON-NLS-1$
494
		output.println("/>"); //$NON-NLS-1$
495
	}
575
	}
496
576
497
	/**
577
	/**
498
	 * Print a <code>cvs</code> task to the Ant script.
578
	 * Print a <code>mkdir</code> task to the Ant script.
499
	 * 
579
	 * 
500
	 * @param command the CVS command to run
580
	 * @param dir the name of the directory to create.
501
	 * @param cvsRoot value for the CVSROOT variable
502
	 * @param dest the destination directory for the checked out resources
503
	 * @param module the module name to check out
504
	 * @param tag the tag of the module to check out
505
	 * @param quiet whether or not to print informational messages to the output
506
	 * @param passFile the name of the password file
507
	 */
581
	 */
508
	public void printCVSTask(String command, String cvsRoot, String dest, String module, String tag, String quiet, String passFile) {
582
	public void printMkdirTask(String dir) {
509
		printTab();
583
		printTab();
510
		output.print("<cvs"); //$NON-NLS-1$
584
		output.print("<mkdir"); //$NON-NLS-1$
511
		printAttribute("command", command, false); //$NON-NLS-1$
585
		printAttribute("dir", dir, false); //$NON-NLS-1$
512
		printAttribute("cvsRoot", cvsRoot, false); //$NON-NLS-1$
513
		printAttribute("dest", dest, false); //$NON-NLS-1$
514
		printAttribute("package", module, false); //$NON-NLS-1$
515
		printAttribute("tag", tag, false); //$NON-NLS-1$
516
		printAttribute("quiet", quiet, false); //$NON-NLS-1$
517
		printAttribute("passfile", passFile, false); //$NON-NLS-1$
518
		output.println("/>"); //$NON-NLS-1$
586
		output.println("/>"); //$NON-NLS-1$
519
	}
587
	}
520
588
589
	public void printMoveTask(String todir, FileSet[] fileSets, boolean failOnError) {
590
		printTab();
591
		output.print("<move"); //$NON-NLS-1$
592
		printAttribute("todir", todir, false); //$NON-NLS-1$
593
		printAttribute("failonerror", failOnError ? "true" : "false", true); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
594
		output.println(">"); //$NON-NLS-1$
595
		indent++;
596
		for (int i = 0; i < fileSets.length; i++)
597
			fileSets[i].print(this);
598
		indent--;
599
		printTab();
600
		output.println("</move>"); //$NON-NLS-1$
601
	}
602
521
	/**
603
	/**
522
	 * Print a <code>cvspass</code> task to the Ant script.
604
	 * Print a <code>param</code> tag to the Ant script.
523
	 * 
605
	 * 
524
	 * @param cvsRoot the name of the repository
606
	 * @param name the parameter name
525
	 * @param password the password
607
	 * @param value the parameter value
526
	 * @param passFile the name of the password file
527
	 */
608
	 */
528
	public void printCVSPassTask(String cvsRoot, String password, String passFile) {
609
	protected void printParam(String name, String value) {
529
		printTab();
610
		printTab();
530
		output.print("<cvspass"); //$NON-NLS-1$
611
		output.print("<param"); //$NON-NLS-1$
531
		printAttribute("cvsRoot", cvsRoot, true); //$NON-NLS-1$
612
		printAttribute("name", name, true); //$NON-NLS-1$
532
		printAttribute("password", password, true); //$NON-NLS-1$
613
		printAttribute("value", value, true); //$NON-NLS-1$
533
		printAttribute("passfile", passFile, false); //$NON-NLS-1$
534
		output.println("/>"); //$NON-NLS-1$
614
		output.println("/>"); //$NON-NLS-1$
535
	}
615
	}
536
616
Lines 564-583 Link Here
564
		}
644
		}
565
		printEndTag(tag);
645
		printEndTag(tag);
566
	}
646
	}
567
	
568
	/**
569
	 * Print a <code>param</code> tag to the Ant script.
570
	 * 
571
	 * @param name the parameter name
572
	 * @param value the parameter value
573
	 */
574
	protected void printParam(String name, String value) {
575
		printTab();
576
		output.print("<param"); //$NON-NLS-1$
577
		printAttribute("name", name, true); //$NON-NLS-1$
578
		printAttribute("value", value, true); //$NON-NLS-1$
579
		output.println("/>"); //$NON-NLS-1$
580
	}
581
647
582
	/**
648
	/**
583
	 * Print a <code>project</code> tag to the Ant script.
649
	 * Print a <code>project</code> tag to the Ant script.
Lines 637-706 Link Here
637
	}
703
	}
638
704
639
	/**
705
	/**
640
	 * Print a start tag in the Ant script for the given element name.
706
	 * Print a <code>eclipse.refreshLocal</code> task to the script. This task refreshes
707
	 * the specified resource in the workspace, to the specified depth. 
641
	 * 
708
	 * 
642
	 * @param tag the name of the element
709
	 * @param resource the resource to refresh
710
	 * @param depth one of <code>IResource.DEPTH_ZERO</code>,
711
	 *   <code>IResource.DEPTH_ONE</code>, or <code>IResource.DEPTH_INFINITY</code>
643
	 */
712
	 */
644
	public void printStartTag(String tag) {
713
	public void printRefreshLocalTask(String resource, String depth) {
645
		printTab();
714
		printTab();
646
		output.print("<"); //$NON-NLS-1$
715
		output.print("<eclipse.refreshLocal"); //$NON-NLS-1$
647
		output.print(tag);
716
		printAttribute("resource", resource, true); //$NON-NLS-1$
648
		output.println(">"); //$NON-NLS-1$
717
		printAttribute("depth", depth, false); //$NON-NLS-1$
718
		output.println("/>"); //$NON-NLS-1$
649
	}
719
	}
650
720
651
	/**
721
	/**
652
	 * Print an end tag in the Ant script for the given element name.
722
	 * Print a start tag in the Ant script for the given element name.
653
	 * 
723
	 * 
654
	 * @param tag the name of the element
724
	 * @param tag the name of the element
655
	 */
725
	 */
656
	public void printEndTag(String tag) {
726
	public void printStartTag(String tag) {
657
		printTab();
727
		printTab();
658
		output.print("</"); //$NON-NLS-1$
728
		output.print("<"); //$NON-NLS-1$
659
		output.print(tag);
729
		output.print(tag);
660
		output.println(">"); //$NON-NLS-1$
730
		output.println(">"); //$NON-NLS-1$
661
	}
731
	}
662
732
663
	/**
733
	/**
664
	 * Print the given number of tabs to the Ant script.
665
	 */
666
	protected void printTab() {
667
		for (int i = 0; i < indent; i++)
668
			output.print("\t"); //$NON-NLS-1$
669
	}
670
671
	/**
672
	 * Print the given string to the Ant script followed by a carriage-return.
673
	 * 
674
	 * @param message the string to print
675
	 */
676
	public void println(String message) {
677
		printTab();
678
		output.println(message);
679
	}
680
681
	/**
682
	 * Print the given string to the Ant script.
734
	 * Print the given string to the Ant script.
683
	 * 
735
	 * 
684
	 * @param message
736
	 * @param string the string to write to the file
685
	 */
737
	 */
686
	public void print(String message) {
738
	public void printString(String string) {
687
		output.print(message);
739
		printTab();
740
		output.println(string);
688
	}
741
	}
689
742
690
	/**
743
	public void printSubantTask(String antfile, String target, String buildpath, String failOnError, Map properties, Map references) {
691
	 * Print a carriage-return to the Ant script.
744
		printTab();
692
	 */
745
		output.print("<subant"); //$NON-NLS-1$
693
	public void println() {
746
		printAttribute("antfile", antfile, false); //$NON-NLS-1$
694
		output.println();
747
		printAttribute("target", target, false); //$NON-NLS-1$
748
		printAttribute("failonerror", failOnError, false);   //$NON-NLS-1$
749
		printAttribute("buildpath", buildpath, false);  //$NON-NLS-1$
750
		if (properties == null && references == null)
751
			output.println("/>"); //$NON-NLS-1$
752
		else {
753
			output.println(">"); //$NON-NLS-1$
754
			indent++;
755
			if( properties != null ) {
756
				Set entries = properties.entrySet();
757
				for (Iterator iter = entries.iterator(); iter.hasNext();) {
758
					Map.Entry entry = (Map.Entry) iter.next();
759
					printProperty((String) entry.getKey(), (String) entry.getValue());
760
				}
761
			}
762
			if( references != null ){
763
				Set entries = references.entrySet();
764
				for (Iterator iter = entries.iterator(); iter.hasNext();) {
765
					Map.Entry entry = (Map.Entry) iter.next();
766
					printTab();
767
					print("<reference refid=\"" + (String)entry.getKey() + "\""); //$NON-NLS-1$ //$NON-NLS-2$
768
					if( entry.getValue() != null ){
769
						print(" torefid=\"" + (String) entry.getValue() + "\""); //$NON-NLS-1$ //$NON-NLS-2$
770
					}
771
					print("/>"); //$NON-NLS-1$
772
					println();
773
				}
774
			}
775
			indent--;
776
			printTab();
777
			output.println("</subant>"); //$NON-NLS-1$
778
		}
695
	}
779
	}
696
780
697
	/**
781
	/**
698
	 * Print the given task to the Ant script.
782
	 * Print the given number of tabs to the Ant script.
699
	 * 
700
	 * @param task the task to print
701
	 */
783
	 */
702
	public void print(ITask task) {
784
	protected void printTab() {
703
		task.print(this);
785
		for (int i = 0; i < indent; i++)
786
			output.print("\t"); //$NON-NLS-1$
704
	}
787
	}
705
788
706
	/**
789
	/**
Lines 732-821 Link Here
732
		indent--;
815
		indent--;
733
		printEndTag("target"); //$NON-NLS-1$
816
		printEndTag("target"); //$NON-NLS-1$
734
	}
817
	}
735
818
	
736
	/**
819
	public void printTarTask(String zipfile, String basedir, boolean filesOnly, boolean update, FileSet[] fileSets) {
737
	 * Print a <code>eclipse.refreshLocal</code> task to the script. This task refreshes
738
	 * the specified resource in the workspace, to the specified depth. 
739
	 * 
740
	 * @param resource the resource to refresh
741
	 * @param depth one of <code>IResource.DEPTH_ZERO</code>,
742
	 *   <code>IResource.DEPTH_ONE</code>, or <code>IResource.DEPTH_INFINITY</code>
743
	 */
744
	public void printRefreshLocalTask(String resource, String depth) {
745
		printTab();
746
		output.print("<eclipse.refreshLocal"); //$NON-NLS-1$
747
		printAttribute("resource", resource, true); //$NON-NLS-1$
748
		printAttribute("depth", depth, false); //$NON-NLS-1$
749
		output.println("/>"); //$NON-NLS-1$
750
	}
751
752
	public void printChmod(String dir, String rights, String files) {
753
		printTab();
754
		output.print("<chmod perm=\"" + rights + "\" "); //$NON-NLS-1$//$NON-NLS-2$
755
		output.print("dir=\"" + dir + "\" "); //$NON-NLS-1$//$NON-NLS-2$
756
		output.print("includes=\"" + files + "\" /> "); //$NON-NLS-1$ //$NON-NLS-2$
757
		output.println();
758
	}
759
760
	public void printGet(String source, String destination, String login, String password, boolean usetimestamp) {
761
		printTab();
762
		output.print("<get "); //$NON-NLS-1$
763
		printAttribute("username", login, false); //$NON-NLS-1$
764
		printAttribute("password", password, false); //$NON-NLS-1$
765
		printAttribute("src", source, true); //$NON-NLS-1$
766
		printAttribute("dest", destination, true); //$NON-NLS-1$
767
		printAttribute("usetimestamp", usetimestamp ? "true" : null, false); //$NON-NLS-1$ //$NON-NLS-2$
768
		output.println("/>"); //$NON-NLS-1$
769
	}
770
771
	public void printGZip(String source, String destination) {
772
		printTab();
773
		output.println("<gzip src=\"" + source + "\" zipfile=\"" + destination + "\"/>"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
774
	}
775
776
	/**
777
	 * Print a <code> eclipse.convertTask</code> task to the script. This task convert a file path to 
778
	 * an Eclipse resource or vice-versa. 
779
	 *
780
	 * @param toConvert the entry to convert 
781
	 * @param propertyName the property where to store the result of the convertion
782
	 * @param isEclipseResource true if toConvert refers to an eclipse resource. 
783
	 */
784
	public void printConvertPathTask(String toConvert, String propertyName, boolean isEclipseResource) {
785
		printTab();
820
		printTab();
786
		output.print("<eclipse.convertPath"); //$NON-NLS-1$
821
		output.print("<tar"); //$NON-NLS-1$
787
		if (isEclipseResource == false)
822
		printAttribute("destfile", zipfile, true); //$NON-NLS-1$
788
			printAttribute("fileSystemPath", toConvert, true); //$NON-NLS-1$
823
		printAttribute("basedir", basedir, false); //$NON-NLS-1$
789
		else
824
		printAttribute("compression", "gzip", true); //$NON-NLS-1$//$NON-NLS-2$
790
			printAttribute("resourcePath", toConvert, true); //$NON-NLS-1$
825
		if (fileSets == null)
791
		printAttribute("property", propertyName, true); //$NON-NLS-1$
826
			output.println("/>"); //$NON-NLS-1$
792
		output.println("/>"); //$NON-NLS-1$
827
		else {
828
			output.println(">"); //$NON-NLS-1$
829
			indent++;
830
			for (int i = 0; i < fileSets.length; i++)
831
				if (fileSets[i] != null)
832
					fileSets[i].print(this);
833
			indent--;
834
			printTab();
835
			output.println("</tar>"); //$NON-NLS-1$
836
		}
793
	}
837
	}
794
838
795
	/**
839
	/**
796
	 * Print a <code> dirname </code> task to the script.
840
	 * Print a <code>zip</code> task to this script.
797
	 * @param property
841
	 * 
798
	 * @param file
842
	 * @param zipfile the destination file name
843
	 * @param basedir the source directory to start the zip
844
	 * @param filesOnly <code>true</code> if the resulting zip file should contain only files and not directories
845
	 * @param update ndicates whether to update or overwrite the destination file if it already exists
846
	 * @param fileSets the inclusion/exclusion rules to use when zipping
799
	 */
847
	 */
800
	public void printDirName(String property, String file) {
848
	public void printZipTask(String zipfile, String basedir, boolean filesOnly, boolean update, FileSet[] fileSets) {
801
		printTab();
849
		printTab();
802
		output.print("<dirname"); //$NON-NLS-1$
850
		output.print("<zip"); //$NON-NLS-1$
803
		printAttribute("property", property, true); //$NON-NLS-1$
851
		printAttribute("destfile", zipfile, true); //$NON-NLS-1$
804
		printAttribute("file", file, true); //$NON-NLS-1$
852
		printAttribute("basedir", basedir, false); //$NON-NLS-1$
805
		output.println("/>"); //$NON-NLS-1$
853
		printAttribute("filesonly", filesOnly ? "true" : "false", true); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
806
	}
854
		printAttribute("whenempty", "skip", true); //$NON-NLS-1$//$NON-NLS-2$
807
	
855
		printAttribute("update", update ? "true" : "false", true); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
808
	/**
856
		if (fileSets == null)
809
	 * Print a <code>Condition</code> task with isset test to the script
857
			output.println("/>"); //$NON-NLS-1$
810
	 * @param property		name of the property to set	
858
		else {
811
	 * @param value			value to set the property to
859
			output.println(">"); //$NON-NLS-1$
812
	 * @param testProperty	name of the property for the isset test
860
			indent++;
813
	 */
861
			for (int i = 0; i < fileSets.length; i++)
814
	public void printConditionIsSet(String property, String value, String testProperty) {
862
				if (fileSets[i] != null)
815
		println("<condition property=\"" + property + "\" value=\"" + value + "\">"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
863
					fileSets[i].print(this);
816
		indent++;
864
			indent--;
817
		println("<isset property=\"" + testProperty + "\"/>"); //$NON-NLS-1$ //$NON-NLS-2$
865
			printTab();
818
		indent--;
866
			output.println("</zip>"); //$NON-NLS-1$
819
		printEndTag("condition"); //$NON-NLS-1$
867
		}
820
	}
868
	}
821
}
869
}
(-)plugin.properties (+3 lines)
Lines 10-12 Link Here
10
###############################################################################
10
###############################################################################
11
pluginName = Plug-in Development Environment Build Support
11
pluginName = Plug-in Development Environment Build Support
12
providerName = Eclipse.org
12
providerName = Eclipse.org
13
14
15
fetchTaskFactories.name = Fetch Script Task Factories
(-).cvsignore (+6 lines)
Lines 1-3 Link Here
1
bin
1
bin
2
lib
2
lib
3
bin_ant
3
bin_ant
4
temp*
5
build.xml
6
pdebuild.jar
7
org.eclipse.pde.build_*.zip
8
pdebuildsrc.zip
9
javaCompiler.pdebuild.jar.args
(-)build.properties (-1 / +2 lines)
Lines 22-27 Link Here
22
jars.compile.order = pdebuild.jar,\
22
jars.compile.order = pdebuild.jar,\
23
                     lib/pdebuild-ant.jar
23
                     lib/pdebuild-ant.jar
24
source.pdebuild.jar = src/
24
source.pdebuild.jar = src/
25
src.includes = about.html
25
src.includes = about.html,\
26
               schema/
26
source.lib/pdebuild-ant.jar = src_ant/
27
source.lib/pdebuild-ant.jar = src_ant/
27
jars.extra.classpath=platform:/plugin/org.apache.ant/lib/ant.jar
28
jars.extra.classpath=platform:/plugin/org.apache.ant/lib/ant.jar
(-)plugin.xml (+11 lines)
Lines 1-6 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
1
<?xml version="1.0" encoding="UTF-8"?>
2
<?eclipse version="3.0"?>
2
<?eclipse version="3.0"?>
3
<plugin>
3
<plugin>
4
   <extension-point id="fetchTaskFactories" name="%fetchTaskFactories.name" schema="schema/fetchTaskFactories.exsd"/>
4
<!-- Tasks -->
5
<!-- Tasks -->
5
   <extension
6
   <extension
6
         point="org.eclipse.ant.core.antTasks">
7
         point="org.eclipse.ant.core.antTasks">
Lines 85-88 Link Here
85
      </application>
86
      </application>
86
   </extension>
87
   </extension>
87
88
89
   <extension
90
         point="org.eclipse.pde.build.fetchTaskFactories">
91
      <factory
92
            class="org.eclipse.pde.internal.build.fetch.COPYFetchTasksFactory"
93
            id="COPY"/>
94
      <factory
95
            class="org.eclipse.pde.internal.build.fetch.CVSFetchTaskFactory"
96
            id="CVS"/>
97
   </extension>
98
88
</plugin>
99
</plugin>
(-)META-INF/MANIFEST.MF (-2 / +3 lines)
Lines 2-8 Link Here
2
Bundle-ManifestVersion: 2
2
Bundle-ManifestVersion: 2
3
Bundle-Name: %pluginName
3
Bundle-Name: %pluginName
4
Bundle-Version: 3.2.0.qualifier
4
Bundle-Version: 3.2.0.qualifier
5
Bundle-SymbolicName: org.eclipse.pde.build; singleton:=true
5
Bundle-SymbolicName: org.eclipse.pde.build;singleton:=true
6
Bundle-Vendor: %providerName
6
Bundle-Vendor: %providerName
7
Bundle-ClassPath: pdebuild.jar
7
Bundle-ClassPath: pdebuild.jar
8
Bundle-Activator: org.eclipse.pde.internal.build.BuildActivator
8
Bundle-Activator: org.eclipse.pde.internal.build.BuildActivator
Lines 11-17 Link Here
11
 org.eclipse.ant.core,
11
 org.eclipse.ant.core,
12
 org.eclipse.update.core,
12
 org.eclipse.update.core,
13
 org.eclipse.core.runtime.compatibility;resolution:=optional
13
 org.eclipse.core.runtime.compatibility;resolution:=optional
14
Export-Package: org.eclipse.pde.internal.build;x-friends:="org.eclipse.pde.ui",
14
Export-Package: org.eclipse.pde.build,
15
 org.eclipse.pde.internal.build;x-friends:="org.eclipse.pde.ui",
15
 org.eclipse.pde.internal.build.ant;x-friends:="org.eclipse.pde.ui",
16
 org.eclipse.pde.internal.build.ant;x-friends:="org.eclipse.pde.ui",
16
 org.eclipse.pde.internal.build.builder;x-friends:="org.eclipse.pde.ui",
17
 org.eclipse.pde.internal.build.builder;x-friends:="org.eclipse.pde.ui",
17
 org.eclipse.pde.internal.build.packager;x-friends:="org.eclipse.pde.ui",
18
 org.eclipse.pde.internal.build.packager;x-friends:="org.eclipse.pde.ui",
(-)src/org/eclipse/pde/internal/build/fetch/CVSFetchTaskFactory.java (+130 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors: 
9
 *     IBM Corporation - initial API and implementation
10
 *     Gunnar Wagenknecht - adaption to new fetch script builder API
11
 **********************************************************************/
12
package org.eclipse.pde.internal.build.fetch;
13
14
import java.util.HashMap;
15
import java.util.Map;
16
import org.eclipse.core.runtime.*;
17
import org.eclipse.osgi.util.NLS;
18
import org.eclipse.pde.build.FetchTaskFactory;
19
import org.eclipse.pde.internal.build.IPDEBuildConstants;
20
import org.eclipse.pde.internal.build.Messages;
21
import org.eclipse.pde.internal.build.ant.AntScript;
22
import org.eclipse.pde.internal.build.ant.ITask;
23
24
/**
25
 * An <code>FetchTaskFactory</code> for building fetch scripts that will
26
 * fetch content from a CVS repository (id: <code>CVS</code>).
27
 * <p>
28
 * Map file arguments:
29
 * <code>&lt;TAG&gt;,&lt;CVSROOT&gt;[,&lt;PASSWORD&gt;[,&lt;PATH&gt;[,&lt;CVSPASSFILE&gt;]]]</code>
30
 * </p>
31
 */
32
public class CVSFetchTaskFactory extends FetchTaskFactory implements IPDEBuildConstants {
33
	public static final String ID = "CVS"; //$NON-NLS-1$
34
	
35
	private static final String CVSPASSFILE = "cvsPassFile"; //$NON-NLS-1$
36
	private static final String CVSROOT = "cvsRoot"; //$NON-NLS-1$
37
	private static final String PASSWORD = "password"; //$NON-NLS-1$
38
	private static final String PATH = "path"; //$NON-NLS-1$
39
	private static final String TAG = "tag"; //$NON-NLS-1$
40
41
	private static final ITask GET_FROM_CVS_TASK = new ITask() {
42
		public void print(AntScript script) {
43
			script.printCVSTask("export -d ${destination} -r ${tag} ${package}", "${cvsRoot}", null, null, null, "${quiet}", null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
44
		}
45
	};
46
47
	public CharSequence generateAuthentificationTask(final String element, final String type, final Map entryInfos) throws CoreException {
48
		return AntScript.taskAsString(new ITask() {
49
			public void print(AntScript script) {
50
				String password = (String) entryInfos.get(PASSWORD);
51
				String cvsPassFileLocation = (String) entryInfos.get(CVSPASSFILE);
52
				if (password != null)
53
					script.printCVSPassTask((String) entryInfos.get(CVSROOT), password, cvsPassFileLocation);
54
			}
55
		});
56
	}
57
58
	public Map generatePropertiesForFetchTask(String element, String type, Map entryInfos, String destination, boolean manifestFileOnly) {
59
		Map params = new HashMap(5);
60
61
		// we directly export the CVS content into the destination
62
		params.put("destination", destination); //$NON-NLS-1$
63
		params.put(TAG, entryInfos.get(TAG));
64
		params.put(CVSROOT, entryInfos.get(CVSROOT));
65
		params.put("quiet", "${quiet}"); //$NON-NLS-1$ //$NON-NLS-2$
66
67
		String cvsPackage = ((String) entryInfos.get(PATH) == null ? element : (String) entryInfos.get(PATH));
68
		if (type.equals(ELEMENT_TYPE_FEATURE)) {
69
			cvsPackage += manifestFileOnly ? '/' + DEFAULT_FEATURE_FILENAME_DESCRIPTOR : ""; //$NON-NLS-1$
70
		} else if (type.equals(ELEMENT_TYPE_PLUGIN)) {
71
			cvsPackage += manifestFileOnly ? '/' + DEFAULT_PLUGIN_FILENAME_DESCRIPTOR : ""; //$NON-NLS-1$
72
		} else if (type.equals(ELEMENT_TYPE_FRAGMENT)) {
73
			cvsPackage += manifestFileOnly ? '/' + DEFAULT_FRAGMENT_FILENAME_DESCRIPTOR : ""; //$NON-NLS-1$
74
		} else if (type.equals(ELEMENT_TYPE_BUNDLE)) {
75
			cvsPackage += manifestFileOnly ? '/' + DEFAULT_BUNDLE_FILENAME_DESCRIPTOR : "";//$NON-NLS-1$ 
76
		}
77
		params.put("package", cvsPackage); //$NON-NLS-1$
78
79
		return params;
80
	}
81
82
	public CharSequence generateRetrieveFilesTask(final String element, final String type, final Map entryInfos, final String destination, final String[] files) throws CoreException {
83
		return AntScript.taskAsString(new ITask() {
84
			public void print(AntScript script) {
85
				String cvsRoot = (String) entryInfos.get(CVSROOT);
86
				String tag = (String) entryInfos.get(TAG);
87
				String path = (String) entryInfos.get(PATH);
88
				String password = (String) entryInfos.get(PASSWORD);
89
				String cvsPassFileLocation = (String) entryInfos.get(CVSPASSFILE);
90
91
				if (password != null)
92
					script.printCVSPassTask(cvsRoot, password, cvsPassFileLocation);
93
94
				for (int i = 0; i < files.length; i++) {
95
					String file = files[i];
96
					IPath filePath;
97
					if (path != null) {
98
						filePath = new Path(path).append(file);
99
					} else {
100
						filePath = new Path(element).append(file);
101
					}
102
103
					script.printCVSTask("export -d " + destination + " -r " + tag + " " + filePath.toString(), cvsRoot, null, null, null, "true", null); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ //$NON-NLS-4$
104
				}
105
			}
106
		});
107
	}
108
109
	public CharSequence getFetchTask() throws CoreException {
110
		return AntScript.taskAsString(GET_FROM_CVS_TASK);
111
	}
112
113
	public String getTagToFetch(String element, String type, Map entryInfos) {
114
		return (String) entryInfos.get(TAG);
115
	}
116
117
	public void processMapFileEntry(String element, String type, String[] arguments, String fetchTag, Map entryInfos) throws CoreException {
118
		if (arguments.length < 2) {
119
			String message = NLS.bind(Messages.error_incorrectDirectoryEntry, element);
120
			throw new CoreException(new Status(IStatus.ERROR, PI_PDEBUILD, EXCEPTION_ENTRY_MISSING, message, null));
121
		}
122
123
		entryInfos.put(CVSPASSFILE, (arguments.length > 4 && !arguments[4].equals("")) ? arguments[4] : null); //$NON-NLS-1$
124
		entryInfos.put(TAG, (null == fetchTag || fetchTag.trim().length() == 0) ? arguments[0] : fetchTag);
125
		entryInfos.put(CVSROOT, arguments[1]);
126
		entryInfos.put(PASSWORD, (arguments.length > 2 && !arguments[2].equals("")) ? arguments[2] : null); //$NON-NLS-1$
127
128
		entryInfos.put(PATH, (arguments.length > 3 && !arguments[3].equals("")) ? arguments[3] : null); //$NON-NLS-1$ 
129
	}
130
}
(-)src/org/eclipse/pde/internal/build/fetch/COPYFetchTasksFactory.java (+132 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2004, 2006 Eclipse Foundation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Gunnar Wagenknecht - Initial API and implementation
10
 **********************************************************************/
11
package org.eclipse.pde.internal.build.fetch;
12
13
import java.util.HashMap;
14
import java.util.Map;
15
import org.eclipse.core.runtime.*;
16
import org.eclipse.osgi.util.NLS;
17
import org.eclipse.pde.build.FetchTaskFactory;
18
import org.eclipse.pde.internal.build.IPDEBuildConstants;
19
import org.eclipse.pde.internal.build.Messages;
20
import org.eclipse.pde.internal.build.ant.*;
21
22
/**
23
 * An <code>FetchTaskFactory</code> that fetches features and plugins by
24
 * copying from a specific location (id: <code>COPY</code>).
25
 * <p>
26
 * Map file arguments:
27
 * <code>&lt;ROOT_LOCATION&gt;[,&lt;ELEMENT_LOCATION&gt;]</code>
28
 * <dl>
29
 * <dt>ROOT_LOCATION</dt>
30
 * <dd>The ROOT_LOCATION (eg. <code>/source/eclipse</code>, or
31
 * <code>D:/dev/myproduct</code>) is used as root path to determine the
32
 * location to fetch. It can be overwritten via the
33
 * <code>fetchTag</code> to fetch from another location (for example, on a different machine).</dd>
34
 * </dl>
35
 * <dt>ELEMENT_LOCATION</dt>
36
 * <dd>A path withing the ROOT_LOCATION (eg.
37
 * <code>org.eclipse.sdk-feature/features/org.eclipse.rcp</code>) to retrive
38
 * the element from if it is not within the root. If this is not provided the
39
 * default path will be used which simply maps to the element name.</dd>
40
 * </dl>
41
 * </p>
42
 */
43
public class COPYFetchTasksFactory extends FetchTaskFactory implements IPDEBuildConstants {
44
45
	public static final String ID = "COPY"; //$NON-NLS-1$
46
47
	private static final String PATH = "path"; //$NON-NLS-1$
48
	private static final String ROOT = "root"; //$NON-NLS-1$
49
50
	private static final ITask GET_FROM_PATH_TASK = new ITask() {
51
		public void print(AntScript script) {
52
			FileSet dir = new FileSet("${sourcePath}", null, null, null, null, null, null); //$NON-NLS-1$
53
			script.printCopyTask(null, "${destination}", new FileSet[] {dir}, false, true); //$NON-NLS-1$ 
54
		}
55
	};
56
57
	public CharSequence generateAuthentificationTask(String element, String type, Map entryInfos) {
58
		// not necessary
59
		return null;
60
	}
61
62
	public Map generatePropertiesForFetchTask(String element, String type, Map entryInfos, String destination, boolean xmlFileOnly) {
63
		Map params = new HashMap(2);
64
65
		// we directly export the CVS content into the destination
66
		params.put("destination", destination); //$NON-NLS-1$
67
		params.put("quiet", "${quiet}"); //$NON-NLS-1$ //$NON-NLS-2$
68
69
		String root = (String) entryInfos.get(ROOT);
70
		String path = (String) entryInfos.get(PATH);
71
		IPath sourcePath = new Path(root);
72
		if (path != null) {
73
			sourcePath = sourcePath.append(path);
74
		} else {
75
			sourcePath = sourcePath.append(element);
76
		}
77
78
		if (xmlFileOnly) {
79
			if (type.equals("feature")) { //$NON-NLS-1$
80
				sourcePath.append(DEFAULT_FEATURE_FILENAME_DESCRIPTOR);
81
			} else if (type.equals("plugin")) { //$NON-NLS-1$
82
				sourcePath.append(DEFAULT_PLUGIN_FILENAME_DESCRIPTOR);
83
			} else if (type.equals("fragment")) { //$NON-NLS-1$
84
				sourcePath.append(DEFAULT_FRAGMENT_FILENAME_DESCRIPTOR);
85
			}
86
		}
87
		params.put("sourcePath", sourcePath.toString()); //$NON-NLS-1$
88
89
		return params;
90
	}
91
92
	public CharSequence generateRetrieveFilesTask(final String element, final String type, final Map entryInfos, final String destination, final String[] files) throws CoreException {
93
		return AntScript.taskAsString(new ITask() {
94
			public void print(AntScript script) {
95
				String root = (String) entryInfos.get(ROOT);
96
				String path = (String) entryInfos.get(PATH);
97
98
				for (int i = 0; i < files.length; i++) {
99
					String file = files[i];
100
					IPath filePath = new Path(root);
101
					if (path != null) {
102
						filePath = filePath.append(path).append(file);
103
					} else {
104
						filePath = filePath.append(element).append(file);
105
					}
106
107
					script.printCopyTask(filePath.toString(), destination, null, false, true);
108
				}
109
			}
110
		});
111
	}
112
113
	public CharSequence getFetchTask() throws CoreException {
114
		return AntScript.taskAsString(GET_FROM_PATH_TASK);
115
	}
116
117
	public String getTagToFetch(String element, String type, Map entryInfos) {
118
		return (String) entryInfos.get(ROOT);
119
	}
120
121
	public void processMapFileEntry(String element, String type, String[] arguments, String fetchTag, Map entryInfos) throws CoreException {
122
123
		if (arguments.length < 1) {
124
			String message = NLS.bind(Messages.error_incorrectDirectoryEntry, element);
125
			throw new CoreException(new Status(IStatus.ERROR, PI_PDEBUILD, EXCEPTION_ENTRY_MISSING, message, null));
126
		}
127
128
		entryInfos.put(ROOT, (null == fetchTag || fetchTag.trim().length() == 0) ? arguments[0] : fetchTag);
129
		entryInfos.put(PATH, (arguments.length > 1 && arguments[1].trim().length() > 0) ? arguments[1] : null);
130
	}
131
132
}
(-)schema/fetchTaskFactories.exsd (+130 lines)
Added Link Here
1
<?xml version='1.0' encoding='UTF-8'?>
2
<!-- Schema file written by PDE -->
3
<schema targetNamespace="org.eclipse.pde.build">
4
<annotation>
5
      <appInfo>
6
         <meta.schema plugin="org.eclipse.pde.build" id="fetchScriptBuilders" name="Fetch Script Builder"/>
7
      </appInfo>
8
      <documentation>
9
         This extension point provides factories for constructing repository specific fetch script tasks during the PDE Build fetch process.
10
      </documentation>
11
   </annotation>
12
13
   <element name="extension">
14
      <complexType>
15
         <sequence>
16
            <element ref="factory" minOccurs="1" maxOccurs="unbounded"/>
17
         </sequence>
18
         <attribute name="point" type="string" use="required">
19
            <annotation>
20
               <documentation>
21
                  
22
               </documentation>
23
            </annotation>
24
         </attribute>
25
         <attribute name="id" type="string">
26
            <annotation>
27
               <documentation>
28
                  
29
               </documentation>
30
            </annotation>
31
         </attribute>
32
         <attribute name="name" type="string">
33
            <annotation>
34
               <documentation>
35
                  
36
               </documentation>
37
            </annotation>
38
         </attribute>
39
      </complexType>
40
   </element>
41
42
   <element name="factory">
43
      <annotation>
44
         <appInfo>
45
            <meta.element labelAttribute="id"/>
46
         </appInfo>
47
         <documentation>
48
            Defines a fetch task factory.
49
         </documentation>
50
      </annotation>
51
      <complexType>
52
         <attribute name="id" type="string" use="required">
53
            <annotation>
54
               <documentation>
55
                  The factory id (must be unique).
56
               </documentation>
57
            </annotation>
58
         </attribute>
59
         <attribute name="class" type="string" use="required">
60
            <annotation>
61
               <documentation>
62
                  The factory implementation (must extend &lt;code&gt;org.eclipse.pde.build.FetchTaskFactory&lt;/code&gt; and must provide a parameter less, public constructor).
63
               </documentation>
64
               <appInfo>
65
                  <meta.attribute kind="java" basedOn="org.eclipse.pde.build.FetchTaskFactory"/>
66
               </appInfo>
67
            </annotation>
68
         </attribute>
69
      </complexType>
70
   </element>
71
72
   <annotation>
73
      <appInfo>
74
         <meta.section type="since"/>
75
      </appInfo>
76
      <documentation>
77
         3.2
78
      </documentation>
79
   </annotation>
80
81
   <annotation>
82
      <appInfo>
83
         <meta.section type="examples"/>
84
      </appInfo>
85
      <documentation>
86
         &lt;pre&gt;
87
&lt;extension point=&quot;org.eclipse.pde.build.fetchTaskFactories&quot;&gt;
88
    &lt;factory
89
        class=&quot;org.eclipse.pde.internal.build.fetch.COPYFetchTasksFactory&quot;
90
        id=&quot;COPY&quot;/&gt;
91
    &lt;factory
92
        class=&quot;org.eclipse.pde.internal.build.fetch.CVSFetchTaskFactory&quot;
93
        id=&quot;CVS&quot;/&gt;
94
&lt;/extension&gt;
95
&lt;/pre&gt;
96
      </documentation>
97
   </annotation>
98
99
   <annotation>
100
      <appInfo>
101
         <meta.section type="apiInfo"/>
102
      </appInfo>
103
      <documentation>
104
         A fetch task factory must extend &lt;code&gt;org.eclipse.pde.build.FetchTaskFactory&lt;/code&gt; and must provide a parameter less, public constructor.
105
      </documentation>
106
   </annotation>
107
108
   <annotation>
109
      <appInfo>
110
         <meta.section type="implementation"/>
111
      </appInfo>
112
      <documentation>
113
         The following fetch task factories are provided by PDE Build.
114
&lt;ul&gt;
115
&lt;li&gt;a CVS fetch task factroy for fetching features and plug-ins from CVS repositories&lt;/li&gt;
116
&lt;li&gt;a COPY fetch task factory for copying features and plug-ins from arbitrary file system locations&lt;/li&gt;
117
&lt;/ul&gt;
118
      </documentation>
119
   </annotation>
120
121
   <annotation>
122
      <appInfo>
123
         <meta.section type="copyright"/>
124
      </appInfo>
125
      <documentation>
126
         
127
      </documentation>
128
   </annotation>
129
130
</schema>
(-)src/org/eclipse/pde/build/FetchTaskFactory.java (+214 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2004, 2006 Eclipse Foundation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Gunnar Wagenknecht - Initial API and implementation
10
 **********************************************************************/
11
package org.eclipse.pde.build;
12
13
import java.util.Map;
14
import org.eclipse.core.runtime.CoreException;
15
16
/**
17
 * A <code>FetchTaskFactory</code> constructs a repository specific fetch
18
 * script for the PDE build process.
19
 * <p>
20
 * It is registered via the
21
 * <code>org.eclipse.pde.build.fetchScriptBuilder</code> extension point.
22
 * </p>
23
 * @since 3.2
24
 */
25
public abstract class FetchTaskFactory {
26
27
	/** element type <code>bundle</code> */
28
	public static final String ELEMENT_TYPE_BUNDLE = "bundle"; //$NON-NLS-1$
29
30
	/** element type <code>feature</code> */
31
	public static final String ELEMENT_TYPE_FEATURE = "feature"; //$NON-NLS-1$
32
33
	/** element type <code>fragment</code> */
34
	public static final String ELEMENT_TYPE_FRAGMENT = "fragment"; //$NON-NLS-1$
35
36
	/** element type <code>plugin</code> */
37
	public static final String ELEMENT_TYPE_PLUGIN = "plugin"; //$NON-NLS-1$
38
39
	/** map key of the element type (value <code>type</code>) */
40
	public static final String KEY_ELEMENT_TYPE = "type"; //$NON-NLS-1$
41
42
	/** map key of the element name (value <code>element</code>) */
43
	public static final String KEY_ELEMENT_NAME = "element"; //$NON-NLS-1$
44
45
	/** map key of the fetch task factory (value <code>factory</code>) */
46
	public static final String KEY_FACTORY = "factory"; //$NON-NLS-1$
47
48
	/**
49
	 * Generates an ANT task that is necessary for authentificate against the
50
	 * repository.
51
	 * 
52
	 * @param element
53
	 *            the element name
54
	 * @param type
55
	 *            the element type (one of
56
	 *            {@link #ELEMENT_TYPE_FEATURE <code>feature</code>},
57
	 *            {@link #ELEMENT_TYPE_PLUGIN <code>plugin</code>},
58
	 *            {@link #ELEMENT_TYPE_FRAGMENT <code>fragment</code>} or
59
	 *            {@link #ELEMENT_TYPE_BUNDLE <code>bundle</code>}) (may not be
60
	 *            <code>null</code>)
61
	 * @param entryInfos
62
	 *            the map with detailed information collected in
63
	 *            {@link #processMapFileEntry(String, String, String[], String, Map)},
64
	 *            additional keys that are set by PDE Build are:
65
	 *            {@link #KEY_ELEMENT_NAME}, 
66
	 *            {@link #KEY_ELEMENT_TYPE} and
67
	 *            {@link #KEY_FACTORY}
68
	 * @return the authentification task (maybe <code>null</code> if not
69
	 *         necessary)
70
	 */
71
	public abstract CharSequence generateAuthentificationTask(String element, String type, Map entryInfos) throws CoreException;
72
73
	/**
74
	 * Generates properties for fetching the specified element via the fetch
75
	 * task.
76
	 * <p>
77
	 * The properties will be set in the fetch script before the fetch task 
78
	 * returned by {@link #getFetchTask()} is executed. This allows to make 
79
	 * the fetch task callable with different arguments.
80
	 * </p>
81
	 * 
82
	 * @param element
83
	 *            the element name
84
	 * @param type
85
	 *            the element type (one of
86
	 *            {@link #ELEMENT_TYPE_FEATURE <code>feature</code>},
87
	 *            {@link #ELEMENT_TYPE_PLUGIN <code>plugin</code>},
88
	 *            {@link #ELEMENT_TYPE_FRAGMENT <code>fragment</code>} or
89
	 *            {@link #ELEMENT_TYPE_BUNDLE <code>bundle</code>}) (may not be
90
	 *            <code>null</code>)
91
	 * @param entryInfos
92
	 *            the map with detailed information collected in
93
	 *            {@link #processMapFileEntry(String, String, String[], String, Map)},
94
	 *            additional keys that are set by PDE Build are:
95
	 *            {@link #KEY_ELEMENT_NAME}, 
96
	 *            {@link #KEY_ELEMENT_TYPE} and
97
	 *            {@link #KEY_FACTORY}
98
	 * @param destination
99
	 *            the destination where the files should be fetched to
100
	 * @param xmlFileOnly
101
	 *            if <code>true</code> only the element's XML descriptor
102
	 *            should be fetched, otherwise the complete element must be
103
	 *            fetched
104
	 * @return the map with properties (must be <code>String</code> keys and
105
	 *         <code>String</code> values)
106
	 * @throws CoreException
107
	 */
108
	public abstract Map generatePropertiesForFetchTask(String element, String type, Map entryInfos, String destination, boolean xmlFileOnly) throws CoreException;
109
110
	/**
111
	 * Generates a task for retrieving the specified files only.
112
	 * 
113
	 * @param element
114
	 *            the element name
115
	 * @param type
116
	 *            the element type (one of
117
	 *            {@link #ELEMENT_TYPE_FEATURE <code>feature</code>},
118
	 *            {@link #ELEMENT_TYPE_PLUGIN <code>plugin</code>},
119
	 *            {@link #ELEMENT_TYPE_FRAGMENT <code>fragment</code>} or
120
	 *            {@link #ELEMENT_TYPE_BUNDLE <code>bundle</code>}) (may not be
121
	 *            <code>null</code>)
122
	 * @param entryInfos
123
	 *            the map with detailed information collected in
124
	 *            {@link #processMapFileEntry(String, String, String[], String, Map)},
125
	 *            additional keys that are set by PDE Build are:
126
	 *            {@link #KEY_ELEMENT_NAME}, 
127
	 *            {@link #KEY_ELEMENT_TYPE} and
128
	 *            {@link #KEY_FACTORY}
129
	 * @param destination
130
	 *            the destination where the files should be fetched to
131
	 * @param files
132
	 *            the list of files to fetch
133
	 * @return the task for fetching the files
134
	 */
135
	public abstract CharSequence generateRetrieveFilesTask(String element, String type, Map entryInfos, String destination, String[] files) throws CoreException;
136
137
	/**
138
	 * Returns the common task that is used to fetch elements specified via Ant
139
	 * properties.
140
	 * <p>
141
	 * This task is wrapped into a target, which is called from within 
142
	 * the element specific generated fetch tasks to fetch an element.
143
	 * Before this task is executed properties collected in 
144
	 * {@link #generatePropertiesForFetchTask(String, String, Map, String, boolean)}
145
	 * are set allowing to pass "arguments" to this task.
146
	 * </p>
147
	 * 
148
	 * @return the common fetch task
149
	 * @see #generatePropertiesForFetchTask(String, String, Map, String,
150
	 *      boolean)
151
	 */
152
	public abstract CharSequence getFetchTask() throws CoreException;
153
154
	/**
155
	 * Returns a version identifyer (eg. TAG name) of the element that will be
156
	 * fetched.
157
	 * 
158
	 * @param element
159
	 *            the element name
160
	 * @param type
161
	 *            the element type (one of
162
	 *            {@link #ELEMENT_TYPE_FEATURE <code>feature</code>},
163
	 *            {@link #ELEMENT_TYPE_PLUGIN <code>plugin</code>},
164
	 *            {@link #ELEMENT_TYPE_FRAGMENT <code>fragment</code>} or
165
	 *            {@link #ELEMENT_TYPE_BUNDLE <code>bundle</code>}) (may not be
166
	 *            <code>null</code>)
167
	 * @param entryInfos
168
	 *            the map with detailed information collected in
169
	 *            {@link #processMapFileEntry(String, String, String[], String, Map)},
170
	 *            additional keys that are set by PDE Build are:
171
	 *            {@link #KEY_ELEMENT_NAME}, 
172
	 *            {@link #KEY_ELEMENT_TYPE} and
173
	 *            {@link #KEY_FACTORY}
174
	 * @return a version identifyer
175
	 */
176
	public abstract String getTagToFetch(String element, String type, Map entryInfos) throws CoreException;
177
178
	/**
179
	 * Processes the specified element with the specified type.
180
	 * <p>
181
	 * The arguments specified in the map file are provided. The map with entry
182
	 * infos should be filled with provider specific information that is
183
	 * required in later processing to sucessfully generate the fetch script.
184
	 * </p>
185
	 * 
186
	 * @param element
187
	 *            the element name (eg. <code>com.my.plugin</code>) (may not
188
	 *            be <code>null</code>)
189
	 * @param type
190
	 *            the element type (one of
191
	 *            {@link #ELEMENT_TYPE_FEATURE <code>feature</code>},
192
	 *            {@link #ELEMENT_TYPE_PLUGIN <code>plugin</code>},
193
	 *            {@link #ELEMENT_TYPE_FRAGMENT <code>fragment</code>} or
194
	 *            {@link #ELEMENT_TYPE_BUNDLE <code>bundle</code>}) (may not be
195
	 *            <code>null</code>)
196
	 * @param arguments
197
	 *            the arguments specified in the build script (may not be
198
	 *            <code>null</code>)
199
	 * @param fetchTag
200
	 *            the fetch tag that will overwrite all tags specified in the
201
	 *            repository if set (maybe <code>null</code> or empty)
202
	 * @param entryInfos
203
	 *            the map to store repository specific information 
204
	 *            (eg., label/tag/authentification informationen)
205
	 *            (may not be <code>null</code>);
206
	 *            reserved keys that must not be used are 
207
	 *            {@link #KEY_ELEMENT_NAME}, 
208
	 *            {@link #KEY_ELEMENT_TYPE} and
209
	 *            {@link #KEY_FACTORY}
210
	 * @throws CoreException
211
	 *             if the arguments are invalid
212
	 */
213
	public abstract void processMapFileEntry(String element, String type, String[] arguments, String fetchTag, Map entryInfos) throws CoreException;
214
}
(-)src/org/eclipse/pde/internal/build/FetchTaskFactoriesRegistry.java (+165 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2004, 2006 Eclipse Foundation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Gunnar Wagenknecht - Initial API and implementation
10
 **********************************************************************/
11
package org.eclipse.pde.internal.build;
12
13
import java.util.*;
14
import org.eclipse.core.runtime.*;
15
import org.eclipse.pde.build.FetchTaskFactory;
16
17
/**
18
 * A registry for acessing fetch task factories.
19
 * @since 3.2
20
 */
21
public class FetchTaskFactoriesRegistry implements IRegistryChangeListener, IPDEBuildConstants {
22
23
	/** the shared instance */
24
	private static FetchTaskFactoriesRegistry instance;
25
26
	/**
27
	 * Creates the singleton registry instance.
28
	 */
29
	private static synchronized void createRegistry() {
30
		if (null != instance)
31
			return;
32
33
		instance = new FetchTaskFactoriesRegistry();
34
		Platform.getExtensionRegistry().addRegistryChangeListener(instance, "org.eclipse.pde.build"); //$NON-NLS-1$
35
	}
36
37
	/**
38
	 * Returns the singleton registry instance.
39
	 * 
40
	 * @return the registry instance
41
	 */
42
	public static FetchTaskFactoriesRegistry getRegistry() {
43
		if (null == instance) {
44
			createRegistry();
45
		}
46
		return instance;
47
	}
48
49
	/**
50
	 * Shuts down the registry.
51
	 */
52
	static void shutdown() {
53
		if (null != instance) {
54
			Platform.getExtensionRegistry().removeRegistryChangeListener(instance);
55
		}
56
	}
57
58
	/** a map of registered factories */
59
	private Map factories;
60
61
	/**
62
	 * Hidden constructor.
63
	 */
64
	private FetchTaskFactoriesRegistry() {
65
		// hidden constructor
66
	}
67
68
	/**
69
	 * Returns the factory instance with the specified id.
70
	 * <p>
71
	 * The instance is not cached. Each time this method is called, a new
72
	 * instance is created.
73
	 * </p>
74
	 * 
75
	 * @param id
76
	 * @return the factory instance (maybe <code>null</code>)
77
	 */
78
	public FetchTaskFactory getFactory(String id) {
79
80
		// ensure initialized
81
		initializeRegistry();
82
83
		IConfigurationElement extension = (IConfigurationElement) factories.get(id);
84
		if (null != extension) {
85
			try {
86
				return (FetchTaskFactory) extension.createExecutableExtension(ATTR_CLASS);
87
			} catch (CoreException e) {
88
				BundleHelper.getDefault().getLog().log(e.getStatus());
89
			}
90
		}
91
		return null;
92
	}
93
94
	/**
95
	 * Returns a collection of registered factory ids.
96
	 * 
97
	 * @return a collection of registered factory ids
98
	 */
99
	public Collection getFactoryIds() {
100
101
		// ensure initialized
102
		initializeRegistry();
103
104
		return factories.keySet();
105
	}
106
107
	/**
108
	 * Initializes the registry
109
	 */
110
	private void initializeRegistry() {
111
112
		// don't initialize twice
113
		if (null != factories)
114
			return;
115
116
		synchronized (factories = new HashMap()) {
117
			IConfigurationElement[] extensions = Platform.getExtensionRegistry().getConfigurationElementsFor(EXT_FETCH_TASK_FACTORIES);
118
			for (int i = 0; i < extensions.length; i++) {
119
				IConfigurationElement extension = extensions[i];
120
				if (ELEM_FACTORY.equals(extension.getName())) {
121
					String id = extension.getAttribute(ATTR_ID);
122
					if (null != id && id.trim().length() > 0) {
123
						factories.put(id, extension);
124
					}
125
				}
126
			}
127
		}
128
	}
129
130
	/*
131
	 * (non-Javadoc)
132
	 * 
133
	 * @see org.eclipse.core.runtime.IRegistryChangeListener#registryChanged(org.eclipse.core.runtime.IRegistryChangeEvent)
134
	 */
135
	public void registryChanged(IRegistryChangeEvent event) {
136
137
		if (null != factories) {
138
			IExtensionDelta[] deltas = event.getExtensionDeltas(PI_PDEBUILD, EXT_FETCH_TASK_FACTORIES);
139
			if (null != deltas && deltas.length > 0) {
140
				synchronized (factories) {
141
					for (int i = 0; i < deltas.length; i++) {
142
						IExtensionDelta delta = deltas[i];
143
						IConfigurationElement[] extensions = delta.getExtension().getConfigurationElements();
144
						for (int j = 0; j < extensions.length; j++) {
145
							IConfigurationElement element = extensions[j];
146
							if (ELEM_FACTORY.equals(element.getName())) {
147
								String id = element.getAttribute(ATTR_ID);
148
								if (null != id && id.trim().length() > 0) {
149
									switch (delta.getKind()) {
150
										case IExtensionDelta.ADDED :
151
											factories.put(id, element);
152
											break;
153
										case IExtensionDelta.REMOVED :
154
											factories.remove(id);
155
											break;
156
									}
157
								}
158
							}
159
						}
160
					}
161
				}
162
			}
163
		}
164
	}
165
}

Return to bug 34757