Beginner Error Error in building wrapper

build.gradle file as follows :
task hello {
doLast {
println “Hello world !”
task wrapper (type: Wrapper){
gradleVersion = ‘7.4.2’
archiveBase = ‘GRADLE_USER_HOME’
archivePath = ‘wrapper/dists’
distributionBase = ‘GRADLE_USER_HOME’
distributionPath = ‘wrapper/dists’
distributionUrl = ‘’
the folowing error occurred in the build:

gradle wrapper
FAILURE: Build failed with an exception.

  • Where:
    Build file ‘D:\edu\edu_gradle\build.gradle’ line: 6

  • What went wrong:
    A problem occurred evaluating root project ‘edu_gradle’.

Cannot add task ‘wrapper’ as a task with that name already exists.

  • 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.

And what is your question?
The error message is pretty speaking, isn’t it?
You are trying to add a task named wrapper while there already is a task with that name.
You probably want to instead configure the existing task using tasks.wrapper { ... }.
Besides that, most of these properties you should probably not configure but use the defaults and also you shouldn’t use the -all distribution.

Actually my recommendation would be to use Kotlin DSL right away also, instead of Groovy DSL.
You will save much headache and have amazingly better IDE support if you use a proper IDE like IntelliJ. :slight_smile: