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.


NEW: Online Workhop Effective WebApps without Frameworks is also coming to: MUC Airport.

Airport MUC workshops: Web (SPA, PWAs, Offline, Desktop, Mobile) Applications Essentials and Effective Web Applications. No migrations. #usetheplatform

Podcast: airhacks.fm and newsletter: airhacks.news

A book about rethinking Java EE Patterns

Comments:

what about database drivers? modding app server?

Posted by kret11 on February 11, 2019 at 04:05 PM CET #

@kret11,

1. JDBC-drivers never ship with the WAR, they are installed on the server.

2. Appserver configuration either happens on Jenkins, Docker or s2i.

3. However, domain-specific libraries like e.g. Apache POI can be included in the WAR (runtime dependency)

big thanks for your question!

--adam

Posted by Adam Bien on February 12, 2019 at 01:42 AM CET #

Post a Comment:
  • HTML Syntax: NOT allowed
Online Workshops
realworldpatterns.com
...the last 150 posts
...the last 10 comments
License