You’ll need to be a bit more explicit in Kotlin. Get war from tasks and use the set method since archiveFileName is a Property<String>, not just a String.
This is not working for gradle-7.1.1
It DOES create an Artifact that you can build → build artifact
But it keeps on building the rootProject.name.war by default!
IntelliJ IDEA 2021.2 (Ultimate Edition)
Build #IU-212.4746.92, built on July 27, 2021
Runtime version: 11.0.11+9-b1504.13 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 10 10.0
GC: ParNew, ConcurrentMarkSweep
Memory: 4012M
Cores: 12
Non-Bundled Plugins: Batch Scripts Support (1.0.12)
Kotlin: 212-1.5.10-release-IJ4746.92
value and set do the same, just one returns the property for method call chaining. Whether war or bootWar task needs to be configured depends on whether it is the normal war plugin or the spring boot plugin that defines it.