adam bien's blog

KISS your WARs--Skipping the Superfluous 📎

Both apache maven and Java EE heavily rely on (Convention over Configuration). Productive, straight-forward "Don't make me think" ThinWARs, fast builds and deployments, short pom.xml are a result of applying the built-in, sensible defaults.

Your WAR is KISS, if the maven artifactId and:
  1. project folder
  2. name in pom.xml (name is derived from artifactId, so remove it)
  3. WAR name
  4. finalName
  5. and so the JAX-RS URI
are identical.

Also

  1. there are no nice-to-have runtime dependencies
  2. there are no maven plugins declared
  3. there is no pom inheritance
  4. the only provided dependencies are the Java EE / Jakarta EE and MicroProfile API
Example:

<project>
   <modelVersion>4.0.0</modelVersion>
   <groupId>com.airhacks</groupId>
   <artifactId>thinwar</artifactId>
   <version>0.0.1</version>
   <packaging>war</packaging>
   <dependencies>
       <dependency>
           <groupId>javax</groupId>
           <artifactId>javaee-api</artifactId>
           <version>8.0</version>
           <scope>provided</scope>
       </dependency>
       <dependency>
           <groupId>org.eclipse.microprofile</groupId>
           <artifactId>microprofile</artifactId>
           <version>1.3</version>
           <type>pom</type>
           <scope>provided</scope>
       </dependency>        
   </dependencies>
   <build>
       <finalName>thinwar</finalName>
   </build>
   <properties>
       <maven.compiler.source>1.8</maven.compiler.source>
       <maven.compiler.target>1.8</maven.compiler.target>
       <failOnMissingWebXml>false</failOnMissingWebXml>
   </properties>
</project> 

The resulting ThinWAR is KISS and YAGNI, without any Cargo Cult Programming involved.

A conventional ThinWAR project can be directly created with javaee8-essentials-archetype and deployed with wad.sh.

See you at Web, MicroProfile and Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting. Is Munich's airport too far? Learn from home: airhacks.io.