Search in sources :

Example 11 with Baseline

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

the class ReleaseHelper method updateProject.

public static void updateProject(ReleaseContext context) throws Exception {
    Collection<? extends Builder> builders = context.getProject().getBuilder(null).getSubBuilders();
    for (Builder builder : builders) {
        Baseline current = getBaselineForBuilder(builder, context);
        if (current == null) {
            continue;
        }
        for (Info info : current.getPackageInfos()) {
            context.getProject().setPackageInfo(info.packageName, info.suggestedVersion);
        }
        updateBundleVersion(context, current, builder);
    }
}
Also used : Builder(aQute.bnd.osgi.Builder) Baseline(aQute.bnd.differ.Baseline) Info(aQute.bnd.differ.Baseline.Info)

Example 12 with Baseline

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

the class ReleaseHelper method doRelease.

private static boolean doRelease(ReleaseContext context, List<Baseline> diffs, List<IReleaseParticipant> participants) throws Exception {
    boolean ret = true;
    if (!preRelease(context, participants)) {
        postRelease(context, participants, false);
        displayErrors(context);
        return false;
    }
    for (Baseline diff : diffs) {
        Collection<? extends Builder> builders = context.getProject().getBuilder(null).getSubBuilders();
        Builder builder = null;
        for (Builder b : builders) {
            if (b.getBsn().equals(diff.getBsn())) {
                builder = b;
                break;
            }
        }
        if (builder != null) {
            if (!release(context, participants, builder)) {
                ret = false;
            }
        }
    }
    return ret;
}
Also used : Builder(aQute.bnd.osgi.Builder) Baseline(aQute.bnd.differ.Baseline)

Example 13 with Baseline

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

the class BaselineMojo method execute.

public void execute() throws MojoExecutionException, MojoFailureException {
    if (skip) {
        logger.debug("skip project as configured");
        return;
    }
    Artifact artifact = RepositoryUtils.toArtifact(project.getArtifact());
    List<RemoteRepository> aetherRepos = getRepositories(artifact);
    setupBase(artifact);
    try {
        if (base.getVersion() == null || base.getVersion().isEmpty()) {
            searchForBaseVersion(artifact, aetherRepos);
        }
        if (base.getVersion() != null && !base.getVersion().isEmpty()) {
            ArtifactResult artifactResult = locateBaseJar(aetherRepos);
            Reporter reporter;
            if (fullReport) {
                reporter = new ReporterAdapter(System.out);
                ((ReporterAdapter) reporter).setTrace(true);
            } else {
                reporter = new ReporterAdapter();
            }
            Baseline baseline = new Baseline(reporter, new DiffPluginImpl());
            if (checkFailures(artifact, artifactResult, baseline)) {
                if (continueOnError) {
                    logger.warn("The baselining check failed when checking {} against {} but the bnd-baseline-maven-plugin is configured not to fail the build.", artifact, artifactResult.getArtifact());
                } else {
                    throw new MojoExecutionException("The baselining plugin detected versioning errors");
                }
            } else {
                logger.info("Baselining check succeeded checking {} against {}", artifact, artifactResult.getArtifact());
            }
        } else {
            if (failOnMissing) {
                throw new MojoExecutionException("Unable to locate a previous version of the artifact");
            } else {
                logger.warn("No previous version of {} could be found to baseline against", artifact);
            }
        }
    } catch (RepositoryException re) {
        throw new MojoExecutionException("Unable to locate a previous version of the artifact", re);
    } catch (Exception e) {
        throw new MojoExecutionException("An error occurred while calculating the baseline", e);
    }
}
Also used : DiffPluginImpl(aQute.bnd.differ.DiffPluginImpl) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) ReporterAdapter(aQute.libg.reporter.ReporterAdapter) Reporter(aQute.service.reporter.Reporter) RemoteRepository(org.eclipse.aether.repository.RemoteRepository) RepositoryException(org.eclipse.aether.RepositoryException) Baseline(aQute.bnd.differ.Baseline) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact) Artifact(org.eclipse.aether.artifact.Artifact) VersionRangeResolutionException(org.eclipse.aether.resolution.VersionRangeResolutionException) ArtifactResolutionException(org.eclipse.aether.resolution.ArtifactResolutionException) IOException(java.io.IOException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MojoFailureException(org.apache.maven.plugin.MojoFailureException) RepositoryException(org.eclipse.aether.RepositoryException) ArtifactResult(org.eclipse.aether.resolution.ArtifactResult)

Example 14 with Baseline

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

the class BaselineTest method testCutOffInheritance.

// This tests the scenario where a super type is injected into the class
// hierarchy but the super class comes from outside the bundle so that the
// baseline cannot find it. Since the class hierarchy was cut off, the
// baseline would _forget_ that every class inherits from Object, and _lose_
// Object's methods if not directly implemented.
public void testCutOffInheritance() 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/inheritance-change-1.0.0.jar"));
        Jar newer = new Jar(IO.getFile("jar/baseline/inheritance-change-1.1.0.jar"))) {
        baseline.baseline(newer, older, null);
        BundleInfo bundleInfo = baseline.getBundleInfo();
        assertFalse(bundleInfo.mismatch);
        assertEquals("1.1.0", bundleInfo.suggestedVersion.toString());
        Set<Info> packageInfos = baseline.getPackageInfos();
        assertEquals(1, packageInfos.size());
        Info change = packageInfos.iterator().next();
        assertFalse(change.mismatch);
        assertEquals("example", change.packageName);
        assertEquals("1.1.0", change.suggestedVersion.toString());
        Diff packageDiff = change.packageDiff;
        Collection<? extends Diff> children = packageDiff.getChildren();
        assertEquals(5, children.size());
        Iterator<? extends Diff> iterator = children.iterator();
        Diff diff = iterator.next();
        assertEquals(Delta.MICRO, diff.getDelta());
        diff = iterator.next();
        assertEquals(Delta.MICRO, diff.getDelta());
        diff = iterator.next();
        assertEquals(Delta.MINOR, diff.getDelta());
    }
}
Also used : DiffPluginImpl(aQute.bnd.differ.DiffPluginImpl) Processor(aQute.bnd.osgi.Processor) BundleInfo(aQute.bnd.differ.Baseline.BundleInfo) Diff(aQute.bnd.service.diff.Diff) Jar(aQute.bnd.osgi.Jar) Baseline(aQute.bnd.differ.Baseline) BundleInfo(aQute.bnd.differ.Baseline.BundleInfo) Info(aQute.bnd.differ.Baseline.Info)

Example 15 with Baseline

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

the class BaselineTest method testIgnoreResourceDiff.

/**
	 * Check if we can ignore resources in the baseline. First build two jars
	 * that are identical except for the b/b resource. Then do baseline on them.
	 */
public void testIgnoreResourceDiff() throws Exception {
    Processor processor = new Processor();
    DiffPluginImpl differ = new DiffPluginImpl();
    differ.setIgnore("b/b");
    Baseline baseline = new Baseline(processor, differ);
    try (Builder a = new Builder();
        Builder b = new Builder()) {
        a.setProperty("-includeresource", "a/a;literal='aa',b/b;literal='bb'");
        a.setProperty("-resourceonly", "true");
        b.setProperty("-includeresource", "a/a;literal='aa',b/b;literal='bbb'");
        b.setProperty("-resourceonly", "true");
        try (Jar aj = a.build();
            Jar bj = b.build()) {
            Set<Info> infoSet = baseline.baseline(aj, bj, null);
            BundleInfo binfo = baseline.getBundleInfo();
            assertFalse(binfo.mismatch);
        }
    }
}
Also used : DiffPluginImpl(aQute.bnd.differ.DiffPluginImpl) Processor(aQute.bnd.osgi.Processor) BundleInfo(aQute.bnd.differ.Baseline.BundleInfo) ProjectBuilder(aQute.bnd.build.ProjectBuilder) Builder(aQute.bnd.osgi.Builder) Jar(aQute.bnd.osgi.Jar) Baseline(aQute.bnd.differ.Baseline) BundleInfo(aQute.bnd.differ.Baseline.BundleInfo) Info(aQute.bnd.differ.Baseline.Info)

Aggregations

Baseline (aQute.bnd.differ.Baseline)27 Info (aQute.bnd.differ.Baseline.Info)15 DiffPluginImpl (aQute.bnd.differ.DiffPluginImpl)15 Jar (aQute.bnd.osgi.Jar)15 BundleInfo (aQute.bnd.differ.Baseline.BundleInfo)13 Processor (aQute.bnd.osgi.Processor)11 Builder (aQute.bnd.osgi.Builder)9 Diff (aQute.bnd.service.diff.Diff)6 ArrayList (java.util.ArrayList)5 ProjectBuilder (aQute.bnd.build.ProjectBuilder)4 RepositoryPlugin (aQute.bnd.service.RepositoryPlugin)2 Tree (aQute.bnd.service.diff.Tree)2 Version (aQute.bnd.version.Version)2 ReporterAdapter (aQute.libg.reporter.ReporterAdapter)2 WorkspaceReleaseDialog (bndtools.release.ui.WorkspaceReleaseDialog)2 IOException (java.io.IOException)2 List (java.util.List)2 IStatus (org.eclipse.core.runtime.IStatus)2 Status (org.eclipse.core.runtime.Status)2 Project (aQute.bnd.build.Project)1