I am trying to generate the javadoc using JDK 8 for a bunch of codes using lombok.
I am getting the error below:
error: cannot find symbol
[ERROR] @RequiredArgsConstructor(onConstructor=@__(@Inject))
[ERROR] ^
[ERROR] symbol: class __
Any advice will be much appreciated on how to resolve the error above.
Update: the error is happening using the maven javadoc plugin configured as below:
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.3</version>
<!--
<configuration>
<doclet>ch.raffael.doclets.pegdown.PegdownDoclet</doclet>
<docletArtifact>
<groupId>ch.raffael.pegdown-doclet</groupId>
<artifactId>pegdown-doclet</artifactId>
<version>1.1.1</version>
</docletArtifact>
<useStandardDocletOptions>true</useStandardDocletOptions>
</configuration>
-->
</plugin>
You need to call mvn javadoc:fix to fix main Java source files (i.e. inside src/main/java directory) or mvn javadoc:test-fix to fix test Java source files (i.e. inside src/test/java directory).
For example, this: @RequiredArgsConstructor(onConstructor = @__(@Inject)) will generate a constructor annotated with @Inject. Follow this answer to receive notifications.
I had the same issue, resolved by:
Configuring lombok-maven-plugin
to
target/delombok
directoryaddOutputDirectory
to the compiler source pathsConfigure maven-javadoc-plugin
to look into the target/delombok
directory
A good explanation is also at this similar question
Also, bare in mind that onConstructor is an experimental feature and that with jdk8, you should use (onConstructor_ = @Autowired)
instead of jdk7-style onConstructor = @__(@Autowired)
Here is my full config:
<plugin>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-maven-plugin</artifactId>
<version>${lombok-maven-plugin-version}</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>delombok</goal>
</goals>
<configuration>
<addOutputDirectory>false</addOutputDirectory>
<sourceDirectory>src/main/java</sourceDirectory>
<outputDirectory>
${project.build.directory}/delombok
</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>${maven-javadoc-plugin-version}</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
<configuration>
<sourcepath>target/generated-sources/delombok</sourcepath>
</configuration>
</plugin>
Adding here just for future reference as on my case I was trying to build on Intelij and the error was due to compiler annotation processors being disabled.
To enable it, go to Intelij preferences, open "Build, Execution, Deployment" -> "Compiler" -> "Annotation Processors" and make sure "Enable annotation processing" is enabled
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With