title: Using Gradle property expansion in kotlin/spring boot
body: <p>I am currently building a <code>Kotlin</code>, <code>Spring Boot</code> service using gradle as the build tool. I am attempting to automatically expand properties found in my <code>application.properties</code> file, using the steps found here: </p>
  
  <p><a href="https://docs.spring.io/spring-boot/docs/current/reference/html/howto-properties-and-configuration.html#howto-automatic-expansion-gradle" rel="nofollow noreferrer">https://docs.spring.io/spring-boot/docs/current/reference/html/howto-properties-and-configuration.html#howto-automatic-expansion-gradle</a></p>
  
  <p>My versions are as follows:</p>
  
  <pre><code>- kotlin: 1.1.4-3
  - spring boot: 1.5.6.RELEASE
  - gradle: 3.5.1
  </code></pre>
  
  <p>When I run a <code>./gradlew bootRun</code>, I get the following error:</p>
  
  <pre><code>java.lang.IllegalArgumentException: Could not resolve placeholder 'myServiceName' in value "${myServiceName}"
  </code></pre>
  
  <p>Followed by:</p>
  
  <pre><code>java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via the context: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@510aeb93: startup date [Fri Sep 15 10:59:51 AEST 2017]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@68edf5bb
  </code></pre>
  
  <p><strong>build.gradle:</strong></p>
  
  <pre><code>apply plugin: 'kotlin'
  apply plugin: 'kotlin-spring'
  apply plugin: 'org.springframework.boot'
  
  processResources {
      filesMatching('application.properties') {
          expand(project.properties)
      }
  }
  </code></pre>
  
  <p><strong>gradle.properties:</strong></p>
  
  <pre><code>myServiceName=potato-service
  </code></pre>
  
  <p><strong>application.properties:</strong></p>
  
  <pre><code>info.app.name=${myServiceName}
  </code></pre>
  
  <p>These errors appear after the app has started, and spring is trying to load the property file. </p>
  
  <p>The interesting thing is that if I change the variable that I am trying to substitute in the application.properties, to <code>myServiceName123</code> for example, gradle fails at the processResources stage.</p>