Skip to content
This repository has been archived by the owner on Aug 19, 2020. It is now read-only.

Unresolved reference war.getWebAppDir() #1250

Closed
rahulkhimasia opened this issue Nov 16, 2018 · 4 comments
Closed

Unresolved reference war.getWebAppDir() #1250

rahulkhimasia opened this issue Nov 16, 2018 · 4 comments

Comments

@rahulkhimasia
Copy link

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 file.
But in Gradle 5.0-rc-3 which has Kotlin DSL 1.0.3 that call fails with the message Unresolved reference : getWebAppDir

Expected Behavior

Current Behavior

Context

Steps to Reproduce (for bugs)

Your Environment

  • Build scan URL:
@eskatos
Copy link
Member

eskatos commented Nov 17, 2018

Thank you for the report @rahulkhimasia.

The following works for me with Gradle 5.0-rc-3:

plugins {
    war
}

println(war.webAppDir)
println(war.getWebAppDir())
war {
    println(webAppDir)
    println(getWebAppDir())
}

Could you please provide more detail? A reproducer would be ideal.

@rahulkhimasia
Copy link
Author

rahulkhimasia commented Nov 17, 2018

I have distilled my relevant source code into this file MultiProjectRoot.tar.gz.

Here are the steps you need to execute to reproduce my problem.

  1. tar --extract --gunzip --file MultiProjectRoot.tar.gz
  2. cd MultiProjectRoot
  3. gradle :WarProject1:simpleTask1

The problem is that when war.webAppDir is placed inside a tasks{ } block it does not work in 5-rc-3. But it works without any problem in 4.10.2.

@eskatos
Copy link
Member

eskatos commented Nov 18, 2018

Thanks @rahulkhimasia, I can reproduce now.

Gradle 5 introduced accessors for tasks, meaning in your WarProject1/build.gradle.kts script:

tasks {
    create("simpleTask") {
        println(war.webAppDir)
    }
}

war now resolves to tasks.war which is the War task, instead of resolving to project.war which is the WarPluginConvention that has this webAppDir property. The War task doesn't.

You need to disambiguate as follow:

tasks {
    create("simpleTask") {
        println(project.war.webAppDir)
    }
}

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.

This is expected and part of Gradle 5.0 changes, closing.

@rahulkhimasia
Copy link
Author

Thank you for your explanation Paul. That makes sense. I was able to fix the issue and I have been able to migrate and validate all my other build.gradle.kts scripts from 4.10.2 to 5.0-rc-3. Looking forward to the final 5.0 release.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants