Skip to content

Commit

Permalink
Propagate the baseline problem messages to the BuildContext
Browse files Browse the repository at this point in the history
  • Loading branch information
laeubi committed Dec 18, 2022
1 parent 4808765 commit 00cf53f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.eclipse.tycho.core.osgitools.OsgiManifest;
import org.eclipse.tycho.core.osgitools.OsgiManifestParserException;
import org.eclipse.tycho.p2maven.repository.P2RepositoryManager;
import org.sonatype.plexus.build.incremental.BuildContext;

/**
* Verifies the artifact against a given baseline repository for version
Expand Down Expand Up @@ -108,6 +109,9 @@ public class BaselineMojo extends AbstractMojo implements BaselineContext {
@Component
private Map<String, ArtifactBaselineComparator> comparators;

@Component
BuildContext buildContext;

@Component
private BundleReader bundleReader;

Expand All @@ -117,6 +121,9 @@ public class BaselineMojo extends AbstractMojo implements BaselineContext {

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
// TODO we actually want a method removeAllMessages() so the comparators can add
// messages on individual files
buildContext.removeMessages(project.getBasedir());
if (skip || baselines == null || baselines.isEmpty()) {
logger.info("Skipped.");
return;
Expand Down Expand Up @@ -196,8 +203,10 @@ private void loadRepositories() throws MojoExecutionException {
@Override
public void reportBaselineProblem(String message) throws MojoFailureException {
if (mode == BaselineMode.warn) {
buildContext.addMessage(project.getBasedir(), 0, 0, message, BuildContext.SEVERITY_WARNING, null);
logger.warn(message);
} else {
buildContext.addMessage(project.getBasedir(), 0, 0, message, BuildContext.SEVERITY_ERROR, null);
throw new MojoFailureException(message);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
import org.osgi.framework.BundleException;
import org.osgi.framework.Constants;
import org.osgi.framework.Version;
import org.sonatype.plexus.build.incremental.BuildContext;

import aQute.bnd.differ.Baseline;
import aQute.bnd.differ.Baseline.BundleInfo;
Expand Down Expand Up @@ -82,9 +81,6 @@ public class BundleArtifactBaselineComparator implements ArtifactBaselineCompara

private static final int WIDTH = 160;

@Requirement
BuildContext buildContext;

@Requirement
private P2RepositoryManager repositoryManager;

Expand Down

0 comments on commit 00cf53f

Please sign in to comment.