Skip to content

Commit

Permalink
Assume bundle shape as jar by default
Browse files Browse the repository at this point in the history
- set PDE generator to assume "unpack" attribute from bundles to be
"false" by default.
- additionally adopted testBug263272() to ignore "unpack=false"
instructions from the feature.

Fixes #884
  • Loading branch information
iloveeclipse committed Nov 7, 2023
1 parent 9d7b6a8 commit 1765416
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 11 deletions.
2 changes: 1 addition & 1 deletion build/org.eclipse.pde.build.tests/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Tests Plug-in
Bundle-SymbolicName: org.eclipse.pde.build.tests;singleton:=true
Bundle-Version: 1.4.100.qualifier
Bundle-Version: 1.4.200.qualifier
Bundle-Activator: org.eclipse.pde.build.tests.Activator
Export-Package: org.eclipse.pde.build.internal.tests;x-internal:=true,
org.eclipse.pde.build.internal.tests.ant;x-internal:=true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -629,8 +629,8 @@ public void testBug263272() throws Exception {
IFolder b = Utils.createFolder(buildFolder, "plugins/b");
IFolder c = Utils.createFolder(buildFolder, "plugins/c");

Utils.generateFeature(buildFolder, "F", null, new String[] { "a;unpack=false", "b;unpack=false;os=linux",
"b;unpack=false;os=win32", "c;unpack=false" });
Utils.generateFeature(buildFolder, "F", null, new String[] { "a", "b;os=linux",
"b;os=win32", "c" });
Properties featureProperties = new Properties();
featureProperties.put("bin.includes", "feature.xml");
Utils.storeProperties(buildFolder.getFile("features/F/build.properties"), featureProperties);
Expand Down Expand Up @@ -685,7 +685,7 @@ public void testBug263272() throws Exception {

// now change A and recompile
Utils.generateFeature(buildFolder, "F", null,
new String[] { "a;unpack=true", "b;os=linux;optional=true", "c;unpack=false" });
new String[] { "a", "b;os=linux;optional=true", "c" });
Utils.storeProperties(buildFolder.getFile("features/F/build.properties"), featureProperties);

code = new StringBuffer();
Expand Down Expand Up @@ -762,8 +762,7 @@ public void testBug263272() throws Exception {
assertLogContainsLines(buildFolder.getFile("compare.log"),
new String[] { "canonical: org.eclipse.update.feature,F,1.0.0",
"The feature has a different number of entries",
"The entry \"Plugin: a 1.0.0.v2\" is not present in both features",
"The entry \"Plugin: b 1.0.0\" has different unpack attribute values" });
"The entry \"Plugin: a 1.0.0.v2\" is not present in both features", });
assertLogContainsLines(buildFolder.getFile("compare.log"),
new String[] { "canonical: osgi.bundle,b,1.0.0", "The class B.class is different." });
boolean failed = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

package org.eclipse.pde.build.tests;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import java.io.BufferedReader;
import java.io.File;
Expand All @@ -26,11 +26,15 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.apache.tools.ant.Project;
import org.apache.tools.ant.helper.AntXMLContext;
Expand Down Expand Up @@ -324,9 +328,11 @@ public static void assertLogContainsLines(IFile log, String[] lines) throws Exce
assertTrue(logFile.length() > 0);

int idx = 0;
List<String> logContent = new ArrayList<>();
try (BufferedReader reader = new BufferedReader(new FileReader(logFile))) {
while (reader.ready()) {
String line = reader.readLine();
logContent.add(line);
if (line.indexOf(lines[idx]) >= 0) {
if (++idx >= lines.length) {
reader.close();
Expand All @@ -335,7 +341,11 @@ public static void assertLogContainsLines(IFile log, String[] lines) throws Exce
}
}
}
fail();

// Will always fail here (expected)
String expected = Stream.of(lines).map(x -> x.trim()).collect(Collectors.joining("\n"));
String actual = logContent.stream().map(x -> x.trim()).collect(Collectors.joining("\n"));
assertEquals("Not found given lines in given order", expected, actual);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ protected void createFeature(String feature, Set<Entry> plugins, Set<Entry> frag
Entry entry = listIter.next();
String name = entry.getId();
String bundleVersion = entry.getVersion();
boolean guessedUnpack = true;
boolean guessedUnpack = false;
boolean writeBundle = !verify;
if (verify) {
BundleDescription bundle = state.getResolvedBundle(name, bundleVersion);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,6 @@ else if (result.booleanValue() != entry.isUnpack()) {
}
}

return true; //don't know, return the default
return false; //don't know, return the default
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ else if (input.startsWith("exclude@") || input.startsWith("feature@")) //$NON-NL

results.put(EXTRA_ID, tokenizer.nextToken());
results.put(EXTRA_VERSION, Version.emptyVersion);
results.put(EXTRA_UNPACK, Boolean.TRUE);
results.put(EXTRA_UNPACK, Boolean.FALSE);

while (tokenizer.hasMoreTokens()) {
String token = tokenizer.nextToken();
Expand Down

0 comments on commit 1765416

Please sign in to comment.