gnodet commented on PR #3448:
URL: https://github.com/apache/maven-surefire/pull/3448#issuecomment-7394176427
### MavenLauncher.java - isMaven4() method (lines 421-438)
✅ **Solid implementation with good defensive coding**
The Maven 4 detection logic is well-implemented:
- ✅ Handles missing/empty `maven.home` property
- ✅ Checks if lib directory exists before listing
- ✅ Null-safe (handles `libDir.list()` returning null)
- ✅ Uses appropriate heuristic (maven-cli module is specific to Maven 4+)
- ✅ Well-documented as a temporary workaround
**Minor optimization (optional):**
You could return early when a match is found:
```java
for (String file : files) {
if (file.startsWith("maven-cli-")) {
return true;
}
}
return false;
```
However, the performance difference is negligible and the current code is
perfectly fine.
**Edge case consideration:**
If someone has a non-Maven jar file starting with "maven-cli-" in the lib
directory, it would trigger false positive detection. This seems extremely
unlikely in practice, and the workaround nature of this code makes it
acceptable.
_Claude Code on behalf of Guillaume Nodet_
--
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]