use of aQute.bnd.differ.Baseline.Info in project bnd by bndtools.
the class BaselineTest method testProviderTypeBump.
// Adding a method to a ProviderType produces a MINOR bump (1.0.0 -> 1.1.0)
public void testProviderTypeBump() 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"))) {
Set<Info> infoSet = baseline.baseline(newer, older, null);
System.out.println(differ.tree(newer).get("<api>"));
assertEquals(1, infoSet.size());
Info info = infoSet.iterator().next();
assertTrue(info.mismatch);
assertEquals("dummy.api", info.packageName);
assertEquals("1.1.0", info.suggestedVersion.toString());
}
}
use of aQute.bnd.differ.Baseline.Info 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.Info in project bnd by bndtools.
the class BaselineCommands method doExportPackage.
/**
* @param infos
* @param out
* @throws IOException
*/
public void doExportPackage(Info[] infos, PrintStream out) throws IOException {
out.printf("# Suggested versions\n%-40s = ", Constants.EXPORT_PACKAGE);
String del = "";
for (Info info : infos) {
out.append(del);
out.printf("\\\n ");
out.append(info.packageName);
info.attributes.put(Constants.VERSION_ATTRIBUTE, info.suggestedVersion.toString());
for (Map.Entry<String, String> clause : info.attributes.entrySet()) {
if (clause.getKey().equals(Constants.USES_DIRECTIVE))
continue;
out.append(";\\\n ");
out.append(clause.getKey());
out.append("=");
Processor.quote(out, clause.getValue());
}
if (info.providers != null && !info.providers.isEmpty()) {
out.append(";\\\n " + Constants.PROVIDER_TYPE_DIRECTIVE + "=\"");
String del2 = "";
for (String part : info.providers) {
out.append(del2);
out.append("\\\n ");
out.append(part);
del2 = ",";
}
out.append("\"");
}
del = ",";
}
}
use of aQute.bnd.differ.Baseline.Info 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();
}
}
use of aQute.bnd.differ.Baseline.Info in project bnd by bndtools.
the class DiffTest method testAPIStaticSuperClassChange.
public void testAPIStaticSuperClassChange() throws Exception {
Jar older = new Jar(IO.getFile("../demo/generated/demo.jar"));
Builder b = new Builder();
b.addClasspath(IO.getFile("bin"));
b.setExportPackage("test.api");
b.build();
assertTrue(b.check());
Jar newer = b.getJar();
Processor processor = new Processor();
DiffPluginImpl differ = new DiffPluginImpl();
Baseline baseline = new Baseline(processor, differ);
Info info = baseline.baseline(newer, older, null).iterator().next();
Diff field = info.packageDiff.get("test.api.B");
show(field, 2);
assertEquals(Delta.UNCHANGED, field.getDelta());
b.close();
}
Aggregations