7.0: 'manifest' in 'org.gradle.api.tasks.bundling.Jar' cannot be applied to '(groovy.lang.Closure)`

I started getting this error when I upgraded to gradle 7.0.

I have this in my build.gradle:

jar {
    manifest {
        attributes 'Main-Class': 'com.example.Main'
    }
    from {
        configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
    }
}

And IntelliJ displays this error:

'manifest' in 'org.gradle.api.tasks.bundling.Jar' cannot be applied to '(groovy.lang.Closure)' 

Any idea what this is and how I can fix it?

Does it actually build from the command line, or do you get an error there too?

The build still works from the command line without IntelliJ. So maybe this is an IntelliJ issue?

Is it a message from Gradle when you run from within Intellij, or is it just some IntelliJ highlighting in the build script?

If the latter, I’d say it is an IJ bug and you should report it to JetBrains.
You could also try to invalidate your IJ caches, this often helps if IJ behaves strange in similar ways.

If the former, it could be both and an MCVE would probably be helpful.