0

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...
Eric Kolotyluk
  • 1,958
  • 2
  • 21
  • 30

2 Answers2

0

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.

BobHy
  • 1,575
  • 10
  • 23
0

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
BobHy
  • 1,575
  • 10
  • 23
  • When I run `gradle wrapper` it fails with "Task 'wrapper' not found in project ':process'." – Eric Kolotyluk Oct 05 '22 at 13:57
  • Okay, I was finally able to get `gradle wrapper` to work in my `process` project, but I don't know why. I was resetting a log of things, especially IntelliJ, but then it just worked one time. However, I cannot do the same in my `engine` project which fails with "Task 'wrapper' not found in project ':engine'." – Eric Kolotyluk Oct 05 '22 at 15:12
  • From what I understand of Gradle (little enough!) the Wrapper task and Gradle command are implemented in folders outside your particular project subdirectories. So they can be removed and reinstalled from scratch without affecting your project config (maybe?) I'd recommend completely removing gradle and reinstalling it from scratch, using SDKMAN! if you can, as described at https://gradle.org/install/. You mention IntelliJ IDE, which I don't use. If that's how you got Gradle in the first place, I'd recommend removing and reinstalling the IDE as well. – BobHy Oct 11 '22 at 14:37