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