Difficulties with processResources expansion

(Kai) #1


I am using Gradle 4.9 for a pretty fresh project using spring-boot. I wanted to expand a property in my src/main/resources/application.properties file, namely the project.version property.

I am still a learner around Gradle, but there are examples around that should help (I thought).
so I tried first

processResources {
    expand project.properties

But that failed because some files contain dollar-curly-braces notation that must not be treated by expansion, and Gradle SimpleTemplateEngine failed on them. Then I tried to be more specific:

processResources {
  def props = ["version":version]
  filesMatching ('**/application.properties') {
    expand props

This does not longer throw an exception in Gradle, but later in Spring-Boot, because it cannot resolve the ${version} value of the project.version property in application.properties - This looks like the filesMatching clause does not catch the file, it goes into build folders unprocessed. I did not find any help yet on how to make property expansion more verbose, but maybe people can hint me if I made a syntax error or a wrong assumption somewhere?


(Kai) #2

solved. The expand did not work on the property because it was the last line of the property file and a CRLF was missing.


You know why I think Gradle is not mature for production? For issues like this one.

(uklance) #3

Sounds like you’ve found a bug. Any chance you could put together a minimal project which shows the problem? Perhaps with two property files where one has the CRLF and another does not?