How to let Eclipse with Gradle auto generate spring-configuration-metadata file?

Viewed 282

I have been trying many ways but not sure how can I point Eclipse to the correct location, or for Eclipse to auto generate spring-configuration-metadata file so that my application.properties can take advantage of the auto-completion. From most of the example online, it is using Maven and stated that spring-configuration-metadata will be generated and located in target\... location but it's not the same as Gradle

I am using Gradle 6.6.1 with Eclipse 2020-09.

Here's my build.gradle

plugins {
    id 'java'
    id 'eclipse'
    id 'org.springframework.boot' version '2.3.4.RELEASE'
    id 'io.spring.dependency-management' version '1.0.10.RELEASE'
    id 'org.openjfx.javafxplugin' version '0.0.9'
}

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'

configurations {
    compileOnly {
        extendsFrom annotationProcessor
    }
}

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter'
    compileOnly 'org.projectlombok:lombok'
    developmentOnly 'org.springframework.boot:spring-boot-devtools'
    annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
    annotationProcessor 'org.projectlombok:lombok'
    testImplementation('org.springframework.boot:spring-boot-starter-test') {
        exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
    }
}

javafx {
    version = '11'
    modules = [ 'javafx.controls', 'javafx.fxml' ]
}

test {
    useJUnitPlatform()
}

springBoot {
    buildInfo()
}

eclipse {
    autoBuildTasks bootBuildInfo
}

If I were to run Gradle build, I can see the file generated inside the build directory or the compiled jar.

project-dir\build\classes\java\main\META-INF\spring-configuration-metadata.json

This is what is shown in Eclipse though

application-properties-hint

If I were to click to create the metadata as shown in the image above, Eclipse will create additional-spring-configuration-metadata.json file under project-dir\src\main\resources\META-INF which will then now, gives me the auto-completion

additional-spring-configuration-metadata

But if I were to create new property, it will complain again as the metadata is not re-generated (I suppose)

not-auto-generated

So I have to manually re-generate it. So my question is, how do I set it up, so that it can be auto generated in Eclipse each time it gets refresh/updated?

Thanks!

0 Answers
Related