title: How to replace yaml file properties with default value?
body: <p>I have the following kts Gradle configuration of the web application:</p>
  
  <pre><code>tasks.withType&lt;ProcessResources&gt; {
          filesMatching("application-test.yaml") {
              expand(project.properties)
          }
      }
  </code></pre>
  
  <p>The <code>application-test.yaml</code> looks like</p>
  
  <pre><code>spring:
    datasource:
      hikari:
        maximum-pool-size: 25
      username: ${DB_USERNAME:user}
      password: ${DB_PASSWORD:password}
      url: ${DB_CONNECT_URL:jdbc:postgresql://localhost:5432/database}
  </code></pre>
  
  <p>When I execute the command:</p>
  
  <pre class="lang-sh prettyprint-override"><code>./gradlew clean test -PDB_PASSWORD=password -PDB_USERNAME=error_user -PDB_CONNECT_URL=jdbc:postgresql://localhost:5432/database
  </code></pre>
  
  <p>There is the error in the groovy script:</p>
  
  <pre><code>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.
  </code></pre>
  
  <p>But if I remove default values, all is ok.
  I tried to</p>
  
  <ul>
  <li>replace delimiter with @@/'@@'</li>
  <li>use \${} instead of ${}</li>
  <li>use the groovy code in yaml: <code>${DB_PASSWORD?!password}</code></li>
  </ul>
  
  <p>One thing that helped me is kts code to get and replace properties in <code>build.gradle.kts</code> with <code>filter&lt;ReplaceTokens&gt;</code>.</p>
  
  <p>Maybe somebody knows another way?</p>