A project was using gradle wrapper 4.6 and I had to updated it to 5.0 because my pc has java 11 installed.
When using gradlew 4.6 with java 8 build was ok.
After upgrading to 5.0 and running it with java 11 (both gradle wrapper 5.0 and installed gradle 6.5) keeps throwing the following error:
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\MyProject\build.gradle' line: 52
* What went wrong:
A problem occurred evaluating root project 'my_project'.
> Failed to apply plugin [id 'org.gradle.java']
> Could not create task ':api:compileJava'.
> class org.gradle.api.internal.tasks.DefaultTaskInputPropertyRegistration cannot be cast to class org.gradle.api.tasks.TaskInputs (org.gradle.api.internal.tasks.DefaultTaskInputPropertyRegistration and org.gradle.api.tasks.TaskInputs are in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader @26653222)
The line in build.gradle that is generating the error is
configure(subprojects - [project(':event')]) { subProject ->
apply plugin: 'java' // <= this line 52
apply plugin: ...
...
}
It is a multiproject gradle project and build.gradle is the root
It doesn't matter which gradle command or task I run, I keep getting the same error.
UPDATE
Works with gradle up to 4.10. 5.0 starts failing.
https://docs.gradle.org/5.0/userguide/upgrading_version_4.html says
The Java Library Distribution Plugin is now based on the Java Library Plugin instead of the Java Plugin. While it applies the Java Plugin, it behaves slightly different (e.g. it adds > the API configuration). Thus, make sure to check whether your build behaves as expected after upgrading.
Still don't know what it means and what I'm supposed to do with that
UPDATE 2 (Laksitha Ranasingha comment)
Tried in gradle 5.0, build.gradle rewriting the plugins definition:
configure(subprojects - [project(':event')]) { subProject ->
plugins { // <= line 52
id 'java'
...
}
...
}
Results in the following error:
FAILURE: Build failed with an exception.
Where: Build file 'C:\MyProjects\build.gradle' line: 52
What went wrong: A problem occurred evaluating root project 'myproject'.
Could not find method plugins() for arguments [build_1pjmxtxk8zv5w7chejrs1s08b$_run_closure2$_closure7@73b72d7e] on project ':api' of type org.gradle.api.Project.
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0. Use '--warning-mode all' to show the individual deprecation warnings. See https://docs.gradle.org/5.0/userguide/command_line_interface.html#sec:command_line_warnings
CONFIGURE FAILED in 0s