How do I generate build-info.properties in the IntelliJ "out" directory on debug/run for a Spring Boot project?

Don Rhummy :

In my build.gradle, I have added spring build info:

springBoot {
    mainClass = "${springBootMainClass}"

    buildInfo() {
        additionalProperties = [
                name: "${appName}",
                version: "${version}-${buildNumber}",
                time: buildTime()
        ]
    }
}

def buildTime() {
    final dateFormat = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ssZ")
    dateFormat.timeZone = TimeZone.getTimeZone('GMT')
    dateFormat.format(new Date())
}

When I run from the command line, this correctly adds the /META-INF/build-info.properties file into /build/resources/main so that the "/info" endpoint shows the build information in JSON.

When I run from IntelliJ's run/debug button, IntelliJ does not use the /build directory but instead uses the /out directory and also does not run that gradle task, so the /info endpoint has empty JSON.

How can I make it generate that file and put it in the /out directory?

Andrey :

Enable Delegate IDE build/run actions to Gradle option in Settings (Preferences) | Build, Execution, Deployment | Build Tools | Gradle | Runner tab.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=442526&siteId=1