You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
forceCreation has no effect when skipIfEmpty is true #560
When both skipIfEmpty=true and forceCreation=true are set, forceCreation has no effect. The execute() method checks skipIfEmpty first and returns early without calling createArchive(), even though the user explicitly requested forced creation.
Location
AbstractJarMojo.java:303-306:
publicvoidexecute() throwsMojoException {
if (skipIfEmpty && isEmpty(getClassesDirectory())) {
getLog().info(String.format("Skipping packaging of the %s.", getType()));
} else {
...
}
}
Problem
If a user configures both skipIfEmpty=true and forceCreation=true, the intent is presumably: "skip if empty, unless force is requested." However, skipIfEmpty always takes priority. forceCreation is only evaluated inside createArchive() which is never reached when the content directory is empty.
The @Parameter documentation for forceCreation (lines 114-124) describes it as forcing recreation of the JAR even if inputs have not changed. A user might reasonably expect that forceCreation=true would override skipIfEmpty=true and still produce the JAR.
Suggested fix
The execute() method should only skip when both skipIfEmpty=true and forceCreation=false, i.e.:
if (skipIfEmpty && !forceCreation && isEmpty(getClassesDirectory())) {
It's not obvious to me that forceCreation should override skipIfEmpty. Either way though we should document this behavior. I'm inclined to stick with the existing behavior and document it.
Activity
elharo commentedon Jul 23, 2026
It's not obvious to me that forceCreation should override skipIfEmpty. Either way though we should document this behavior. I'm inclined to stick with the existing behavior and document it.
AzazelSensei commentedon Aug 14, 2026
#585
Document that skipIfEmpty wins over forceCreation
Document that skipIfEmpty wins over forceCreation (apache#585)