0

I'm pretty new to maven and trying to build a code on Windows that works fine in linux. I have 2 local repositories in my pom.xml:

<repositories>
    <repository>
        <id>p2-repo-equinox_3.8.1</id>
        <layout>p2</layout>
        <url>file:///${basedir}/../xyz/abc/repository/</url>
    </repository>
    <repository>
        <id>p2-repo-common</id>
        <layout>p2</layout>
        <url>file:///${basedir}/../xyz/def/repository/</url>
    </repository>
</repositories>

When building, I get the error:

 Internal error: java.lang.RuntimeException: Failed to load p2 repository with ID 'p2-repo-equinox_3.8.1' from location file://D:/maven/myproject/../xyz/abc/repository/: URI has an authority component -> [Help 1]

I found this post, and tried adding a third slash to pass an empty authority component ( file:///) which made it work, but I'm not sure why the issue only happens in Windows in the first place and not on Linux.

Any Advice appreciated.

Community
  • 1
  • 1
Rohit
  • 106
  • 2
  • 15

2 Answers2

1

The reason this doesn't cause an error on linux is probably due to the difference in the value of ${basedir} on the two platforms:

On Windows ${basedir} will be set to something like "c:/file/path"

file://c:/file/path   <--- not happy

On linux ${basedir} will be like "/file/path"

file:///file/path   <--- happy
alasdairg
  • 2,108
  • 12
  • 14
0

On a windows machine, the complete syntax is file://host/path .
If the host is your machine(localhost), it can be omitted, resulting in file:///path .

See RFC 1738 – Uniform Resource Locators (URL)

A file URL takes the form:

file://<host>/<path>
[…]

As a special case, <host> can be the string "localhost" or the empty string; this is interpreted as 'the machine from which the URL is being interpreted'.
RITZ XAVI
  • 3,633
  • 1
  • 25
  • 35
  • Yes. He already fixed it with three slashes. I guess his question is, why is it that it works with 3 slashes as against 2 slashes on windows machine. – RITZ XAVI Oct 04 '16 at 15:19
  • Thanks for your reply. My question is, why doesn't this cause an issue on Linux? – Rohit Oct 04 '16 at 15:43