I am working in grails, which is also built on spring boot. Alike you, I wanted to pass properties from my gradle file, but for me, it was from build.gradle and to be used during junit execution.
Note: for a list of ways to load application.properties, not gradle.properties, you can have a look here. Just to make sure we are on the same page, if you are trying to version the application you are using (possibly display it to some user), you should be setting it in application.properties not gradle.properties. If you want the latter, you need to replace the properties in the file you plan on using with gradle, and change out the value, which is more complex.
Regardless, here is one approach I have taken that lets me inject properties during my test execution, from build.gradle.
test {
def defaultLoginUrl = System.getProperty("testing.defaults.loginUrl")
systemProperty "testing.defaults.loginUrl", defaultLoginUrl?: "https://localhost:8443/"
}
And in my Java code:
public String getLoginUrl() {
return System.getProperty("testing.defaults.loginUrl")
}
Lastly, if you want to access the file as an input stream, you should place it in the resources directory, and use the context to fetch it. However, application.properties is, in my opinion from reading your post, exactly what you want. This concept is similarly addressed in the question you quoted, as loading properties from a build file is not common practice when you are ready to deploy it.