Search code examples
gradle-kotlin-dsl

Unresolved reference war.getWebAppDir()


In my project I apply the WAR plugin and have call war.getWebAppDir(). In Gradle 4.10.2 which has kotlin DSL 1.0-rc-6 that call works fine. But in Gradle 5.0-rc-3 which has Kotlin DSL 1.0.3 that call fails with the message Unresolved reference : getWebAppDir


Solution

  • I asked this question on the Gradle-Kotlin-dsl github site. It was answered by Paul Merlin.

    Gradle 5 introduced accessors for tasks. So now war within the tasks {} block resolves to tasks.war which is the War task, instead of resolving to project.war which is the WarPluginConvention that has this webAppDir property. This can be discovered by either navigating to the source of webAppDir from your IDE, or printing war to get to know what it is. You should in your tasks {} block update your old 4.10.2 war.getWebAppDir() calls to the 5.0 way project.war.getWebAppDir().