Gradle: Could not find method providedCompile()

providedCompile is shipped with war plugin. So you need to add:

plugins {
  // ...
  id 'war'
}

You can get this error if you have a higher version of Gradle installed. For example you have:

gradle --version

giving

Gradle 5.0

but the project expects Gradle 2.10 or some other lower version of Gradle.

To solve this first try to use Gradle wrapper ./gradlew (if included with project) instead of locally installed gradle. Or install a correct version of gradle and make it available using path variable.