0

In my project I'm using the spring-boot-configuration-processor to generate configuration metadata, which can be helpful at setting fields in @ConfigurationProperties marked classes from .properties files. As build system I use Gradle.

The configuration with JavaDoc in class looks like this:

@Configuration
@ConfigurationProperties(prefix = "user-config")
public class UserSettings {
    /**
     * User name.
     */
    private String name;

    // getters & setters
}

And I import spring-boot-configuration-processor dependency in Gradle like this:

annotationProcessor group: 'org.springframework.boot', name: 'spring-boot-configuration-processor'

The problem is that IntelliJ IDEA can't find generated file spring-configuration-metadata.json, which is putted into folder /build/classes/java/main/META-INF when executing build task from Gradle.

I did some research, and found out that IDEA uses out/production/classes path for production output, but Gradle uses build/classes/java/main path.

Then I came to this SO question, where I found a solution: https://stackoverflow.com/a/55516113/8521177. As pointed there, there are two solutions:

  1. Configure the Spring Boot Annotation Processor manually in IDEA (which is unacceptable, because it would force to do so everyone, who works in my project)
  2. Set IDEA output path to the same as Gradle path as pointed in this answer: https://stackoverflow.com/a/46420842/8521177, so IDEA will find the spring-configuration-metadata.json generated metadata file.

And the another is to put generated file in src/main/resources/META-INF manually and deploy the app with the file in this folder.

The second solution is worked out, but then in the same answer in comments I saw the @CrazyCoder's response - Intellij - set default output path to gradle output, which is saying that gradle idea is obsolete and the one should use 'delegate' option in IDEA. I turned on this option, and IDEA now produces output in the same folder as Gradle do, but IDEA again can't find generated metadata file, since output path again is set to out/.

So, what is the right solution to make IDEA recognize this generated file, considering that I don't want to force user do something manually?

P.S. - Also, I have the following automatically added source path: build/sources/annotationProcessor/java/main. I don't know what is it and where it came from, the folder is empty, but can be there solution with it? Maybe if I can make spring boot configuration processor produce generated file in this folder?

UPD: I use IntelliJ IDEA 2019.1.3 (Ultimate Edition), Gradle 5.4.1, Spring Boot 2.1.5.

TwITe
  • 400
  • 2
  • 14
  • Perhaps the exact versions of IntelliJ and Gradle you are using would help people respond more accurately. – adarshr Jun 07 '19 at 11:00
  • @adarshr versions added – TwITe Jun 07 '19 at 11:04
  • `but IDEA again can't find generated metadata file, since output path again is set to out/.` this looks like a bug. With this option enabled the Gradle's output path should be used. What output path do you see in Project Structure | Modules | Paths | **Output path**? Can you show a sample project? Try also using Gradle 5.1.1 version. – Andrey Jun 10 '19 at 16:57

0 Answers0