I’m using Gradle 6.0.1 with Kotlin DSL. My build script uses the
war plugin. How can I change the name of the war file built?
An older answer to a similar question (see https://discuss.gradle.org/t/how-do-i-change-the-name-of-the-war-file-being-built/9223/2) uses Groovy. I’m not sure how to achieve the same effect when using Kotlin.
Tried the following, but it did not work.
archiveFileName = "something.war"
You’ll need to be a bit more explicit in Kotlin. Get
tasks and use the
set method since
archiveFileName is a
Property<String>, not just a
This is not working for
It DOES create an Artifact that you can build → build artifact
But it keeps on building the
rootProject.name.war by default!
java.sourceCompatibility = JavaVersion.VERSION_11
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
Non-Bundled Plugins: Batch Scripts Support (1.0.12)
This way you can solve it:
set do the same, just one returns the property for method call chaining. Whether
bootWar task needs to be configured depends on whether it is the normal
war plugin or the spring boot plugin that defines it.