Generate `Log4jPlugins` class does not compile in JPMS
Currently log4j-plugin-processor in version 3.0.0-beta3 of Log4j Core adds BND annotations to the generated code.
While these might be useful for OSGi users, they cause a compilation error if the biz.aQute.bnd.annotation module is not present:
- On the compiler classpath,
- A
staticdependency on the module is not declared in themodule-info.javafile.
A workaround for this issue is to add:
<dependency>
<groupId>biz.aQute.bnd</groupId>
<artifactId>biz.aQute.bnd.annotation</artifactId>
<version>7.1.0</version>
<scope>provided</scope>
</dependency>
to the compile-time only classpath and a:
requires static biz.aQute.bnd.annotation;
to the module descriptor. The annotations have a CLASS retention, so they don't cause problems at runtime.
A workaround for this issue is to add:
to the compile-time only classpath and a: biz.aQute.bnd biz.aQute.bnd.annotation 7.1.0 provided requires static biz.aQute.bnd.annotation; to the module descriptor. The annotations have a
CLASSretention, so they don't cause problems at runtime.
Just wanted to confirm -- the suggested workaround code changes on the source -- not during usage, correct? Meaning... wait until beta4 to use the PlugProcessor in non-OSGi environments
biz.aQute.bnd.annotation has a retention of CLASS, i.e. its presence or absence does not make a difference at runtime.
@ppkarwasz to clarify my use case -- I was attempting to build a a custom plug however the annotation processor (using Kotlin Kapt) breaks -- complaining that the annotations are unable to be resolved. And tasks for the prompt feedback
error: cannot find symbol
@ServiceProvider(value = PluginService.class, resolution = Resolution.OPTIONAL)
^
symbol: variable Resolution
error: package aQute.bnd.annotation.spi does not exist
import aQute.bnd.annotation.spi.ServiceProvider;
error: cannot find symbol
@ServiceProvider(value = PluginService.class, resolution = Resolution.OPTIONAL)
^
symbol: class ServiceProvider
@lockhartja,
Did you try adding:
compileOnly 'biz.aQute.bnd:biz.aQute.bnd.annotation:7.1.0'
to your dependencies?
Yes -- that does solve the issue -- thanks
@ppkarwasz Maybe it is better to change milestone to 3.x?