0

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

Rahul Khimasia
  • 473
  • 12
  • 24

2 Answers2

0

I am using gradle 4.10.2 and the call war.getWebAppDir() doesn't work in my case. The build fails saying no property found. Not sure why it works in your case.

Call :

logger.info " web app dir is : ${war.getWebAppDir()}"

Error:

Could not find method getWebAppDir() for arguments [] on task ':war' of type org.gradle.api.tasks.bundling.War

After a quicksearch I found getWebAppDir is a property provided by the WarPluginConvention and not the WAR plugin itself. So just called getWebAppDir() and everything seems to be working in my case.

Call:

logger.info " web app dir is : ${getWebAppDir()}"

The output :

web app dir is : D:\Practice\Gradle\GradleInAction\todo-webapp-customized\webfiles

I'm not sure if that's at all related to Kotlin DSL as it clearly says in the failure logs that its unable to locate that property in WAR task.

So trying to call it via the war task would give error.

Could you try enabling logs and stacktrace and share the same. I'm just in the process of learning gradle, not an expert or even an intermediate. Just trying to learn by helping others learn.

EDIT 1 START

Tried with Gradle 5.0-rc-3. Similar behavior is demonstrated in my case. Same output as above.

EDIT 1 END

Asif Kamran Malick
  • 2,409
  • 3
  • 25
  • 47
0

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().

Rahul Khimasia
  • 473
  • 12
  • 24