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/04 14:12:48 UTC
[I] WarUtils.isRelated() has inverted equality checks for version, type, classifier, scope [maven-war-plugin]
elharo opened a new issue, #619:
URL: https://github.com/apache/maven-war-plugin/issues/619
## Bug Description
`WarUtils.isRelated()` at `src/main/java/org/apache/maven/plugins/war/util/WarUtils.java` lines 69-80 has inverted equality checks. The method returns `false` when `version`, `type`, `classifier`, or `scope` are **equal** between the artifact and the dependency — the opposite of what's intended.
The method should return `false` only when these attributes **differ**. As written, the method only returns `true` if every one of these four attributes differs while groupId/artifactId match.
## Impact
This makes `registerTargetFileName()` in `WebappStructure` effectively broken: a dependency will never match its artifact when any of these attributes coincide, and could match the wrong dependency when they all differ.
## Code
```java
if (Objects.equals(artifact.getVersion(), dependency.getVersion())) {
return false; // BUG: should return false when NOT equal
}
if (Objects.equals(artifact.getType(), dependency.getType())) {
return false;
}
if (Objects.equals(artifact.getClassifier(), dependency.getClassifier())) {
return false;
}
if (Objects.equals(artifact.getScope(), dependency.getScope())) {
return false;
}
```
## Expected behavior
Each `if` block should use `!Objects.equals(...)` so that `false` is returned only when the values differ.
--
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