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/messages.properties (-1 / +1 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
error_noCorrespondingFactory = The element {0} ca not be fetched because the necessary factory ({1}) is not available.
32
error_noCorrespondingFactory = The element {0} can not be fetched because the necessary factory ({1}) is not available.
33
33
34
### exception
34
### exception
35
exception_missingElement = Unable to find element: {0}.
35
exception_missingElement = Unable to find element: {0}.
(-)plugin.xml (+3 lines)
Lines 96-101 Link Here
96
      <factory
96
      <factory
97
            class="org.eclipse.pde.internal.build.fetch.CVSFetchTaskFactory"
97
            class="org.eclipse.pde.internal.build.fetch.CVSFetchTaskFactory"
98
            id="CVS"/>
98
            id="CVS"/>
99
      <factory
100
            class="org.eclipse.pde.internal.build.fetch.COPYFetchTasksFactory"
101
            id="COPY"/>
99
   </extension>
102
   </extension>
100
   
103
   
101
    <extension
104
    <extension
(-)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
 *     IBM - Initial API and implementation
11
 **********************************************************************/
12
package org.eclipse.pde.internal.build.fetch;
13
14
import java.util.Map;
15
import java.util.Properties;
16
import org.eclipse.core.runtime.*;
17
import org.eclipse.osgi.util.NLS;
18
import org.eclipse.pde.build.IAntScript;
19
import org.eclipse.pde.build.IFetchFactory;
20
import org.eclipse.pde.internal.build.*;
21
22
/**
23
 * An <code>IFetchFactory</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 implements IFetchFactory, IPDEBuildConstants {
44
	public static final String ID = "COPY"; //$NON-NLS-1$
45
46
	private static final String SEPARATOR = ","; //$NON-NLS-1$
47
	private static final String OVERRIDE_TAG = ID;
48
49
	//COPY specific keys used in the map being passed around.
50
	private static final String KEY_PATH = "path"; //$NON-NLS-1$
51
	private static final String KEY_ROOT = "root"; //$NON-NLS-1$
52
53
	public void generateRetrieveElementCall(Map entryInfos, IPath destination, IAntScript script) {
54
		String element = (String) entryInfos.get(KEY_ELEMENT_NAME);
55
56
		// we directly copy the disc content into the destination
57
		String root = (String) entryInfos.get(KEY_ROOT);
58
		String path = (String) entryInfos.get(KEY_PATH);
59
		IPath sourcePath = new Path(root);
60
		if (path != null) {
61
			sourcePath = sourcePath.append(path);
62
		} else {
63
			sourcePath = sourcePath.append(element);
64
		}
65
66
		printCopyTask(null, destination.toString(), new String[] {sourcePath.toString()}, false, true, script);
67
	}
68
69
	public void generateRetrieveFilesCall(final Map entryInfos, IPath destination, final String[] files, IAntScript script) {
70
		String root = (String) entryInfos.get(KEY_ROOT);
71
		String path = (String) entryInfos.get(KEY_PATH);
72
73
		for (int i = 0; i < files.length; i++) {
74
			String file = files[i];
75
			IPath filePath = new Path(root);
76
			if (path != null) {
77
				filePath = filePath.append(path).append(file);
78
			} else {
79
				filePath = filePath.append((String) entryInfos.get(KEY_ELEMENT_NAME)).append(file);
80
			}
81
			printCopyTask(filePath.toString(), destination.toString(), null, false, true, script);
82
		}
83
	}
84
85
	public void addTargets(IAntScript script) {
86
		// no additional targets
87
	}
88
89
	public void parseMapFileEntry(String repoSpecificentry, Properties overrideTags, Map entryInfos) throws CoreException {
90
		String[] arguments = Utils.getArrayFromStringWithBlank(repoSpecificentry, SEPARATOR);
91
		if (arguments.length < 1) {
92
			String message = NLS.bind(Messages.error_incorrectDirectoryEntry, entryInfos.get(KEY_ELEMENT_NAME));
93
			throw new CoreException(new Status(IStatus.ERROR, PI_PDEBUILD, EXCEPTION_ENTRY_MISSING, message, null));
94
		}
95
96
		String overrideTag = overrideTags.getProperty(OVERRIDE_TAG);
97
		entryInfos.put(KEY_ROOT, (null == overrideTag || overrideTag.trim().length() == 0) ? arguments[0] : overrideTag);
98
		entryInfos.put(KEY_PATH, (arguments.length > 1 && arguments[1].trim().length() > 0) ? arguments[1] : null);
99
	}
100
101
	/**
102
	 * Print a <code>copy</code> task to the script. The source file is specified 
103
	 * by the <code>file</code> OR the <code>dirs</code> parameter. 
104
	 * The destination directory is specified by the <code>todir</code> parameter. 
105
	 * @param file the source file
106
	 * @param todir the destination directory
107
	 * @param dirs the directories to copy
108
	 * @param overwrite indicates if existing files should be overwritten 
109
	 * @param script the script to print to
110
	 */
111
	private void printCopyTask(String file, String todir, String[] dirs, boolean failOnError, boolean overwrite, IAntScript script) {
112
		script.printTabs();
113
		script.print("<copy"); //$NON-NLS-1$
114
		script.printAttribute("file", file, false); //$NON-NLS-1$
115
		script.printAttribute("todir", todir, false); //$NON-NLS-1$
116
		script.printAttribute("failonerror", failOnError ? "true" : "false", true); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
117
		script.printAttribute("overwrite", overwrite ? "true" : "false", true); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
118
119
		if (dirs == null)
120
			script.println("/>"); //$NON-NLS-1$
121
		else {
122
			script.println(">"); //$NON-NLS-1$
123
			for (int i = 0; i < dirs.length; i++) {
124
				script.printTabs();
125
				script.print("\t<fileset"); //$NON-NLS-1$
126
				script.printAttribute("dir", dirs[i], true); //$NON-NLS-1$
127
				script.println("/>"); //$NON-NLS-1$
128
			}
129
			script.println("</copy>"); //$NON-NLS-1$
130
		}
131
	}
132
}

Return to bug 34757