spring-projects/spring-boot

Ref to annotationProcessor rather than compileOnly for annotation processors

Closed this issue · 8 comments

izeye commented

With the current snapshot version (2.1.0.BUILD-SNAPSHOT) of Spring Boot, building a Spring Boot application with ./gradlew clean check prints the following deprecation message:

Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
See https://docs.gradle.org/4.6/userguide/command_line_interface.html#sec:command_line_warnings

This is a sample project I used to reproduce this: https://github.com/izeye/spring-boot-throwaway-branches/tree/minimal-rest

Thanks @izeye, here is the warning

Putting annotation processors on the compile classpath has been deprecated and is scheduled to be removed in Gradle 5.0. Please add them to the processor path instead.

We should change our samples and I guess updating Spring Initializr is in order.

izeye commented

@snicoll Sorry, I thought it's due to Spring Boot Gradle plugin but as you said it's due to Lombok. Adding annotationProcessor resolves the problem. Feel free to reuse this issue to update samples if any 😅

@izeye no need to be sorry, if our build generates that warning, we have to fix it!

We only have reference to compileOnly in our documentation so I guess we should make sure we fix the reference in the doc instead.

FYI related/duplicate: #12316

Intellij doesn't yet fully recognize/support annotationProcessor so we are living with the warning. (Plus lombok has its own wrinkles here as the processor is in the same artifact as the annotations.)

@jeffbswope gah, good catch there. I was looking for that issue and couldn't find it back.

@wilkinsona what do you think? If Gradle is spitting a warning, I guess it's kind of a weird we document that behaviour in the doc isn't it?

@snicoll Our recommendation is correct to avoid a warning when using Gradle 4.6 or later. It's also needed to allow Boot's Gradle plugin to correctly detect the presence of the configuration processor. Arguably, that's a breaking change in a minor release of Gradle but there's not much we can do about it. It's unfortunate that IntelliJ's Gradle integration cannot keep pace with Gradle's rate of (breaking) change but there's not much we can do about that either. This is the sort of thing that people need to be aware when choosing Gradle as their build tool. I don't think it's our place to try to do anything about the rough edges.

I missed the annotationProcessor one. All good then.