kratos0718 commented on issue #307:
URL:
https://github.com/apache/maven-source-plugin/issues/307#issuecomment-5267307461
I think this may already be resolved on `main`.
The snippet in the description operates on a `String`
(`r.getDirectory().endsWith(...)`), but `createArchiver()` now maps through the
Maven 4 API:
```java
projectManager
.getEnabledSourceRoots(project, ProjectScope.MAIN,
Language.RESOURCES)
.map(SourceRoot::directory)
.filter(directory ->
directory.endsWith("maven-shared-archive-resources"))
```
`SourceRoot::directory` returns a `java.nio.file.Path` (confirmed by
`addDirectory(Archiver, Path, String[], String[])`), so this is
`Path.endsWith`, which compares whole path **segments** rather than characters
— which is exactly the exact-filename matching the issue asks for.
Checked against the cases:
| path | `Path.endsWith` | `String.endsWith` |
|---|---|---|
| `/path/tmp-maven-shared-archive-resources` | **false** | true |
| `/var/my-maven-shared-archive-resources` | **false** | true |
| `/project/target/maven-shared-archive-resources` | **true** | true |
| `/var/lib/maven-shared-archive-resources-backup` | false | false |
So the prefixed directories that would have falsely matched under
`String.endsWith` no longer match, while the legitimate directory still does.
One small note on the examples in the description:
`/path/tmp-maven-shared-archive-resources-extra` and
`/var/lib/maven-shared-archive-resources-backup` would not have matched even
with the old `String.endsWith`, since they end in `-extra` / `-backup`. The
genuine false-positive shape was a **prefixed** last segment, as in the first
two rows above.
Unless I am missing a code path that still does string matching, this looks
safe to close. Happy to send a test pinning the behaviour if you would like it
guarded against regression.
--
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]