spring-io / initializr

A quickstart generator for Spring projects
https://start.spring.io
Apache License 2.0
3.43k stars 1.73k forks source link

Allow annotation processors to be made available to tests when using Gradle #1380

Open wilkinsona opened 1 year ago

wilkinsona commented 1 year ago

Gradle has more finely grained classpath separation than Maven, particularly for annotation processors. While generally a good thing, it makes it more cumbersome when you want to use an annotation processor in both your main code and in your tests. It would be useful if an annotation processor dependency could indicate that it should be available for use with test code as well as main code. I don't think we'd want to do this for all annotation processors (for example, I can see no need to use spring-boot-configuration-processor in tests) so I think it would need to be opt-in on a per-dependency basis. Lombok is one example of an annotation processor that may be useful in tests.

prithvitewatia commented 1 year ago

@wilkinsona do we need something like

dependencies {
    compileOnly 'org.projectlombok:lombok:1.18.22'
    annotationProcessor 'org.projectlombok:lombok:1.18.22'

    testCompileOnly 'org.projectlombok:lombok:1.18.22'
    testAnnotationProcessor 'org.projectlombok:lombok:1.18.22'
}
plat2eau commented 7 months ago

As per Issue 1379 we don't need to add the annotation processors to both compileOnly and annotationProcessor. We can do the same for testCompileOnly and testAnnotationProcessor