use of aQute.bnd.differ.Baseline.BundleInfo in project bnd by bndtools.
the class BaselineTest method testBundleVersionBumpDifferentSymbolicNames.
// Adding a method to a ProviderType produces a MINOR bump (1.0.0 -> 1.1.0)
public void testBundleVersionBumpDifferentSymbolicNames() throws Exception {
Processor processor = new Processor();
DiffPluginImpl differ = new DiffPluginImpl();
Baseline baseline = new Baseline(processor, differ);
try (Jar older = new Jar(IO.getFile("testresources/api-orig.jar"));
Jar newer = new Jar(IO.getFile("testresources/api-providerbump.jar"))) {
newer.getManifest().getMainAttributes().putValue(BUNDLE_SYMBOLICNAME, "a.different.name");
baseline.baseline(newer, older, null);
BundleInfo bundleInfo = baseline.getBundleInfo();
assertFalse(bundleInfo.mismatch);
assertEquals(newer.getVersion(), bundleInfo.suggestedVersion.toString());
}
}
use of aQute.bnd.differ.Baseline.BundleInfo in project bnd by bndtools.
the class BaselineTest method testMinorAndRemovedChange.
// Adding a method to an exported class and unexporting a package produces a MINOR bump (1.0.0 -> 1.1.0)
public void testMinorAndRemovedChange() throws Exception {
Processor processor = new Processor();
DiffPluginImpl differ = new DiffPluginImpl();
Baseline baseline = new Baseline(processor, differ);
try (Jar older = new Jar(IO.getFile("testresources/minor-and-removed-change-1.0.0.jar"));
Jar newer = new Jar(IO.getFile("testresources/minor-and-removed-change-1.0.1.jar"))) {
baseline.baseline(newer, older, null);
BundleInfo bundleInfo = baseline.getBundleInfo();
assertTrue(bundleInfo.mismatch);
assertEquals("2.0.0", bundleInfo.suggestedVersion.toString());
}
}
use of aQute.bnd.differ.Baseline.BundleInfo in project bnd by bndtools.
the class BaselineTest method testMovePackageToBundleClassPath.
// Moving a package from the root into a jar on the Bundle-ClassPath
// should not result in DELETED
public void testMovePackageToBundleClassPath() throws Exception {
Processor processor = new Processor();
DiffPluginImpl differ = new DiffPluginImpl();
Baseline baseline = new Baseline(processor, differ);
try (Jar older = new Jar(IO.getFile("jar/baseline/com.liferay.calendar.api-2.0.5.jar"));
Jar newer = new Jar(IO.getFile("jar/baseline/com.liferay.calendar.api-2.1.0.jar"))) {
baseline.baseline(newer, older, null);
BundleInfo bundleInfo = baseline.getBundleInfo();
assertFalse(bundleInfo.mismatch);
assertEquals("2.1.0", bundleInfo.suggestedVersion.toString());
Set<Info> packageInfos = baseline.getPackageInfos();
assertEquals(12, packageInfos.size());
Info change = packageInfos.iterator().next();
assertFalse(change.mismatch);
assertEquals("com.google.ical.iter", change.packageName);
assertEquals("20110304.0.0", change.suggestedVersion.toString());
}
}
use of aQute.bnd.differ.Baseline.BundleInfo in project bnd by bndtools.
the class BaselineTest method testBundleVersionBump.
// Adding a method to a ProviderType produces a MINOR bump (1.0.0 -> 1.1.0)
public void testBundleVersionBump() throws Exception {
Processor processor = new Processor();
DiffPluginImpl differ = new DiffPluginImpl();
Baseline baseline = new Baseline(processor, differ);
try (Jar older = new Jar(IO.getFile("testresources/api-orig.jar"));
Jar newer = new Jar(IO.getFile("testresources/api-providerbump.jar"))) {
baseline.baseline(newer, older, null);
BundleInfo bundleInfo = baseline.getBundleInfo();
assertTrue(bundleInfo.mismatch);
assertEquals("1.1.0", bundleInfo.suggestedVersion.toString());
}
}
use of aQute.bnd.differ.Baseline.BundleInfo in project bnd by bndtools.
the class BaselineCommands method baseline.
private void baseline(baseLineOptions opts, Jar newer, Jar older) throws FileNotFoundException, UnsupportedEncodingException, IOException, Exception {
PrintStream out = null;
if (opts.fixup() != null) {
out = new PrintStream(bnd.getFile(opts.fixup()), "UTF-8");
}
Set<Info> infos = baseline.baseline(newer, older, null);
BundleInfo bundleInfo = baseline.getBundleInfo();
Info[] sorted = infos.toArray(new Info[0]);
Arrays.sort(sorted, new Comparator<Info>() {
public int compare(Info o1, Info o2) {
return o1.packageName.compareTo(o2.packageName);
}
});
if (!opts.quiet()) {
bnd.out.printf("===============================================================%n%s %s %s-%s", bundleInfo.mismatch ? '*' : ' ', bundleInfo.bsn, newer.getVersion(), older.getVersion());
if (bundleInfo.mismatch && bundleInfo.suggestedVersion != null)
bnd.out.printf(" suggests %s", bundleInfo.suggestedVersion);
bnd.out.printf("%n===============================================================%n");
boolean hadHeader = false;
for (Info info : sorted) {
if (info.packageDiff.getDelta() != Delta.UNCHANGED || opts.all()) {
if (!hadHeader) {
bnd.out.printf(" %-50s %-10s %-10s %-10s %-10s %-10s%n", "Package", "Delta", "New", "Old", "Suggest", "If Prov.");
hadHeader = true;
}
bnd.out.printf("%s %-50s %-10s %-10s %-10s %-10s %-10s%n", info.mismatch ? '*' : ' ', //
info.packageName, //
info.packageDiff.getDelta(), //
info.newerVersion, info.olderVersion != null && info.olderVersion.equals(Version.LOWEST) ? "-" : //
info.olderVersion, info.suggestedVersion != null && info.suggestedVersion.compareTo(info.newerVersion) <= 0 ? "ok" : //
info.suggestedVersion, info.suggestedIfProviders == null ? "-" : info.suggestedIfProviders);
}
}
}
if (out != null) {
// Create a fixup file
Manifest manifest = newer.getManifest();
if (manifest == null)
manifest = new Manifest();
for (Map.Entry<Object, Object> e : manifest.getMainAttributes().entrySet()) {
String key = e.getKey().toString();
if (!SKIP_HEADERS.contains(key)) {
if (!Constants.EXPORT_PACKAGE.equals(key)) {
out.printf("%-40s = ", key);
String value = (String) e.getValue();
out.append(value);
}
out.println();
}
}
doExportPackage(sorted, out);
out.close();
}
}
Aggregations