Why won't Gradle subproject upgrade?

128 Views Asked by At

I have the following existing structure

repo
|--orchestration
   |--build.gradle
   |--settings.gradle
   |--gradle
   |  |--7.5.1
   |--engine
   |  |--build.gradle
   |  |--gradle
   |  |  |--6.7.1
   |--process
   |  |--build.gradle
   |  |--gradle
   |  |  |--6.1.1
   |  |  |--7.4

furthermore

orchestration % which gradle
/opt/homebrew/bin/gradle
orchestration % gradle --version
------------------------------------------------------------
Gradle 7.5.1
------------------------------------------------------------
orchestration % ./gradlew --version
------------------------------------------------------------
Gradle 7.5.1
------------------------------------------------------------
cd engine
engine % ./gradlew --version
------------------------------------------------------------
Gradle 6.7.1
------------------------------------------------------------
cd ../process 
process % ./gradlew --version
------------------------------------------------------------
Gradle 6.1.1
------------------------------------------------------------

Now, The Problem

process % gradle wrapper --gradle-version 7.5.1

FAILURE: Build failed with an exception.

* What went wrong:
Task 'wrapper' not found in project ':process'.

cd ../engine
engine % gradle wrapper --gradle-version 7.5.1

FAILURE: Build failed with an exception.

* What went wrong:
Task 'wrapper' not found in project ':engine'.

What is going on?

  • why was I able to upgrade sub-projects in the past?
  • why does Gradle so often give unhelpful diagnostics?
    • often misleading, where I waste hours on a wild goose chase...
  • I ran with --scan... after much time investigating... still no insight...
2

There are 2 best solutions below

3
On

Let me "revise and extend" my previous answer... I can't say why the upgrade may have broken the wrapper task, but the Gradle Wrapper docs explain how to recreate it from scratch:

$ gradle wrapper
> Task :wrapper

BUILD SUCCESSFUL in 0s
1 actionable task: 1 executed
0
On

Regarding the error reporting, the fundamental error is the second one reported, that project 'engine' doesn't have a task 'wrapper' defined. You have to sort of squint and ignore the (really redundant) first error, which doesn't say anything constructive.

Further reading of the docs makes me realize that 'wrapper' is special (see later answer), and the way to restore it is documented.

But the error reporting is a bit jargonny and obscure. It would be nice if Gradle had an option to expand the explanation on the task-not-found error by listing all the places it did look for the task definition, and, special case for missing 'wrapper' task, the documented 2 line fix to restore it when it gets lost. Also nice if there were a way to suppress the 'build terminated by exception' if a prior, more specific, error has already been logged.