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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]