ErrorPronePlugins support search annation info within CLASS_PATH
- Dominant language
- Java
- Stars
- 7.2k
- Forks
- 820
- Avg merge
- 5h 9m
- Merged PRs (30d)
- 50
Description
```
public class ErrorPronePlugins {
public static ScannerSupplier loadPlugins(ScannerSupplier scannerSupplier, Context context) {
JavaFileManager fileManager = context.get(JavaFileManager.class);
// Unlike in annotation processor discovery, we never search CLASS_PATH if
// ANNOTATION_PROCESSOR_PATH is unavailable.
if (!fileManager.hasLocation(StandardLocation.ANNOTATION_PROCESSOR_PATH)) {
return scannerSupplier;
}
// Use the same classloader that Error Prone was loaded from to avoid classloader skew
// when using Error Prone plugins together with the Error Prone javac plugin.
JavacProcessingEnvironment processingEnvironment = JavacProcessingEnvironment.instance(context);
ClassLoader loader = processingEnvironment.getProcessorClassLoader();
Iterable extraBugCheckers = ServiceLoader.load(BugChecker.class, loader);
if (Iterables.isEmpty(extraBugCheckers)) {
return scannerSupplier;
}
return scannerSupplier.plus(
ScannerSupplier.fromBugCheckerClasses(
Iterables.transform(extraBugCheckers, BugChecker::getClass)));
}
}
```
https://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html
maven note: Classpath elements to supply as annotation processor path. If specified, the compiler will detect annotation processors only in those classpath elements. If omitted, the default classpath is used to detect annotation processors. The detection itself depends on the configuration of annotationProcessors.
ErrorPronePlugins broke this specification of maven-compiler-plugin, please resolve this conflict issue about this code.
Contributor guide
Assessment
This issue has not been assessed yet.