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

Collapse All | Expand All

(-)src/org/eclipse/pde/internal/build/fetch/CVSFetchTaskFactory.java (-1 / +63 lines)
Lines 59-64 Link Here
59
	private static final String PROP_FILETOCHECK = "fileToCheck"; //$NON-NLS-1$
59
	private static final String PROP_FILETOCHECK = "fileToCheck"; //$NON-NLS-1$
60
	private static final String PROP_ELEMENTNAME = "elementName"; //$NON-NLS-1$
60
	private static final String PROP_ELEMENTNAME = "elementName"; //$NON-NLS-1$
61
61
62
	//Associated repository provider
63
	private static final String CVS_DIRECTIVES = ";type:=psf;provider:=\"org.eclipse.team.cvs.core.cvsnature\""; //$NON-NLS-1$
64
62
	private void generateAuthentificationAntTask(Map entryInfos, IAntScript script) {
65
	private void generateAuthentificationAntTask(Map entryInfos, IAntScript script) {
63
		String password = (String) entryInfos.get(KEY_PASSWORD);
66
		String password = (String) entryInfos.get(KEY_PASSWORD);
64
		String cvsPassFileLocation = (String) entryInfos.get(KEY_CVSPASSFILE);
67
		String cvsPassFileLocation = (String) entryInfos.get(KEY_CVSPASSFILE);
Lines 139-145 Link Here
139
			String tag = (String) entryInfos.get(IFetchFactory.KEY_ELEMENT_TAG);
142
			String tag = (String) entryInfos.get(IFetchFactory.KEY_ELEMENT_TAG);
140
			String cvsRoot = (String) entryInfos.get(KEY_CVSROOT);
143
			String cvsRoot = (String) entryInfos.get(KEY_CVSROOT);
141
			String dest = "true".equalsIgnoreCase((String) entryInfos.get(KEY_PREBUILT)) ? destination.removeLastSegments(1).toString() : destination.toString(); //$NON-NLS-1$
144
			String dest = "true".equalsIgnoreCase((String) entryInfos.get(KEY_PREBUILT)) ? destination.removeLastSegments(1).toString() : destination.toString(); //$NON-NLS-1$
142
			printCVSTask("export -r " + tag + ' ' + filePath.toString(), cvsRoot, dest, null, null, "true", Utils.getPropertyFormat(PROP_REALLYQUIET), null, null, "${fetch.failonerror}", script); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-5$
145
			printCVSTask("export -r " + tag + ' ' + filePath.toString(), cvsRoot, dest, null, null, "true", Utils.getPropertyFormat(PROP_REALLYQUIET), null, null, "${fetch.failonerror}", script); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
143
			script.println("<move file=\"" + destination + '/' + filePath + "\"" + " tofile=\"" + destination.append(file) + "\" failonerror=\"false\" />"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
146
			script.println("<move file=\"" + destination + '/' + filePath + "\"" + " tofile=\"" + destination.append(file) + "\" failonerror=\"false\" />"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
144
		}
147
		}
145
	}
148
	}
Lines 180-185 Link Here
180
			int index = arg.indexOf('=');
183
			int index = arg.indexOf('=');
181
			if (index == -1) {
184
			if (index == -1) {
182
				legacyParseMapFileEntry(arguments, overrideTags, entryInfos);
185
				legacyParseMapFileEntry(arguments, overrideTags, entryInfos);
186
				addProjectReference(entryInfos);
183
				return;
187
				return;
184
			}
188
			}
185
			String key = arg.substring(0, index);
189
			String key = arg.substring(0, index);
Lines 197-202 Link Here
197
		entryInfos.put(KEY_PASSWORD, table.get(KEY_PASSWORD));
201
		entryInfos.put(KEY_PASSWORD, table.get(KEY_PASSWORD));
198
		entryInfos.put(KEY_PATH, table.get(KEY_PATH));
202
		entryInfos.put(KEY_PATH, table.get(KEY_PATH));
199
		entryInfos.put(KEY_PREBUILT, table.get(KEY_PREBUILT));
203
		entryInfos.put(KEY_PREBUILT, table.get(KEY_PREBUILT));
204
		addProjectReference(entryInfos);
205
	}
206
207
	private void addProjectReference(Map entryInfos) {
208
		String repoLocation = (String) entryInfos.get(KEY_CVSROOT);
209
		String module = (String) entryInfos.get(KEY_PATH);
210
		String projectName = (String) entryInfos.get(KEY_ELEMENT_NAME);
211
		String tag = (String) entryInfos.get(IFetchFactory.KEY_ELEMENT_TAG);
212
213
		if (repoLocation != null && projectName != null) {
214
			String sourceURLs = asReference(repoLocation, module != null ? module : projectName, projectName, tag);
215
			if (sourceURLs != null) {
216
				entryInfos.put(Constants.KEY_SOURCE_REFERENCES, sourceURLs + CVS_DIRECTIVES);
217
			}
218
		}
219
	}
220
221
	/**
222
	 * Creates an SCMURL reference to the associated source.
223
	 * 
224
	 * @param repoLocation
225
	 * @param module
226
	 * @param projectName
227
	 * @return project reference string or <code>null</code> if none
228
	 */
229
	private String asReference(String repoLocation, String module, String projectName, String tagName) {
230
		// parse protocol, host, repository root from repoLocation
231
		String sep = repoLocation.substring(0, 1);
232
		String[] split = repoLocation.substring(1).split(sep);
233
		if (split.length == 3) {
234
			String protocol = split[0];
235
			String host = split[1];
236
			int index = host.indexOf('@');
237
			if (index >= 0 && index < host.length() - 2) {
238
				host = host.substring(index + 1);
239
			}
240
			String root = split[2];
241
			StringBuffer buffer = new StringBuffer();
242
			buffer.append("scm:cvs:"); //$NON-NLS-1$
243
			buffer.append(protocol);
244
			buffer.append(':');
245
			buffer.append(host);
246
			buffer.append(':');
247
			buffer.append(root);
248
249
			buffer.append(':');
250
			buffer.append(module);
251
252
			buffer.append(";project="); //$NON-NLS-1$
253
			buffer.append(projectName);
254
255
			if (tagName != null) {
256
				buffer.append(";tag="); //$NON-NLS-1$
257
				buffer.append(tagName);
258
			}
259
			return buffer.toString();
260
		}
261
		return null;
200
	}
262
	}
201
263
202
	/**
264
	/**
(-)src/org/eclipse/pde/build/internal/tests/FetchTests.java (-12 / +20 lines)
Lines 17-22 Link Here
17
import org.eclipse.core.runtime.*;
17
import org.eclipse.core.runtime.*;
18
import org.eclipse.pde.build.tests.BuildConfiguration;
18
import org.eclipse.pde.build.tests.BuildConfiguration;
19
import org.eclipse.pde.build.tests.PDETestCase;
19
import org.eclipse.pde.build.tests.PDETestCase;
20
import org.eclipse.pde.internal.build.IPDEBuildConstants;
20
21
21
/**
22
/**
22
 * These tests are not included in the main test suite unless the "pde.build.includeFetch" system property
23
 * These tests are not included in the main test suite unless the "pde.build.includeFetch" system property
Lines 40-71 Link Here
40
41
41
	public void testGetUnpack() throws Exception {
42
	public void testGetUnpack() throws Exception {
42
		IFolder buildFolder = newTest("testGetUnpack");
43
		IFolder buildFolder = newTest("testGetUnpack");
43
		
44
44
		StringBuffer buffer = new StringBuffer();
45
		StringBuffer buffer = new StringBuffer();
45
		buffer.append("plugin@javax.xml.rpc,1.1.0=GET,http://download.eclipse.org/tools/orbit/downloads/drops/R20090825191606/bundles/javax.xml.rpc_1.1.0.v200905122109.zip,unpack=true\n");
46
		buffer.append("plugin@javax.xml.rpc,1.1.0=GET,http://download.eclipse.org/tools/orbit/downloads/drops/R20090825191606/bundles/javax.xml.rpc_1.1.0.v200905122109.zip,unpack=true\n");
46
		buffer.append("plugin@com.ibm.icu.base,3.6.0=GET,http://download.eclipse.org/tools/orbit/downloads/drops/R20090825191606/updateSite/plugins/com.ibm.icu.base_3.6.0.v20080530.jar,unpack=true,dest=${buildDirectory}/plugins/com.ibm.icu.base_3.6.0/.zip\n");
47
		buffer.append("plugin@com.ibm.icu.base,3.6.0=GET,http://download.eclipse.org/tools/orbit/downloads/drops/R20090825191606/updateSite/plugins/com.ibm.icu.base_3.6.0.v20080530.jar,unpack=true,dest=${buildDirectory}/plugins/com.ibm.icu.base_3.6.0/.zip\n");
47
		buffer.append("plugin@com.ibm.icu.base,3.6.1=GET,http://download.eclipse.org/tools/orbit/downloads/drops/R20090825191606/updateSite/plugins/com.ibm.icu.base_3.6.1.v20080530.jar,unpack=true\n");
48
		buffer.append("plugin@com.ibm.icu.base,3.6.1=GET,http://download.eclipse.org/tools/orbit/downloads/drops/R20090825191606/updateSite/plugins/com.ibm.icu.base_3.6.1.v20080530.jar,unpack=true\n");
48
		Utils.writeBuffer(buildFolder.getFile("directory.txt"), buffer);
49
		Utils.writeBuffer(buildFolder.getFile("directory.txt"), buffer);
49
		
50
50
		Utils.generateFeature(buildFolder, "org.eclipse.pde.build.container.feature", null, new String[] {"javax.xml.rpc", "com.ibm.icu.base;version=3.6.0.qualifier", "com.ibm.icu.base;version=3.6.1.qualifier"});
51
		Utils.generateFeature(buildFolder, "org.eclipse.pde.build.container.feature", null, new String[] {"javax.xml.rpc", "com.ibm.icu.base;version=3.6.0.qualifier", "com.ibm.icu.base;version=3.6.1.qualifier"});
51
		
52
52
		Properties fetchProperties = new Properties();
53
		Properties fetchProperties = new Properties();
53
		fetchProperties.put("buildDirectory", buildFolder.getLocation().toOSString());
54
		fetchProperties.put("buildDirectory", buildFolder.getLocation().toOSString());
54
		fetchProperties.put("type", "feature");
55
		fetchProperties.put("type", "feature");
55
		fetchProperties.put("id", "org.eclipse.pde.build.container.feature");
56
		fetchProperties.put("id", "org.eclipse.pde.build.container.feature");
56
		
57
57
		URL resource = FileLocator.find(Platform.getBundle("org.eclipse.pde.build"), new Path("/scripts/genericTargets.xml"), null);
58
		URL resource = FileLocator.find(Platform.getBundle("org.eclipse.pde.build"), new Path("/scripts/genericTargets.xml"), null);
58
		String buildXMLPath = FileLocator.toFileURL(resource).getPath();
59
		String buildXMLPath = FileLocator.toFileURL(resource).getPath();
59
		runAntScript(buildXMLPath, new String[] {"fetchElement"}, buildFolder.getLocation().toOSString(), fetchProperties);
60
		runAntScript(buildXMLPath, new String[] {"fetchElement"}, buildFolder.getLocation().toOSString(), fetchProperties);
60
		
61
61
		assertResourceFile(buildFolder.getFile("plugins/javax.xml.rpc_1.1.0.v200905122109/META-INF/MANIFEST.MF"));
62
		assertResourceFile(buildFolder.getFile("plugins/javax.xml.rpc_1.1.0.v200905122109/META-INF/MANIFEST.MF"));
62
		assertResourceFile(buildFolder.getFile("plugins/com.ibm.icu.base_3.6.0/META-INF/MANIFEST.MF"));
63
		assertResourceFile(buildFolder.getFile("plugins/com.ibm.icu.base_3.6.0/META-INF/MANIFEST.MF"));
63
		assertResourceFile(buildFolder.getFile("plugins/com.ibm.icu.base_3.6.1.v20080530/META-INF/MANIFEST.MF"));
64
		assertResourceFile(buildFolder.getFile("plugins/com.ibm.icu.base_3.6.1.v20080530/META-INF/MANIFEST.MF"));
64
	}
65
	}
65
	
66
66
	public void testFetchFeature() throws Exception {
67
	public void testFetchFeature() throws Exception {
67
		IFolder buildFolder = newTest("fetchFeature");
68
		IFolder buildFolder = newTest("fetchFeature");
68
		
69
69
		StringBuffer buffer = new StringBuffer();
70
		StringBuffer buffer = new StringBuffer();
70
		buffer.append("feature@org.eclipse.cvs=v20090619,:pserver:anonymous@dev.eclipse.org:/cvsroot/eclipse,,org.eclipse.cvs-feature\n");
71
		buffer.append("feature@org.eclipse.cvs=v20090619,:pserver:anonymous@dev.eclipse.org:/cvsroot/eclipse,,org.eclipse.cvs-feature\n");
71
		buffer.append("plugin@org.eclipse.cvs=v20090520,:pserver:anonymous@dev.eclipse.org:/cvsroot/eclipse,,org.eclipse.sdk-feature/plugins/org.eclipse.cvs\n");
72
		buffer.append("plugin@org.eclipse.cvs=v20090520,:pserver:anonymous@dev.eclipse.org:/cvsroot/eclipse,,org.eclipse.sdk-feature/plugins/org.eclipse.cvs\n");
Lines 73-89 Link Here
73
		buffer.append("plugin@org.eclipse.team.cvs.ssh2=I20090508-2000,:pserver:anonymous@dev.eclipse.org:/cvsroot/eclipse,\n");
74
		buffer.append("plugin@org.eclipse.team.cvs.ssh2=I20090508-2000,:pserver:anonymous@dev.eclipse.org:/cvsroot/eclipse,\n");
74
		buffer.append("plugin@org.eclipse.team.cvs.ui=I20090521-1750,:pserver:anonymous@dev.eclipse.org:/cvsroot/eclipse,\n");
75
		buffer.append("plugin@org.eclipse.team.cvs.ui=I20090521-1750,:pserver:anonymous@dev.eclipse.org:/cvsroot/eclipse,\n");
75
		Utils.writeBuffer(buildFolder.getFile("directory.txt"), buffer);
76
		Utils.writeBuffer(buildFolder.getFile("directory.txt"), buffer);
76
		
77
77
		Properties fetchProperties = new Properties();
78
		Properties fetchProperties = new Properties();
78
		fetchProperties.put("buildDirectory", buildFolder.getLocation().toOSString());
79
		fetchProperties.put("buildDirectory", buildFolder.getLocation().toOSString());
79
		fetchProperties.put("type", "feature");
80
		fetchProperties.put("type", "feature");
80
		fetchProperties.put("id", "org.eclipse.cvs");
81
		fetchProperties.put("id", "org.eclipse.cvs");
81
		
82
82
		URL resource = FileLocator.find(Platform.getBundle("org.eclipse.pde.build"), new Path("/scripts/genericTargets.xml"), null);
83
		URL resource = FileLocator.find(Platform.getBundle("org.eclipse.pde.build"), new Path("/scripts/genericTargets.xml"), null);
83
		String buildXMLPath = FileLocator.toFileURL(resource).getPath();
84
		String buildXMLPath = FileLocator.toFileURL(resource).getPath();
84
		runAntScript(buildXMLPath, new String[] {"fetchElement"}, buildFolder.getLocation().toOSString(), fetchProperties);
85
		runAntScript(buildXMLPath, new String[] {"fetchElement"}, buildFolder.getLocation().toOSString(), fetchProperties);
86
87
		IFile sourceRefsFile = buildFolder.getFile(IPDEBuildConstants.DEFAULT_SOURCE_REFERENCES_FILENAME_DESCRIPTOR);
88
		assertResourceFile(sourceRefsFile);
89
		Properties sourceRefs = Utils.loadProperties(sourceRefsFile);
90
		assertEquals(sourceRefs.get("org.eclipse.cvs,0.0.0"), "scm:cvs:pserver:dev.eclipse.org:/cvsroot/eclipse:org.eclipse.sdk-feature/plugins/org.eclipse.cvs;project=org.eclipse.cvs,tag=v20090520");
91
		assertEquals(sourceRefs.get("org.eclipse.team.cvs.core,0.0.0"), "scm:cvs:pserver:dev.eclipse.org:/cvsroot/eclipse:org.eclipse.team.cvs.core:project=org.eclipse.team.cvs.core;tag=I20090430-0408");
92
		assertEquals(sourceRefs.get("org.eclipse.team.cvs.ssh2,0.0.0"), "scm:cvs:pserver:dev.eclipse.org:/cvsroot/eclipse:org.eclipse.team.cvs.ssh2:project=org.eclipse.team.cvs.ssh2;tag=I20090508-2000");
85
	}
93
	}
86
	
94
87
	public void testBug248767_2() throws Exception {
95
	public void testBug248767_2() throws Exception {
88
		IFolder buildFolder = newTest("248767_2");
96
		IFolder buildFolder = newTest("248767_2");
89
		IFolder base = Utils.createFolder(buildFolder, "base");
97
		IFolder base = Utils.createFolder(buildFolder, "base");
Lines 136-142 Link Here
136
		assertResourceFile(buildFolder, "plugins/com.ibm.icu.base_3.6.1.v20080530.jar");
144
		assertResourceFile(buildFolder, "plugins/com.ibm.icu.base_3.6.1.v20080530.jar");
137
		assertResourceFile(buildFolder, "plugins/com.ibm.icu.base_3.6.0.v20080530.jar");
145
		assertResourceFile(buildFolder, "plugins/com.ibm.icu.base_3.6.0.v20080530.jar");
138
	}
146
	}
139
	
147
140
	public void testP2Get() throws Exception {
148
	public void testP2Get() throws Exception {
141
		IFolder buildFolder = newTest("p2.get");
149
		IFolder buildFolder = newTest("p2.get");
142
		Utils.createFolder(buildFolder, "plugins");
150
		Utils.createFolder(buildFolder, "plugins");
Lines 148-154 Link Here
148
		Map replacements = new HashMap();
156
		Map replacements = new HashMap();
149
		replacements.put("repoLocation", repoLocation.toExternalForm());
157
		replacements.put("repoLocation", repoLocation.toExternalForm());
150
		Utils.transferAndReplace(mapFile, buildFolder.getFile("directory.txt"), replacements);
158
		Utils.transferAndReplace(mapFile, buildFolder.getFile("directory.txt"), replacements);
151
		
159
152
		//org.eclipse.pde.build.container.feature is special in that the fetch won't try
160
		//org.eclipse.pde.build.container.feature is special in that the fetch won't try
153
		//to fetch it, and will just fetch everything it includes.
161
		//to fetch it, and will just fetch everything it includes.
154
		Properties fetchProperties = new Properties();
162
		Properties fetchProperties = new Properties();

Return to bug 243582