apache / apache/maven-war-plugin
WarUtils.isRelated() has inverted equality checks for version, type, classifier, scope
- Dominant language
- Java
- Stars
- 50
- Forks
- 97
- Avg merge
- 16h 49m
- Merged PRs (30d)
- 3
Description
## 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.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in src/main/java/org/apache/maven/plugins/war/util/WarUtils.java at WarUtils.isRelated(), lines 69-80, and review how registerTargetFileName() in WebappStructure depends on it. Verify that the method returns false when version, type, classifier, or scope differ, and can match when those attributes are equal.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 86/100