You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "elharo (via GitHub)" <gi...@apache.org> on 2026/07/19 16:12:27 UTC
[I] forceCreation has no effect when skipIfEmpty is true [maven-jar-plugin]
elharo opened a new issue, #560:
URL: https://github.com/apache/maven-jar-plugin/issues/560
## Bug
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`:
```java
public void execute() throws MojoException {
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.:
```java
if (skipIfEmpty && !forceCreation && isEmpty(getClassesDirectory())) {
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] forceCreation has no effect when skipIfEmpty is true [maven-jar-plugin]
Posted by "AzazelSensei (via GitHub)" <gi...@apache.org>.
AzazelSensei commented on issue #560:
URL: https://github.com/apache/maven-jar-plugin/issues/560#issuecomment-5297533260
https://github.com/apache/maven-jar-plugin/pull/585
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] forceCreation has no effect when skipIfEmpty is true [maven-jar-plugin]
Posted by "elharo (via GitHub)" <gi...@apache.org>.
elharo closed issue #560: forceCreation has no effect when skipIfEmpty is true
URL: https://github.com/apache/maven-jar-plugin/issues/560
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] forceCreation has no effect when skipIfEmpty is true [maven-jar-plugin]
Posted by "elharo (via GitHub)" <gi...@apache.org>.
elharo commented on issue #560:
URL: https://github.com/apache/maven-jar-plugin/issues/560#issuecomment-5057590064
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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org