Search code examples
spring-bootgradlewar

How can I create a gradle task to generate exploded war with Sprint boot "bootWar" plugin?


I use the "org.springframework.boot" plugin and use the bootWar task to generate a war file of my spring boot project. I would like to have a task that creates an exploded version of this war file.

The standard way to do that with the 'war' plugin is :

task explodedWar(type: Sync) {
    into "${war.archivePath.parentFile.getAbsolutePath()}/exploded/${war.archivePath.name}"
    with war
}

How can i do the same thing with the spring-boot/bootWar plugin?


Solution

  • Try with:

    task explodeBootWar(type: Sync) {
        dependsOn bootWar
        into "$buildDir/boot_war_exploded"
        from project.zipTree(bootWar.archiveFile)
    }
    

    You can use the with method on the normal war task because it is basically just a copySpec. However, the bootWar task does some additional things, so you have to build and unzip the actual archive.