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 265524
Collapse All | Expand All

(-)src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/AbstractRepositoryTask.java (-2 / +13 lines)
Lines 12-17 Link Here
12
12
13
import java.io.File;
13
import java.io.File;
14
import java.net.URI;
14
import java.net.URI;
15
import java.net.URISyntaxException;
15
import java.util.*;
16
import java.util.*;
16
import org.apache.tools.ant.*;
17
import org.apache.tools.ant.*;
17
import org.apache.tools.ant.types.FileSet;
18
import org.apache.tools.ant.types.FileSet;
Lines 121-127 Link Here
121
					String[][] elements = new String[][] {scanner.getIncludedDirectories(), scanner.getIncludedFiles()};
122
					String[][] elements = new String[][] {scanner.getIncludedDirectories(), scanner.getIncludedFiles()};
122
					for (int i = 0; i < 2; i++) {
123
					for (int i = 0; i < 2; i++) {
123
						for (int j = 0; j < elements[i].length; j++) {
124
						for (int j = 0; j < elements[i].length; j++) {
124
							URI uri = new File(fileset.getDir(), elements[i][j]).toURI();
125
							File file = new File(fileset.getDir(), elements[i][j]);
126
							URI uri = file.toURI();
127
128
							if (file.isFile() && file.getName().endsWith(".zip")) { //$NON-NLS-1$
129
								try {
130
									uri = new URI("jar:" + uri.toString() + "!/"); //$NON-NLS-1$ //$NON-NLS-2$
131
								} catch (URISyntaxException e) {
132
									//?
133
									continue;
134
								}
135
							}
125
							application.addSourceArtifactRepository(uri);
136
							application.addSourceArtifactRepository(uri);
126
							application.addSourceMetadataRepository(uri);
137
							application.addSourceMetadataRepository(uri);
127
						}
138
						}
Lines 156-162 Link Here
156
			}
167
			}
157
168
158
			if (collector.isEmpty())
169
			if (collector.isEmpty())
159
				throw new BuildException("Unable to find: " + id + (version != null ? " " + version : ""));
170
				throw new BuildException("Unable to find: " + id + (version != null ? " " + version : "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
160
			result.add(collector.iterator().next());
171
			result.add(collector.iterator().next());
161
		}
172
		}
162
		return result;
173
		return result;
(-)src/org/eclipse/pde/build/internal/tests/p2/P2Tests.java (-21 / +41 lines)
Lines 1-16 Link Here
1
package org.eclipse.pde.build.internal.tests.p2;
1
package org.eclipse.pde.build.internal.tests.p2;
2
2
3
import java.io.File;
3
import java.io.*;
4
import java.io.FilenameFilter;
5
import java.net.URL;
4
import java.net.URL;
6
import java.util.ArrayList;
5
import java.util.*;
7
import java.util.Properties;
6
import java.util.zip.ZipOutputStream;
8
7
9
import junit.framework.AssertionFailedError;
8
import junit.framework.AssertionFailedError;
10
9
10
import org.apache.tools.ant.BuildException;
11
import org.eclipse.core.resources.IFile;
11
import org.eclipse.core.resources.IFile;
12
import org.eclipse.core.resources.IFolder;
12
import org.eclipse.core.resources.IFolder;
13
import org.eclipse.core.runtime.*;
13
import org.eclipse.core.runtime.*;
14
import org.eclipse.equinox.internal.p2.core.helpers.FileUtils;
15
import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
14
import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
16
import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
15
import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository;
17
import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository;
16
import org.eclipse.pde.build.internal.tests.Utils;
18
import org.eclipse.pde.build.internal.tests.Utils;
Lines 257-266 Link Here
257
259
258
	public void testBug258126() throws Exception {
260
	public void testBug258126() throws Exception {
259
		IFolder buildFolder = newTest("258126");
261
		IFolder buildFolder = newTest("258126");
260
		
262
261
		File delta = Utils.findDeltaPack();
263
		File delta = Utils.findDeltaPack();
262
		assertNotNull(delta);
264
		assertNotNull(delta);
263
		
265
264
		IFolder repo = Utils.createFolder(buildFolder, "repo");
266
		IFolder repo = Utils.createFolder(buildFolder, "repo");
265
267
266
		Utils.generateFeature(buildFolder, "F", null, new String[] {"org.eclipse.osgi;unpack=false", "org.eclipse.core.runtime;unpack=false"});
268
		Utils.generateFeature(buildFolder, "F", null, new String[] {"org.eclipse.osgi;unpack=false", "org.eclipse.core.runtime;unpack=false"});
Lines 276-285 Link Here
276
		String repoLocation = "file:" + repo.getLocation().toOSString();
278
		String repoLocation = "file:" + repo.getLocation().toOSString();
277
		Properties properties = BuildConfiguration.getBuilderProperties(buildFolder);
279
		Properties properties = BuildConfiguration.getBuilderProperties(buildFolder);
278
		properties.put("product", productFile.getLocation().toOSString());
280
		properties.put("product", productFile.getLocation().toOSString());
279
		properties.put("configs", "win32,win32,x86");		
281
		properties.put("configs", "win32,win32,x86");
280
		if (!delta.equals(new File((String) properties.get("baseLocation"))))
282
		if (!delta.equals(new File((String) properties.get("baseLocation"))))
281
			properties.put("pluginPath", delta.getAbsolutePath());
283
			properties.put("pluginPath", delta.getAbsolutePath());
282
		
284
283
		properties.put("archivesFormat", "win32,win32,x86-folder");
285
		properties.put("archivesFormat", "win32,win32,x86-folder");
284
		properties.put("generate.p2.metadata", "true");
286
		properties.put("generate.p2.metadata", "true");
285
		properties.put("p2.metadata.repo", repoLocation);
287
		properties.put("p2.metadata.repo", repoLocation);
Lines 301-318 Link Here
301
			assertEquals(e.getMessage(), "Action not found:addProgramArg(programArg:-vmargs);");
303
			assertEquals(e.getMessage(), "Action not found:addProgramArg(programArg:-vmargs);");
302
		}
304
		}
303
	}
305
	}
304
	
306
305
	public void testBug262421() throws Exception {
307
	public void testBug262421() throws Exception {
306
		IFolder buildFolder = newTest("262421");
308
		IFolder buildFolder = newTest("262421");
307
		
309
308
		IFile productFile = buildFolder.getFile("rcp.product");
310
		IFile productFile = buildFolder.getFile("rcp.product");
309
		Utils.generateProduct(productFile, "rcp.product", "1.0.0", new String [] {"org.eclipse.osgi"}, false);
311
		Utils.generateProduct(productFile, "rcp.product", "1.0.0", new String[] {"org.eclipse.osgi"}, false);
310
		
312
311
		IFile p2Inf = buildFolder.getFile("p2.inf");
313
		IFile p2Inf = buildFolder.getFile("p2.inf");
312
		StringBuffer buffer = new StringBuffer();
314
		StringBuffer buffer = new StringBuffer();
313
		buffer.append("instructions.configure=addRepository(type:0,location:http${#58}//download.eclipse.org/eclipse/updates/3.4);");
315
		buffer.append("instructions.configure=addRepository(type:0,location:http${#58}//download.eclipse.org/eclipse/updates/3.4);");
314
		Utils.writeBuffer(p2Inf, buffer);
316
		Utils.writeBuffer(p2Inf, buffer);
315
		
317
316
		IFolder repo = Utils.createFolder(buildFolder, "repo");
318
		IFolder repo = Utils.createFolder(buildFolder, "repo");
317
		String repoLocation = "file:" + repo.getLocation().toOSString();
319
		String repoLocation = "file:" + repo.getLocation().toOSString();
318
		Properties properties = BuildConfiguration.getBuilderProperties(buildFolder);
320
		Properties properties = BuildConfiguration.getBuilderProperties(buildFolder);
Lines 326-348 Link Here
326
		Utils.storeBuildProperties(buildFolder, properties);
328
		Utils.storeBuildProperties(buildFolder, properties);
327
329
328
		runProductBuild(buildFolder);
330
		runProductBuild(buildFolder);
329
		
331
330
		IMetadataRepository repository = loadMetadataRepository(repoLocation);
332
		IMetadataRepository repository = loadMetadataRepository(repoLocation);
331
		IInstallableUnit iu = getIU(repository, "rcp.product");
333
		IInstallableUnit iu = getIU(repository, "rcp.product");
332
		assertTouchpoint(iu, "configure", "addRepository");
334
		assertTouchpoint(iu, "configure", "addRepository");
333
	}
335
	}
334
	
336
335
	public void testBug265526() throws Exception {
337
	public void testBug265526_265524() throws Exception {
336
		IFolder buildFolder= newTest("265526");
338
		IFolder buildFolder = newTest("265526");
337
		IFolder a = Utils.createFolder(buildFolder, "plugins/a");
339
		IFolder a = Utils.createFolder(buildFolder, "plugins/a");
338
		IFolder b = Utils.createFolder(buildFolder, "plugins/b");
340
		IFolder b = Utils.createFolder(buildFolder, "plugins/b");
339
		
341
340
		Utils.generateFeature(buildFolder, "F", null, new String[] {"a;unpack=false", "b;unpack=true"});
342
		Utils.generateFeature(buildFolder, "F", null, new String[] {"a;unpack=false", "b;unpack=true"});
341
		Utils.generateBundle(a, "a");
343
		Utils.generateBundle(a, "a");
342
		Utils.writeBuffer(a.getFile("src/a.java"), new StringBuffer("class A {}"));
344
		Utils.writeBuffer(a.getFile("src/a.java"), new StringBuffer("class A {}"));
343
		Utils.generateBundle(b, "b");
345
		Utils.generateBundle(b, "b");
344
		Utils.writeBuffer(b.getFile("src/b.java"), new StringBuffer("class B {}"));
346
		Utils.writeBuffer(b.getFile("src/b.java"), new StringBuffer("class B {}"));
345
		
347
346
		IFolder repo = Utils.createFolder(buildFolder, "repo/r1");
348
		IFolder repo = Utils.createFolder(buildFolder, "repo/r1");
347
		String repoLocation = "file:" + repo.getLocation().toOSString();
349
		String repoLocation = "file:" + repo.getLocation().toOSString();
348
		Properties properties = BuildConfiguration.getBuilderProperties(buildFolder);
350
		Properties properties = BuildConfiguration.getBuilderProperties(buildFolder);
Lines 355-370 Link Here
355
		Utils.storeBuildProperties(buildFolder, properties);
357
		Utils.storeBuildProperties(buildFolder, properties);
356
358
357
		runBuild(buildFolder);
359
		runBuild(buildFolder);
358
		
360
359
		properties.put("repoBaseLocation", buildFolder.getFolder("repo").getLocation().toOSString());
361
		properties.put("repoBaseLocation", buildFolder.getFolder("repo").getLocation().toOSString());
360
		properties.put("transformedRepoLocation", buildFolder.getFolder("outRepo").getLocation().toOSString());
362
		properties.put("transformedRepoLocation", buildFolder.getFolder("outRepo").getLocation().toOSString());
361
		URL resource = FileLocator.find(Platform.getBundle("org.eclipse.pde.build"), new Path("/scripts/genericTargets.xml"), null);
363
		URL resource = FileLocator.find(Platform.getBundle("org.eclipse.pde.build"), new Path("/scripts/genericTargets.xml"), null);
362
		String buildXMLPath = FileLocator.toFileURL(resource).getPath();
364
		String buildXMLPath = FileLocator.toFileURL(resource).getPath();
363
		runAntScript(buildXMLPath, new String[] {"transformRepos"}, buildFolder.getLocation().toOSString(), properties);
365
		runAntScript(buildXMLPath, new String[] {"transformRepos"}, buildFolder.getLocation().toOSString(), properties);
364
		
366
365
		assertResourceFile(buildFolder, "outRepo/plugins/b_1.0.0/B.class");
367
		assertResourceFile(buildFolder, "outRepo/plugins/b_1.0.0/B.class");
366
		assertResourceFile(buildFolder, "outRepo/plugins/a_1.0.0.jar");
368
		assertResourceFile(buildFolder, "outRepo/plugins/a_1.0.0.jar");
367
		assertResourceFile(buildFolder, "outRepo/artifacts.xml");
369
		assertResourceFile(buildFolder, "outRepo/artifacts.xml");
368
		assertResourceFile(buildFolder, "outRepo/content.xml");
370
		assertResourceFile(buildFolder, "outRepo/content.xml");
371
372
		//part 2, zipped repos
373
		IFolder zipped = Utils.createFolder(buildFolder, "zipped");
374
		ZipOutputStream output = new ZipOutputStream(new FileOutputStream(new File(zipped.getLocation().toFile(), "zipped repo.zip")));
375
		File root = buildFolder.getFolder("repo/r1").getLocation().toFile();
376
		FileUtils.zip(output, root, Collections.EMPTY_SET, FileUtils.createRootPathComputer(root));
377
		org.eclipse.pde.internal.build.Utils.close(output);
378
		
379
		IFolder outRepo2 = Utils.createFolder(buildFolder, "outRepo2");
380
		properties.put("repoBaseLocation", zipped.getLocation().toOSString());
381
		properties.put("transformedRepoLocation", outRepo2.getLocation().toOSString());
382
		runAntScript(buildXMLPath, new String[] {"transformRepos"}, buildFolder.getLocation().toOSString(), properties);
383
		
384
		assertResourceFile(outRepo2, "plugins/b_1.0.0/B.class");
385
		assertResourceFile(outRepo2, "plugins/a_1.0.0.jar");
386
		assertResourceFile(outRepo2, "artifacts.xml");
387
		assertResourceFile(outRepo2, "content.xml");
369
	}
388
	}
389
370
}
390
}

Return to bug 265524