Search in sources :

Example 1 with BundleInfo

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());
    }
}
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)

Example 2 with BundleInfo

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());
    }
}
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)

Example 3 with BundleInfo

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());
    }
}
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 4 with BundleInfo

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());
    }
}
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)

Example 5 with BundleInfo

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();
    }
}
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)

Aggregations

BundleInfo (aQute.bnd.differ.Baseline.BundleInfo)12 Jar (aQute.bnd.osgi.Jar)10 Baseline (aQute.bnd.differ.Baseline)9 DiffPluginImpl (aQute.bnd.differ.DiffPluginImpl)8 Processor (aQute.bnd.osgi.Processor)8 Info (aQute.bnd.differ.Baseline.Info)7 ProjectBuilder (aQute.bnd.build.ProjectBuilder)2 Builder (aQute.bnd.osgi.Builder)2 Diff (aQute.bnd.service.diff.Diff)2 Formatter (java.util.Formatter)2 Parameters (aQute.bnd.header.Parameters)1 Instructions (aQute.bnd.osgi.Instructions)1 RepositoryPlugin (aQute.bnd.service.RepositoryPlugin)1 InfoRepository (aQute.bnd.service.repository.InfoRepository)1 ResourceDescriptor (aQute.bnd.service.repository.SearchableRepository.ResourceDescriptor)1 Version (aQute.bnd.version.Version)1 MultiMap (aQute.lib.collections.MultiMap)1 File (java.io.File)1 PrintStream (java.io.PrintStream)1 HashMap (java.util.HashMap)1