0

I have the following kts Gradle configuration of the web application:

tasks.withType<ProcessResources> {
        filesMatching("application-test.yaml") {
            expand(project.properties)
        }
    }

The application-test.yaml looks like

spring:
  datasource:
    hikari:
      maximum-pool-size: 25
    username: ${DB_USERNAME:user}
    password: ${DB_PASSWORD:password}
    url: ${DB_CONNECT_URL:jdbc:postgresql://localhost:5432/database}

When I execute the command:

./gradlew clean test -PDB_PASSWORD=password -PDB_USERNAME=error_user -PDB_CONNECT_URL=jdbc:postgresql://localhost:5432/database

There is the error in the groovy script:

Failed to parse template script (your template may contain an error or be trying to use expressions not currently supported): startup failed:
SimpleTemplateScript6.groovy: 9: unexpected token:  @ line 9, column 40.

But if I remove default values, all is ok. I tried to

  • replace delimiter with @@/'@@'
  • use \${} instead of ${}
  • use the groovy code in yaml: ${DB_PASSWORD?!password}

One thing that helped me is kts code to get and replace properties in build.gradle.kts with filter<ReplaceTokens>.

Maybe somebody knows another way?

Eugene Ustimenko
  • 322
  • 4
  • 16

0 Answers0