Search in sources :

Example 1 with Info

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());
    }
}
Also used : DiffPluginImpl(aQute.bnd.differ.DiffPluginImpl) Processor(aQute.bnd.osgi.Processor) Jar(aQute.bnd.osgi.Jar) Baseline(aQute.bnd.differ.Baseline) BundleInfo(aQute.bnd.differ.Baseline.BundleInfo) Info(aQute.bnd.differ.Baseline.Info)

Example 2 with Info

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());
    }
}
Also used : DiffPluginImpl(aQute.bnd.differ.DiffPluginImpl) Processor(aQute.bnd.osgi.Processor) BundleInfo(aQute.bnd.differ.Baseline.BundleInfo) Jar(aQute.bnd.osgi.Jar) Baseline(aQute.bnd.differ.Baseline) BundleInfo(aQute.bnd.differ.Baseline.BundleInfo) Info(aQute.bnd.differ.Baseline.Info)

Example 3 with Info

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 = ",";
    }
}
Also used : Info(aQute.bnd.differ.Baseline.Info) BundleInfo(aQute.bnd.differ.Baseline.BundleInfo) MultiMap(aQute.lib.collections.MultiMap) Map(java.util.Map)

Example 4 with Info

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();
    }
}
Also used : PrintStream(java.io.PrintStream) BundleInfo(aQute.bnd.differ.Baseline.BundleInfo) Info(aQute.bnd.differ.Baseline.Info) BundleInfo(aQute.bnd.differ.Baseline.BundleInfo) Manifest(java.util.jar.Manifest) MultiMap(aQute.lib.collections.MultiMap) Map(java.util.Map)

Example 5 with Info

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();
}
Also used : DiffPluginImpl(aQute.bnd.differ.DiffPluginImpl) Processor(aQute.bnd.osgi.Processor) Diff(aQute.bnd.service.diff.Diff) Builder(aQute.bnd.osgi.Builder) Jar(aQute.bnd.osgi.Jar) Baseline(aQute.bnd.differ.Baseline) Info(aQute.bnd.differ.Baseline.Info)

Aggregations

Info (aQute.bnd.differ.Baseline.Info)22 Baseline (aQute.bnd.differ.Baseline)16 BundleInfo (aQute.bnd.differ.Baseline.BundleInfo)13 Jar (aQute.bnd.osgi.Jar)13 DiffPluginImpl (aQute.bnd.differ.DiffPluginImpl)10 Processor (aQute.bnd.osgi.Processor)8 Builder (aQute.bnd.osgi.Builder)5 ProjectBuilder (aQute.bnd.build.ProjectBuilder)4 Diff (aQute.bnd.service.diff.Diff)4 Version (aQute.bnd.version.Version)4 Instructions (aQute.bnd.osgi.Instructions)3 MultiMap (aQute.lib.collections.MultiMap)3 Parameters (aQute.bnd.header.Parameters)2 RepositoryPlugin (aQute.bnd.service.RepositoryPlugin)2 File (java.io.File)2 Formatter (java.util.Formatter)2 Map (java.util.Map)2 Manifest (java.util.jar.Manifest)2 Attrs (aQute.bnd.header.Attrs)1 Analyzer (aQute.bnd.osgi.Analyzer)1