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

Collapse All | Expand All

(-)src/org/eclipse/pde/internal/build/BuildScriptGenerator.java (-3 / +3 lines)
Lines 89-95 Link Here
89
	// the default id is a generic feature name as uber source features have no inherent 
89
	// the default id is a generic feature name as uber source features have no inherent 
90
	// semantics or scope.
90
	// semantics or scope.
91
	private String sourceBundleTemplateFeature = "org.eclipse.pde.build.uber.feature"; //$NON-NLS-1$
91
	private String sourceBundleTemplateFeature = "org.eclipse.pde.build.uber.feature"; //$NON-NLS-1$
92
	private String sourceBundleFeatureId = null;  //default is sourceBundleTemplateFeature + ".source"
92
	private String sourceBundleFeatureId = null; //default is sourceBundleTemplateFeature + ".source"
93
93
94
	// the default version is simply time-based as uber source features have no inherent 
94
	// the default version is simply time-based as uber source features have no inherent 
95
	// semantics or scope.
95
	// semantics or scope.
Lines 164-170 Link Here
164
				String[] modelInfo = getNameAndVersion((String) iterator.next());
164
				String[] modelInfo = getNameAndVersion((String) iterator.next());
165
				generator.setBuildSiteFactory(siteFactory);
165
				generator.setBuildSiteFactory(siteFactory);
166
				generator.setModelId(modelInfo[0], modelInfo[1]);
166
				generator.setModelId(modelInfo[0], modelInfo[1]);
167
167
				generator.setFeatureGenerator(new BuildDirector());
168
				generator.setPluginPath(pluginPath);
168
				generator.setPluginPath(pluginPath);
169
				generator.setDevEntries(devEntries);
169
				generator.setDevEntries(devEntries);
170
				generator.setCompiledElements(generator.getCompiledElements());
170
				generator.setCompiledElements(generator.getCompiledElements());
Lines 181-187 Link Here
181
					//Filtering is not required here, since we are only generating the build for a plugin or a fragment
181
					//Filtering is not required here, since we are only generating the build for a plugin or a fragment
182
					generator.setBuildSiteFactory(siteFactory);
182
					generator.setBuildSiteFactory(siteFactory);
183
					generator.setModel(bundlesToBuild[i]);
183
					generator.setModel(bundlesToBuild[i]);
184
184
					generator.setFeatureGenerator(new BuildDirector());
185
					generator.setPluginPath(pluginPath);
185
					generator.setPluginPath(pluginPath);
186
					generator.setDevEntries(devEntries);
186
					generator.setDevEntries(devEntries);
187
					generator.setCompiledElements(generator.getCompiledElements());
187
					generator.setCompiledElements(generator.getCompiledElements());
(-)src/org/eclipse/pde/internal/build/IXMLConstants.java (+1 lines)
Lines 50-55 Link Here
50
	public static final String TARGET_ASSEMBLE_ARCHIVE_CONDITION = "assemble.archive.condition"; //$NON-NLS-1$
50
	public static final String TARGET_ASSEMBLE_ARCHIVE_CONDITION = "assemble.archive.condition"; //$NON-NLS-1$
51
	public static final String TARGET_CLEANUP_ASSEMBLY = "cleanup.assembly"; //$NON-NLS-1$
51
	public static final String TARGET_CLEANUP_ASSEMBLY = "cleanup.assembly"; //$NON-NLS-1$
52
	public static final String TARGET_COPY_SRC_INCLUDES = "copy.src.includes"; //$NON-NLS-1$
52
	public static final String TARGET_COPY_SRC_INCLUDES = "copy.src.includes"; //$NON-NLS-1$
53
	public static final String TARGET_NESTED_JARS = ".nestedJars"; //$NON-NLS-1$
53
	public static final String TARGET_INIT = "init"; //$NON-NLS-1$
54
	public static final String TARGET_INIT = "init"; //$NON-NLS-1$
54
	public static final String TARGET_MAIN = "main"; //$NON-NLS-1$
55
	public static final String TARGET_MAIN = "main"; //$NON-NLS-1$
55
	public static final String TARGET_GZIP_RESULTS = "gzipResults"; //$NON-NLS-1$
56
	public static final String TARGET_GZIP_RESULTS = "gzipResults"; //$NON-NLS-1$
(-)src/org/eclipse/pde/internal/build/ant/AntScript.java (+22 lines)
Lines 378-383 Link Here
378
		}
378
		}
379
	}
379
	}
380
380
381
	public void printUnzipTask(String zipFile, String destDir, boolean overWrite, String includePatterns, String excludePatterns) {
382
		printTab();
383
		output.print("<unzip"); //$NON-NLS-1$
384
		printAttribute("src", zipFile, true); //$NON-NLS-1$
385
		printAttribute("dest", destDir, true); //$NON-NLS-1$
386
		printAttribute("overwrite", Boolean.toString(overWrite), true); //$NON-NLS-1$
387
		if (includePatterns == null && excludePatterns == null) {
388
			output.println("/>"); //$NON-NLS-1$
389
		} else {
390
			output.println(">"); //$NON-NLS-1$
391
			indent++;
392
			printTab();
393
			output.print("<patternset"); //$NON-NLS-1$
394
			printAttribute("includes", includePatterns, false); //$NON-NLS-1$
395
			printAttribute("excludes", excludePatterns, false); //$NON-NLS-1$
396
			output.println("/>"); //$NON-NLS-1$
397
			indent--;
398
			printTab();
399
			output.println("</unzip>"); //$NON-NLS-1$
400
		}
401
	}
402
381
	public void printTarTask(String zipfile, String basedir, boolean filesOnly, boolean update, FileSet[] fileSets) {
403
	public void printTarTask(String zipfile, String basedir, boolean filesOnly, boolean update, FileSet[] fileSets) {
382
		printTab();
404
		printTab();
383
		output.print("<tar"); //$NON-NLS-1$
405
		output.print("<tar"); //$NON-NLS-1$
(-)src/org/eclipse/pde/internal/build/builder/BuildDirector.java (+26 lines)
Lines 10-20 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.build.builder;
11
package org.eclipse.pde.internal.build.builder;
12
12
13
import java.io.File;
13
import java.util.*;
14
import java.util.*;
14
import org.eclipse.core.runtime.*;
15
import org.eclipse.core.runtime.*;
15
import org.eclipse.osgi.service.resolver.BundleDescription;
16
import org.eclipse.osgi.service.resolver.BundleDescription;
16
import org.eclipse.osgi.util.NLS;
17
import org.eclipse.osgi.util.NLS;
17
import org.eclipse.pde.internal.build.*;
18
import org.eclipse.pde.internal.build.*;
19
import org.eclipse.pde.internal.build.builder.ClasspathComputer3_0.ClasspathElement;
18
import org.eclipse.pde.internal.build.site.BuildTimeFeature;
20
import org.eclipse.pde.internal.build.site.BuildTimeFeature;
19
import org.eclipse.pde.internal.build.site.compatibility.Feature;
21
import org.eclipse.pde.internal.build.site.compatibility.Feature;
20
import org.eclipse.pde.internal.build.site.compatibility.FeatureEntry;
22
import org.eclipse.pde.internal.build.site.compatibility.FeatureEntry;
Lines 78-83 Link Here
78
		this.assemblyData = assemblageInformation;
80
		this.assemblyData = assemblageInformation;
79
	}
81
	}
80
82
83
	private final Map extractedLocations = new HashMap();
84
85
	public String getExtractedRoot(ClasspathElement element) {
86
		if (element.getSubPath() == null)
87
			return element.getPath();
88
89
		String absolute = element.getAbsolutePath();
90
		if (extractedLocations.containsKey(absolute)) {
91
			return (String) extractedLocations.get(absolute);
92
		}
93
94
		//Use the jar name, append a suffix if that name is already taken
95
		String name = new File(absolute).getName();
96
		if (name.endsWith(".jar")) //$NON-NLS-1$
97
			name = name.substring(0, name.length() - 4);
98
		String destination = name;
99
		while (extractedLocations.containsValue(destination)) {
100
			destination = name + '_' + Integer.toHexString(destination.hashCode());
101
		}
102
103
		extractedLocations.put(absolute, destination);
104
		return destination;
105
	}
106
81
	/**
107
	/**
82
	 * Returns a list of BundleDescription objects representing the elements delivered by the feature. 
108
	 * Returns a list of BundleDescription objects representing the elements delivered by the feature. 
83
	 *  
109
	 *  
(-)src/org/eclipse/pde/internal/build/builder/ClasspathComputer3_0.java (-38 / +67 lines)
Lines 25-32 Link Here
25
import org.osgi.framework.Filter;
25
import org.osgi.framework.Filter;
26
26
27
public class ClasspathComputer3_0 implements IClasspathComputer, IPDEBuildConstants, IXMLConstants, IBuildPropertiesConstants {
27
public class ClasspathComputer3_0 implements IClasspathComputer, IPDEBuildConstants, IXMLConstants, IBuildPropertiesConstants {
28
	public static class ClasspathElement {
28
	public class ClasspathElement {
29
		private final String path;
29
		private final String path;
30
		private final String subPath;
30
		private String accessRules;
31
		private String accessRules;
31
32
32
		/**
33
		/**
Lines 35-42 Link Here
35
		 * @param accessRules
36
		 * @param accessRules
36
		 * @throws NullPointerException if path is null
37
		 * @throws NullPointerException if path is null
37
		 */
38
		 */
38
		public ClasspathElement(String path, String accessRules) {
39
		protected ClasspathElement(String path, String subPath, String accessRules) {
40
			if (path == null)
41
				throw new NullPointerException();
39
			this.path = path;
42
			this.path = path;
43
			this.subPath = subPath;
40
			this.accessRules = accessRules;
44
			this.accessRules = accessRules;
41
		}
45
		}
42
46
Lines 48-57 Link Here
48
			return path;
52
			return path;
49
		}
53
		}
50
54
55
		public String getSubPath() {
56
			return subPath;
57
		}
58
51
		public String getAccessRules() {
59
		public String getAccessRules() {
52
			return accessRules;
60
			return accessRules;
53
		}
61
		}
54
62
63
		public String getAbsolutePath() {
64
			if (new File(path).isAbsolute())
65
				return path;
66
67
			return modelLocation + '/' + path;
68
		}
69
55
		public void addRules(String newRule) {
70
		public void addRules(String newRule) {
56
			if (accessRules.equals("") || accessRules.equals(newRule)) //$NON-NLS-1$
71
			if (accessRules.equals("") || accessRules.equals(newRule)) //$NON-NLS-1$
57
				return;
72
				return;
Lines 70-88 Link Here
70
		public boolean equals(Object obj) {
85
		public boolean equals(Object obj) {
71
			if (obj instanceof ClasspathElement) {
86
			if (obj instanceof ClasspathElement) {
72
				ClasspathElement element = (ClasspathElement) obj;
87
				ClasspathElement element = (ClasspathElement) obj;
73
				return (path != null && path.equals(element.getPath()));
88
				if (!path.equals(element.getPath()))
89
					return false;
90
				if (subPath != null && subPath.equals(element.getSubPath()))
91
					return false;
92
				return true;
74
			}
93
			}
75
			return false;
94
			return false;
76
		}
95
		}
77
96
78
		public int hashCode() {
97
		public int hashCode() {
79
			return path.hashCode();
98
			int result = path.hashCode();
99
			return 13 * result + ((subPath == null) ? 0 : subPath.hashCode());
80
		}
100
		}
81
101
82
		public static String normalize(String path) {
102
	}
83
			//always use '/' as a path separator to help with comparing paths in equals
103
	private static String normalize(String path) {
84
			return path.replaceAll("\\\\", "/"); //$NON-NLS-1$ //$NON-NLS-2$
104
		if (path == null)
85
		}
105
			return null;
106
		//always use '/' as a path separator to help with comparing paths in equals
107
		return path.replaceAll("\\\\", "/"); //$NON-NLS-1$ //$NON-NLS-2$
86
	}
108
	}
87
109
88
	private static final String EXCLUDE_ALL_RULE = "?**/*"; //$NON-NLS-1$
110
	private static final String EXCLUDE_ALL_RULE = "?**/*"; //$NON-NLS-1$
Lines 92-97 Link Here
92
	private Map pathElements = null;
114
	private Map pathElements = null;
93
	private boolean allowBinaryCycles = false;
115
	private boolean allowBinaryCycles = false;
94
	private Set requiredIds = null;
116
	private Set requiredIds = null;
117
	protected String modelLocation = null;
95
118
96
	public ClasspathComputer3_0(ModelBuildScriptGenerator modelGenerator) {
119
	public ClasspathComputer3_0(ModelBuildScriptGenerator modelGenerator) {
97
		this.generator = modelGenerator;
120
		this.generator = modelGenerator;
Lines 109-115 Link Here
109
	public List getClasspath(BundleDescription model, ModelBuildScriptGenerator.CompiledEntry jar) throws CoreException {
132
	public List getClasspath(BundleDescription model, ModelBuildScriptGenerator.CompiledEntry jar) throws CoreException {
110
		List classpath = new ArrayList(20);
133
		List classpath = new ArrayList(20);
111
		List pluginChain = new ArrayList(10); //The list of plugins added to detect cycle
134
		List pluginChain = new ArrayList(10); //The list of plugins added to detect cycle
112
		String location = generator.getLocation(model);
135
		modelLocation = generator.getLocation(model);
113
		Set addedPlugins = new HashSet(10); //The set of all the plugins already added to the classpath (this allows for optimization)
136
		Set addedPlugins = new HashSet(10); //The set of all the plugins already added to the classpath (this allows for optimization)
114
		pathElements = new HashMap();
137
		pathElements = new HashMap();
115
		visiblePackages = getVisiblePackages(model);
138
		visiblePackages = getVisiblePackages(model);
Lines 117-126 Link Here
117
		allowBinaryCycles = AbstractScriptGenerator.getPropertyAsBoolean(IBuildPropertiesConstants.PROPERTY_ALLOW_BINARY_CYCLES);
140
		allowBinaryCycles = AbstractScriptGenerator.getPropertyAsBoolean(IBuildPropertiesConstants.PROPERTY_ALLOW_BINARY_CYCLES);
118
141
119
		//PREREQUISITE
142
		//PREREQUISITE
120
		addPrerequisites(model, classpath, location, pluginChain, addedPlugins);
143
		addPrerequisites(model, classpath, modelLocation, pluginChain, addedPlugins);
121
144
122
		//SELF
145
		//SELF
123
		addSelf(model, jar, classpath, location, pluginChain, addedPlugins);
146
		addSelf(model, jar, classpath, modelLocation, pluginChain, addedPlugins);
124
147
125
		recordRequiredIds(model);
148
		recordRequiredIds(model);
126
149
Lines 327-340 Link Here
327
		}
350
		}
328
351
329
		String path = null;
352
		String path = null;
330
		if ("jar".equalsIgnoreCase(basePath.getFileExtension())) { //$NON-NLS-1$
353
		String subPath = null;
354
		Path libraryPath = new Path(libraryName);
355
		if (libraryPath.isAbsolute()) {
356
			path = libraryPath.toOSString();
357
		} else if ("jar".equalsIgnoreCase(basePath.getFileExtension())) { //$NON-NLS-1$
358
			if ("jar".equalsIgnoreCase(libraryPath.getFileExtension())) //$NON-NLS-1$
359
				subPath = libraryPath.toOSString();
331
			path = basePath.toOSString();
360
			path = basePath.toOSString();
332
		} else {
361
		} else {
333
			Path libraryPath = new Path(libraryName);
362
			path = basePath.append(libraryPath).toOSString();
334
			if (libraryPath.isAbsolute())
335
				path = libraryPath.toOSString();
336
			else
337
				path = basePath.append(libraryPath).toOSString();
338
		}
363
		}
339
		path = ModelBuildScriptGenerator.replaceVariables(path, pluginKey == null ? false : generator.getCompiledElements().contains(pluginKey));
364
		path = ModelBuildScriptGenerator.replaceVariables(path, pluginKey == null ? false : generator.getCompiledElements().contains(pluginKey));
340
		String secondaryPath = null;
365
		String secondaryPath = null;
Lines 345-365 Link Here
345
370
346
		}
371
		}
347
372
348
		addClasspathElementWithRule(classpath, path, rules);
373
		addClasspathElementWithRule(classpath, path, subPath, rules);
349
		if (secondaryPath != null) {
374
		if (secondaryPath != null) {
350
			addClasspathElementWithRule(classpath, secondaryPath, rules);
375
			addClasspathElementWithRule(classpath, secondaryPath, null, rules);
351
		}
376
		}
352
	}
377
	}
353
378
354
	private void addClasspathElementWithRule(List classpath, String path, String rules) {
379
	private void addClasspathElementWithRule(List classpath, String path, String subPath, String rules) {
355
		String normalizedPath = ClasspathElement.normalize(path);
380
		path = normalize(path);
356
		ClasspathElement existing = (ClasspathElement) pathElements.get(normalizedPath);
381
		subPath = normalize(subPath);
382
		
383
		String elementsKey = subPath != null ? path + '/' + subPath : path;
384
		ClasspathElement existing = (ClasspathElement) pathElements.get(elementsKey);
357
		if (existing != null) {
385
		if (existing != null) {
358
			existing.addRules(rules);
386
			existing.addRules(rules);
359
		} else {
387
		} else {
360
			ClasspathElement element = new ClasspathElement(normalizedPath, rules);
388
			ClasspathElement element = new ClasspathElement(path, subPath, rules);
361
			classpath.add(element);
389
			classpath.add(element);
362
			pathElements.put(normalizedPath, element);
390
			pathElements.put(elementsKey, element);
363
		}
391
		}
364
	}
392
	}
365
393
Lines 424-432 Link Here
424
			for (int i = 0; i < extra.length; i++) {
452
			for (int i = 0; i < extra.length; i++) {
425
				//Potential pb: if the path refers to something that is being compiled (which is supposetly not the case, but who knows...)
453
				//Potential pb: if the path refers to something that is being compiled (which is supposetly not the case, but who knows...)
426
				//the user will get $basexx instead of $ws 
454
				//the user will get $basexx instead of $ws 
427
				String toAdd = computeExtraPath(extra[i], classpath, location);
455
				String[] toAdd = computeExtraPath(extra[i], classpath, location);
428
				if (toAdd != null)
456
				if (toAdd != null && toAdd.length == 2)
429
					addPathAndCheck(null, new Path(toAdd), "", modelProperties, classpath); //$NON-NLS-1$
457
					addPathAndCheck(null, new Path(toAdd[0]), toAdd[1], modelProperties, classpath);
430
			}
458
			}
431
		}
459
		}
432
460
Lines 435-443 Link Here
435
		for (int i = 0; i < jarSpecificExtraClasspath.length; i++) {
463
		for (int i = 0; i < jarSpecificExtraClasspath.length; i++) {
436
			//Potential pb: if the path refers to something that is being compiled (which is supposetly not the case, but who knows...)
464
			//Potential pb: if the path refers to something that is being compiled (which is supposetly not the case, but who knows...)
437
			//the user will get $basexx instead of $ws 
465
			//the user will get $basexx instead of $ws 
438
			String toAdd = computeExtraPath(jarSpecificExtraClasspath[i], classpath, location);
466
			String[] toAdd = computeExtraPath(jarSpecificExtraClasspath[i], classpath, location);
439
			if (toAdd != null)
467
			if (toAdd != null && toAdd.length == 2)
440
				addPathAndCheck(null, new Path(toAdd), "", modelProperties, classpath); //$NON-NLS-1$
468
				addPathAndCheck(null, new Path(toAdd[0]), toAdd[1], modelProperties, classpath);
441
		}
469
		}
442
	}
470
	}
443
471
Lines 448-461 Link Here
448
	 * @return String the relative path 
476
	 * @return String the relative path 
449
	 * @throws CoreException
477
	 * @throws CoreException
450
	 */
478
	 */
451
	private String computeExtraPath(String url, List classpath, String location) throws CoreException {
479
	private String[] computeExtraPath(String url, List classpath, String location) throws CoreException {
452
		String relativePath = null;
480
		String relativePath = null;
453
481
454
		String[] urlfragments = Utils.getArrayFromString(url, "/"); //$NON-NLS-1$
482
		String[] urlfragments = Utils.getArrayFromString(url, "/"); //$NON-NLS-1$
455
483
456
		// A valid platform url for a plugin has a leat 3 segments.
484
		// A valid platform url for a plugin has a leat 3 segments.
457
		if (urlfragments.length > 2 && urlfragments[0].equals(PlatformURLHandler.PROTOCOL + PlatformURLHandler.PROTOCOL_SEPARATOR)) {
485
		if (urlfragments.length > 2 && urlfragments[0].equals(PlatformURLHandler.PROTOCOL + PlatformURLHandler.PROTOCOL_SEPARATOR)) {
458
			String modelLocation = null;
486
			String bundleLocation = null;
459
			BundleDescription bundle = null;
487
			BundleDescription bundle = null;
460
			if (urlfragments[1].equalsIgnoreCase(PLUGIN) || urlfragments[1].equalsIgnoreCase(FRAGMENT)) {
488
			if (urlfragments[1].equalsIgnoreCase(PLUGIN) || urlfragments[1].equalsIgnoreCase(FRAGMENT)) {
461
				bundle = generator.getSite(false).getRegistry().getResolvedBundle(urlfragments[2]);
489
				bundle = generator.getSite(false).getRegistry().getResolvedBundle(urlfragments[2]);
Lines 472-483 Link Here
472
					return null;
500
					return null;
473
				}
501
				}
474
502
475
				modelLocation = generator.getLocation(bundle);
503
				bundleLocation = generator.getLocation(bundle);
476
				if (modelLocation != null) {
504
				if (bundleLocation != null) {
477
					for (int i = 3; i < urlfragments.length; i++) {
505
					String entry = urlfragments[3];
478
						modelLocation += '/' + urlfragments[i];
506
					for (int i = 4; i < urlfragments.length; i++) {
507
						entry += '/' + urlfragments[i];
479
					}
508
					}
480
					return Utils.makeRelative(new Path(modelLocation), new Path(location)).toOSString();
509
					return new String[] {Utils.makeRelative(new Path(bundleLocation), new Path(location)).toOSString(), entry};
481
				}
510
				}
482
			} else if (urlfragments[1].equalsIgnoreCase("resource")) { //$NON-NLS-1$
511
			} else if (urlfragments[1].equalsIgnoreCase("resource")) { //$NON-NLS-1$
483
				String message = NLS.bind(Messages.exception_url, generator.getModel().getSymbolicName() + '/' + generator.getPropertiesFileName() + ": " + url); //$NON-NLS-1$
512
				String message = NLS.bind(Messages.exception_url, generator.getModel().getSymbolicName() + '/' + generator.getPropertiesFileName() + ": " + url); //$NON-NLS-1$
Lines 500-506 Link Here
500
			//		String message = Policy.bind("exception.url", PROPERTIES_FILE + "::"+url); //$NON-NLS-1$  //$NON-NLS-2$
529
			//		String message = Policy.bind("exception.url", PROPERTIES_FILE + "::"+url); //$NON-NLS-1$  //$NON-NLS-2$
501
			//		throw new CoreException(new Status(IStatus.ERROR,PI_PDEBUILD, IPDEBuildConstants.EXCEPTION_MALFORMED_URL, message,e));
530
			//		throw new CoreException(new Status(IStatus.ERROR,PI_PDEBUILD, IPDEBuildConstants.EXCEPTION_MALFORMED_URL, message,e));
502
		}
531
		}
503
		return relativePath;
532
		return new String[] {relativePath, ""}; //$NON-NLS-1$
504
	}
533
	}
505
534
506
	//Add the prerequisite of a given plugin (target)
535
	//Add the prerequisite of a given plugin (target)
(-)src/org/eclipse/pde/internal/build/builder/ModelBuildScriptGenerator.java (-4 / +47 lines)
Lines 1433-1440 Link Here
1433
					if (classpath.size() > 0 && classpath.get(0) instanceof ClasspathElement) {
1433
					if (classpath.size() > 0 && classpath.get(0) instanceof ClasspathElement) {
1434
						for (Iterator iterator = classpath.iterator(); iterator.hasNext();) {
1434
						for (Iterator iterator = classpath.iterator(); iterator.hasNext();) {
1435
							ClasspathElement element = (ClasspathElement) iterator.next();
1435
							ClasspathElement element = (ClasspathElement) iterator.next();
1436
							if (element.getPath() != null && element.getPath().length() > 0 && element.getAccessRules().length() > 0) {
1436
							if (element.getPath() != null && element.getAccessRules().length() > 0) {
1437
								String path = element.getPath();
1437
								String path = null;
1438
								if (element.getSubPath() == null)
1439
									path = element.getPath();
1440
								else
1441
									path = featureGenerator.getExtractedRoot(element) + '/' + element.getSubPath();
1442
1438
								if (path.startsWith(Utils.getPropertyFormat(PROPERTY_BUILD_RESULT_FOLDER))) {
1443
								if (path.startsWith(Utils.getPropertyFormat(PROPERTY_BUILD_RESULT_FOLDER))) {
1439
									//remove leading ${build.result.folder}/
1444
									//remove leading ${build.result.folder}/
1440
									path = path.substring(Utils.getPropertyFormat(PROPERTY_BUILD_RESULT_FOLDER).length() + 1);
1445
									path = path.substring(Utils.getPropertyFormat(PROPERTY_BUILD_RESULT_FOLDER).length() + 1);
Lines 1460-1465 Link Here
1460
	}
1465
	}
1461
1466
1462
	/**
1467
	/**
1468
	 * Add a target to extract any nested jars we need to compile against
1469
	 * @param classpath
1470
	 * @param entry
1471
	 * @return a new classpath list containing the extracted locations
1472
	 */
1473
	private List generateExtractNestedJars(List classpath, CompiledEntry entry) {
1474
		script.printTargetDeclaration(entry.getName(false) + TARGET_NESTED_JARS, null, null, null, null);
1475
1476
		if (classpath == null || classpath.size() == 0 || !(classpath.get(0) instanceof ClasspathElement)) {
1477
			script.printTargetEnd();
1478
			return classpath;
1479
		}
1480
1481
		List extracted = new ArrayList(classpath.size());
1482
		for (Iterator iterator = classpath.iterator(); iterator.hasNext();) {
1483
			ClasspathElement element = (ClasspathElement) iterator.next();
1484
1485
			if (element.getSubPath() == null)
1486
				extracted.add(element);
1487
			else {
1488
				String destPath = featureGenerator.getExtractedRoot(element);
1489
				String destDir = Utils.getPropertyFormat(PROPERTY_BUILD_DIRECTORY) + '/' + "nestedJars" + '/' + destPath.toString(); //$NON-NLS-1$
1490
				script.printMkdirTask(destDir);
1491
				script.printUnzipTask(element.getPath(), destDir, false, element.getSubPath(), null);
1492
				extracted.add(destDir + '/' + element.getSubPath());
1493
			}
1494
		}
1495
		script.printTargetEnd();
1496
1497
		return extracted;
1498
	}
1499
1500
	/**
1463
	 * Add the "jar" target to the given Ant script using the given classpath and
1501
	 * Add the "jar" target to the given Ant script using the given classpath and
1464
	 * jar as parameters.
1502
	 * jar as parameters.
1465
	 * 
1503
	 * 
Lines 1469-1479 Link Here
1469
	private void generateCompilationTarget(List classpath, CompiledEntry entry) {
1507
	private void generateCompilationTarget(List classpath, CompiledEntry entry) {
1470
		script.println();
1508
		script.println();
1471
		String name = entry.getName(false);
1509
		String name = entry.getName(false);
1472
		script.printTargetDeclaration(name, TARGET_INIT, null, entry.getName(true), NLS.bind(Messages.build_plugin_jar, model.getSymbolicName() + ' ' + name));
1510
1511
		//extract nested jars and update the classpath with the new locations
1512
		List extractedPath = generateExtractNestedJars(classpath, entry);
1513
1514
		String depends = TARGET_INIT + "," + name + TARGET_NESTED_JARS; //$NON-NLS-1$
1515
		script.printTargetDeclaration(name, depends, null, entry.getName(true), NLS.bind(Messages.build_plugin_jar, model.getSymbolicName() + ' ' + name));
1473
		String destdir = (entry.getType() == CompiledEntry.FOLDER) ? getJARLocation(entry.getName(true)) : getTempJARFolderLocation(entry.getName(true));
1516
		String destdir = (entry.getType() == CompiledEntry.FOLDER) ? getJARLocation(entry.getName(true)) : getTempJARFolderLocation(entry.getName(true));
1474
		script.printDeleteTask(destdir, null, null);
1517
		script.printDeleteTask(destdir, null, null);
1475
		script.printMkdirTask(destdir);
1518
		script.printMkdirTask(destdir);
1476
		script.printPathStructure("path", name + PROPERTY_CLASSPATH, classpath); //$NON-NLS-1$
1519
		script.printPathStructure("path", name + PROPERTY_CLASSPATH, extractedPath); //$NON-NLS-1$
1477
1520
1478
		String[] sources = entry.getSource();
1521
		String[] sources = entry.getSource();
1479
		Map params = null, references = null;
1522
		Map params = null, references = null;
(-)src/org/eclipse/pde/build/internal/tests/ScriptGenerationTests.java (+82 lines)
Lines 2153-2156 Link Here
2153
		Utils.storeBuildProperties(buildFolder, properties);
2153
		Utils.storeBuildProperties(buildFolder, properties);
2154
		runBuild(buildFolder);
2154
		runBuild(buildFolder);
2155
	}
2155
	}
2156
2157
	public void testBug157375_NestedJars() throws Exception {
2158
		IFolder root = newTest("157375");
2159
		IFolder buildFolder = Utils.createFolder(root, "first");
2160
2161
		IFolder host = Utils.createFolder(buildFolder, "plugins/Host");
2162
		Attributes additional = new Attributes();
2163
		additional.put(new Attributes.Name("Bundle-Classpath"), "a.jar, c.jar");
2164
		Utils.generateBundleManifest(host, "Host", "1.0.0", additional);
2165
		Properties properties = new Properties();
2166
		properties.put("source.a.jar", "src_a");
2167
		properties.put("source.b.jar", "src_b");
2168
		properties.put("bin.includes", "META-INF/, a.jar, b.jar");
2169
		Utils.storeBuildProperties(host, properties);
2170
2171
		StringBuffer buffer = new StringBuffer();
2172
		buffer.append("package a;				\n");
2173
		buffer.append("public class A { }		\n");
2174
		Utils.writeBuffer(host.getFile("src_a/a/A.java"), buffer);
2175
2176
		buffer = new StringBuffer();
2177
		buffer.append("package b;			\n");
2178
		buffer.append("public class B { } 	\n");
2179
		Utils.writeBuffer(host.getFile("src_b/b/B.java"), buffer);
2180
2181
		IFolder fragment = Utils.createFolder(buildFolder, "plugins/fragment");
2182
		additional = new Attributes();
2183
		additional.put(new Attributes.Name("Fragment-Host"), "Host");
2184
		Utils.generateBundleManifest(fragment, "fragment", "1.0.0", additional);
2185
		properties = new Properties();
2186
		properties.put("source.c.jar", "src_c");
2187
		properties.put("bin.includes", "META-INF/, c.jar");
2188
		Utils.storeBuildProperties(fragment, properties);
2189
2190
		buffer = new StringBuffer();
2191
		buffer.append("package c;			\n");
2192
		buffer.append("public class C { } 	\n");
2193
		Utils.writeBuffer(fragment.getFile("src_c/c/C.java"), buffer);
2194
2195
		Utils.generateFeature(buildFolder, "F", null, new String[] {"Host", "fragment"});
2196
2197
		properties = BuildConfiguration.getBuilderProperties(buildFolder);
2198
		properties.put("topLevelElementId", "F");
2199
		properties.put("p2.gathering", "true");
2200
		properties.put("baseLocation", "");
2201
		Utils.storeBuildProperties(buildFolder, properties);
2202
2203
		runBuild(buildFolder);
2204
2205
		IFolder second = Utils.createFolder(root, "second");
2206
		IFolder plugins = Utils.createFolder(second, "target/plugins");
2207
		buildFolder.getFile("buildRepo/plugins/fragment_1.0.0.jar").getLocation().toFile().renameTo(plugins.getFile("Host_1.0.0.jar").getLocation().toFile());
2208
2209
		Utils.generateFeature(second, "F", null, new String[] {"D"});
2210
2211
		IFolder d = Utils.createFolder(second, "plugins/d");
2212
		additional = new Attributes();
2213
		additional.put(new Attributes.Name("Require-Bundle"), "Host");
2214
		Utils.generateBundleManifest(d, "D", "1.0.0", additional);
2215
		properties = new Properties();
2216
		properties.put("jars.extra.classpath", "platform:/plugin/Host/b.jar");
2217
		Utils.generatePluginBuildProperties(d, properties);
2218
2219
		buffer = new StringBuffer();
2220
		buffer.append("package d;					\n");
2221
		buffer.append("import a.A;					\n");
2222
		buffer.append("import b.B;					\n");
2223
		buffer.append("import c.C;					\n");
2224
		buffer.append("public class D { 			\n");
2225
		buffer.append("  public A a = new A();		\n");
2226
		buffer.append("  public B b = new B();		\n");
2227
		buffer.append("  public C c = new C();		\n");
2228
		buffer.append("}							\n");
2229
		Utils.writeBuffer(d.getFile("src/d/D.java"), buffer);
2230
2231
		properties = BuildConfiguration.getBuilderProperties(second);
2232
		properties.put("topLevelElementId", "F");
2233
		properties.put("pluginPath", buildFolder.getFolder("buildRepo").getLocation().toOSString());
2234
		properties.put("baseLocation", second.getFolder("target").getLocation().toOSString());
2235
		Utils.storeBuildProperties(second, properties);
2236
		runBuild(second);
2237
	}
2156
}
2238
}

Return to bug 157375