kratos0718 commented on PR #317:
URL:
https://github.com/apache/maven-source-plugin/pull/317#issuecomment-5322850944
Closing this — the resource-root refactor on `master` has already fixed the
underlying problem, so the change is no longer needed.
`createArchiver()` now reads:
```java
projectManager
.getEnabledSourceRoots(project, ProjectScope.MAIN,
Language.RESOURCES)
.map(SourceRoot::directory)
.filter(directory ->
directory.endsWith("maven-shared-archive-resources"))
```
`SourceRoot.directory()` returns `java.nio.file.Path` (`public default
java.nio.file.Path directory();` in `maven-api-core`), so that `endsWith` is
**`Path.endsWith`**, not `String.endsWith`. `Path.endsWith` compares complete
name elements, which is exactly the last-segment match this PR was adding.
Confirmed the difference rather than assuming it:
| path | `String.endsWith` | `Path.endsWith` |
|---|---|---|
| `/project/target/maven-shared-archive-resources` | true | true |
| `/var/lib/tmp-maven-shared-archive-resources-extra` | false | false |
| `/var/lib/maven-shared-archive-resources-backup` | false | false |
| `/home/x/my-maven-shared-archive-resources` | **true** | **false** |
Worth noting for #307: the two examples in that issue (`…-extra`,
`…-backup`) would not actually have matched even under `String.endsWith`, since
the suffix comes after the target text. The real false positive was the
*prefix* case in the last row — a directory such as
`my-maven-shared-archive-resources`. Either way `Path.endsWith` handles it, so
**#307 can be closed as fixed by the refactor**.
Thanks for the review on this one — the inlining note was right and I've
applied the same preference since.
--
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]