I have a simple statement being printed to say that all tasks have been completed with a timestamp in gradle. We've implemented like the following:
gradle.getTaskGraph().whenReady { graph ->
graph.getAllTasks().last().doLast {
This all seems to run prefectly fine from the command line but in intellij when loading gradle for the first time the build breaks due to
* Exception is: java.util.NoSuchElementException: Cannot access last() element from an empty List
This stops the "External Libraries" from being populated and therefore intellisense and syntax highlighting is also stopped. It also stops the Gradle task list being populated in the Gradle view.
If I delete the block of code for printing this statement then everything works as expected, and if I reintroduce the code then the "Load Gradle Changes" will fail with the same error except that I can now run any of the gradle tasks with no issue.
Am I implementing the getTaskGraph().whenReady incorrectly? If I debug the code (after doing the work around described above) I can see the list of tasks in the graph object. It just seems to be the initial load that intellij isn't liking.