Empty Java source files (or all commented or just not containing a class with the same name) are detected as stale source files by Apache Maven Compiler Plugin, so modules containing such files get unnecessarily recompiled every single time.
This plugin adds an enforcer rule to detect and ban such files.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.5.0</version>
<dependencies>
<dependency>
<groupId>io.github.shitikanth</groupId>
<artifactId>enforcer-rules</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>enforce-java-rules</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<banEmptyJavaFiles/>
</rules>
</configuration>
</execution>
</executions>
</plugin>