arturobernalg opened a new pull request, #13538:
URL: https://github.com/apache/maven/pull/13538

   ### What and why
   
   The Javadoc of `Source.resolve(String)` says that file sources resolve 
against their parent directory, and that both forward and back slashes are 
handled as separators. That is what `ModelSource.resolve(ModelLocator, String)` 
does (it resolves against the parent directory and normalises both kinds of 
slashes). `Source.resolve(String)` of `Sources.PathSource` and 
`BuildPathSource` calls `path.resolve(relative)` on the path of the source 
itself, so for a file such as `/tmp/x/pom.xml`, `resolve("child.xml")` gives 
`/tmp/x/pom.xml/child.xml`, and a backslash is an ordinary character of the 
name on Linux. There is no issue for it.
   
   ### How
   
   Only the Javadoc changes: it now says that a path source resolves against 
its own path, so it is meant to be used on a directory, that the separators are 
those of the platform and `..` is resolved lexically in the result, and it 
points to `ModelSource.resolve(ModelLocator, String)` for the resolution 
against the parent directory. The behaviour is not changed, because 
`SourcesTest` and callers rely on it. If the maintainers prefer the documented 
behaviour, that would be a behaviour change for a separate PR.
   
   ### Tests
   
   `SourcesTest#testPathSourceResolvesAgainstItsOwnPath` pins the documented 
behaviour for a file (`/tmp/x/pom.xml` with `child.xml` and with 
`../other/pom.xml`). `SourcesTest` passes (10 tests), three runs in a row, 
spotless is clean and the Javadoc of `maven-api-core` builds. I did not run the 
integration tests.
   
   ---
   
   To make clear that you license your contribution under
   the [Apache License Version 2.0, January 
2004](https://www.apache.org/licenses/LICENSE-2.0)
   check one of the following:
   
   - [ ] I hereby declare this contribution to be licensed under the [Apache 
License Version 2.0, January 2004](https://www.apache.org/licenses/LICENSE-2.0)
   - [ ] I hereby declare that I have filed an [Apache Individual Contributor 
License Agreement](https://www.apache.org/licenses/icla.pdf).
   


-- 
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]

Reply via email to