diff --git a/tycho-baseline-plugin/src/main/java/org/eclipse/tycho/baseline/DependencyCheckMojo.java b/tycho-baseline-plugin/src/main/java/org/eclipse/tycho/baseline/DependencyCheckMojo.java index 1e85c65047..b56e36c365 100644 --- a/tycho-baseline-plugin/src/main/java/org/eclipse/tycho/baseline/DependencyCheckMojo.java +++ b/tycho-baseline-plugin/src/main/java/org/eclipse/tycho/baseline/DependencyCheckMojo.java @@ -150,7 +150,8 @@ public void execute() throws MojoExecutionException, MojoFailureException { Map lowestPackageVersion = new HashMap<>(); Map> allPackageVersion = new HashMap<>(); Set packageWithError = new HashSet<>(); - Function> classResolver = DependencyAnalyzer + DependencyAnalyzer dependencyAnalyzer = new DependencyAnalyzer((m, e) -> getLog().error(m, e)); + Function> classResolver = dependencyAnalyzer .createDependencyClassResolver(jrtClassResolver, artifacts); for (GenericInfo genericInfo : requirements) { if (PackageNamespace.PACKAGE_NAMESPACE.equals(genericInfo.getNamespace())) { @@ -223,7 +224,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { } ClassCollection collection = analyzeCache.get(artifact); if (collection == null) { - collection = DependencyAnalyzer.analyzeProvides(artifact.toFile(), classResolver, null); + collection = dependencyAnalyzer.analyzeProvides(artifact.toFile(), classResolver); analyzeCache.put(artifact, collection); } boolean ok = true; diff --git a/tycho-baseline-plugin/src/main/java/org/eclipse/tycho/baseline/analyze/DependencyAnalyzer.java b/tycho-baseline-plugin/src/main/java/org/eclipse/tycho/baseline/analyze/DependencyAnalyzer.java index 1152b53858..ff36357441 100644 --- a/tycho-baseline-plugin/src/main/java/org/eclipse/tycho/baseline/analyze/DependencyAnalyzer.java +++ b/tycho-baseline-plugin/src/main/java/org/eclipse/tycho/baseline/analyze/DependencyAnalyzer.java @@ -19,6 +19,7 @@ import java.util.Enumeration; import java.util.List; import java.util.Optional; +import java.util.function.BiConsumer; import java.util.function.Consumer; import java.util.function.Function; import java.util.jar.JarEntry; @@ -34,6 +35,11 @@ public class DependencyAnalyzer { static final String CLASS_SUFFIX = ".class"; static final int ASM_API = Opcodes.ASM9; + private BiConsumer errorConsumer; + + public DependencyAnalyzer(BiConsumer errorConsumer) { + this.errorConsumer = errorConsumer; + } public static String getPackageName(String className) { className = className.replace('/', '.'); @@ -44,7 +50,7 @@ public static String getPackageName(String className) { return className; } - public static Function> createDependencyClassResolver(JrtClasses jrtClassResolver, + public Function> createDependencyClassResolver(JrtClasses jrtClassResolver, DependencyArtifacts artifacts) throws MojoFailureException { ClassCollection allClassMethods = new ClassCollection(); Function> function = allClassMethods.chain(jrtClassResolver); @@ -76,7 +82,12 @@ public static List analyzeUsage(File file, JrtClasses jre) throws Mo } } - public static ClassCollection analyzeProvides(File file, Function> classResolver, + public ClassCollection analyzeProvides(File file, Function> classResolver) + throws MojoFailureException { + return analyzeProvides(file, classResolver, null); + } + + public ClassCollection analyzeProvides(File file, Function> classResolver, Consumer consumer) throws MojoFailureException { try { ClassCollection local = new ClassCollection(); @@ -88,7 +99,16 @@ public static ClassCollection analyzeProvides(File file, Function