Search in sources :

Example 6 with DiffPluginImpl

use of aQute.bnd.differ.DiffPluginImpl 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 7 with DiffPluginImpl

use of aQute.bnd.differ.DiffPluginImpl in project bnd by bndtools.

the class BaselineTest method testClassesDiffWithSource.

/**
	 * Test skipping classes when there is source
	 */
public void testClassesDiffWithSource() throws Exception {
    DiffPluginImpl diff = new DiffPluginImpl();
    try (Jar jar = new Jar(IO.getFile("jar/osgi.jar"));
        Jar out = new Jar(".")) {
        out.putResource("OSGI-OPT/src/org/osgi/application/ApplicationContext.java", jar.getResource("OSGI-OPT/src/org/osgi/application/ApplicationContext.java"));
        out.putResource("org/osgi/application/ApplicationContext.class", jar.getResource("org/osgi/application/ApplicationContext.class"));
        Tree tree = diff.tree(out);
        Tree src = tree.get("<resources>").get("OSGI-OPT/src/org/osgi/application/ApplicationContext.java").getChildren()[0];
        assertNotNull(src);
        assertNull(tree.get("<resources>").get("org/osgi/application/ApplicationContext.class"));
    }
}
Also used : DiffPluginImpl(aQute.bnd.differ.DiffPluginImpl) Tree(aQute.bnd.service.diff.Tree) Jar(aQute.bnd.osgi.Jar)

Example 8 with DiffPluginImpl

use of aQute.bnd.differ.DiffPluginImpl 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 9 with DiffPluginImpl

use of aQute.bnd.differ.DiffPluginImpl in project bnd by bndtools.

the class DiffCommand method showTree.

/**
	 * Just show the single tree
	 * 
	 * @param bnd
	 * @param options
	 * @throws Exception
	 */
private static void showTree(bnd bnd, diffOptions options) throws Exception {
    File fout = options.output();
    PrintWriter pw;
    if (fout == null)
        pw = IO.writer(bnd.out);
    else
        pw = IO.writer(fout, UTF_8);
    Instructions packageFilters = new Instructions(options.pack());
    try (Jar newer = new Jar(bnd.getFile(options._arguments().get(0)))) {
        Differ di = new DiffPluginImpl();
        Tree n = di.tree(newer);
        boolean all = options.api() == false && options.resources() == false && options.manifest() == false;
        if (all || options.api())
            for (Tree packageDiff : n.get("<api>").getChildren()) {
                if (packageFilters.matches(packageDiff.getName()))
                    show(pw, packageDiff, 0);
            }
        if (all || options.manifest())
            show(pw, n.get("<manifest>"), 0);
        if (all || options.resources())
            show(pw, n.get("<resources>"), 0);
    } finally {
        pw.close();
    }
}
Also used : DiffPluginImpl(aQute.bnd.differ.DiffPluginImpl) Differ(aQute.bnd.service.diff.Differ) Tree(aQute.bnd.service.diff.Tree) Instructions(aQute.bnd.osgi.Instructions) Jar(aQute.bnd.osgi.Jar) File(java.io.File) PrintWriter(java.io.PrintWriter)

Example 10 with DiffPluginImpl

use of aQute.bnd.differ.DiffPluginImpl in project bnd by bndtools.

the class DiffTest method testSimple.

public static void testSimple() throws Exception {
    DiffPluginImpl differ = new DiffPluginImpl();
    differ.setIgnore("Bundle-Copyright,Bundle-Description,Bundle-License,Bundle-Name,bundle-manifestversion,Export-Package,Import-Package,Bundle-Vendor,Bundle-Version");
    Tree newer = differ.tree(new Jar(IO.getFile("jar/osgi.core-4.3.0.jar")));
    // 4.2
    Tree older = differ.tree(new Jar(IO.getFile("jar/osgi.core.jar")));
    Diff diff = newer.get("<manifest>").diff(older.get("<manifest>"));
    show(diff, 0);
    assertEquals(Delta.UNCHANGED, diff.getDelta());
}
Also used : DiffPluginImpl(aQute.bnd.differ.DiffPluginImpl) Diff(aQute.bnd.service.diff.Diff) Tree(aQute.bnd.service.diff.Tree) Jar(aQute.bnd.osgi.Jar)

Aggregations

DiffPluginImpl (aQute.bnd.differ.DiffPluginImpl)21 Jar (aQute.bnd.osgi.Jar)20 Baseline (aQute.bnd.differ.Baseline)15 BundleInfo (aQute.bnd.differ.Baseline.BundleInfo)12 Processor (aQute.bnd.osgi.Processor)11 Info (aQute.bnd.differ.Baseline.Info)9 ProjectBuilder (aQute.bnd.build.ProjectBuilder)5 Builder (aQute.bnd.osgi.Builder)5 Tree (aQute.bnd.service.diff.Tree)5 Diff (aQute.bnd.service.diff.Diff)4 ReporterAdapter (aQute.libg.reporter.ReporterAdapter)2 File (java.io.File)2 Project (aQute.bnd.build.Project)1 Instructions (aQute.bnd.osgi.Instructions)1 Differ (aQute.bnd.service.diff.Differ)1 Version (aQute.bnd.version.Version)1 Reporter (aQute.service.reporter.Reporter)1 IOException (java.io.IOException)1 PrintWriter (java.io.PrintWriter)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1