Building ThinWARs with Gradle

UPDATE: As it turns out the two POM files (javaee-api 8.0) (microprofile 1.3) consumed by the build files shown here are not real BOMs. A POM is considered a BOM if it defines a <dependencyManagement> block which neither of these files do. They are just regular POM files for which the regular dependency resolution mechanism works out of the box. This means there's no strict requirement for building ThinWARs with Gradle 5.0, you can use earlier versions too. The Gradle build file has been updated to reflect this change however the screencast remains unchanged.

Java Champion Adam Bien has advocated for some time that when building Java web applications one should aim for designing ThinWARs, a technique that reduces build configuration to its bare minimum. In this post I'll show how you can build a ThinWAR using Gradle 5.0 as this release adds support for consuming BOMs without requiring an external plugin. After bootstrapping a sample project using Adam's thinWAR maven archetype I manually created an equivalent Gradle build file.

Here's the Maven POM once tweaked to have Microprofile as an additional dependency (still within Adam's ThinWAR rules)

<project xmlns="" xmlns:xsi=""

And here is the equivalent Gradle build file

apply plugin: 'war'

group = 'com.acme'
version = '1.0-SNAPSHOT'
sourceCompatibility = '1.8'
targetCompatibility = '1.8'

repositories {

dependencies {

war {
    archiveFileName = 'sample.war'

As it turns out the Gradle build file is thinner than it's Maven counterpart and it also produces a smaller WAR file. The following video shows the two builds in action

Keep on coding!

Liked it? Take a second to support aalmiray on Patreon!
Become a patron at Patreon!


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

ˆ Back To Top