ok
________________________________
From: [Quipsy] Markus Karg <[email protected]>
Sent: Wednesday, July 27, 2022 7:41 AM
To: Maven Users List <[email protected]>
Subject: Maven fails to resolve version range for <scope>import</scope>
I think I found a bug in Maven, but I am not sure. Maybe I am doing something
wrong, so Maven Committers, please judge the following case:
A version range in a dependency like...
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
<version>[2.0.0, 3.0.0)</version>
</dependency>
mvn dependency:tree
...results in a correctly resolved output...
...
+- org.glassfish.jersey.core:jersey-server:jar:3.0.0-RC2:compile
...
But when instead using the same version range IN AN IMPORTED BOM, then...
<dependencyManagement>
<dependency>
<groupId>org.glassfish.jersey</groupId>
<artifactId>jersey-bom</artifactId>
<version>[2.0.0, 3.0.0)</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencyManagement>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
</dependency>
mvn dependency:tree
...results in this error message as it was not resolved:
downloading from xxx:
http://xxx:8081/content/groups/public/org/glassfish/jersey/jersey-bom/%5B2.0.0,%203.0.0)/jersey-bom-%5B2.0.0,%203.0.0).pom
MG>which tree will only see if your repository has already been declared in
parent pom
MG>the beauty of the configuration for repository in parent-pom is visibility
will not depend on a specific build profile
Maven – Guide to using Multiple Repositories
(apache.org)<https://maven.apache.org/guides/mini/guide-multiple-repositories.html>
Maven – Guide to using Multiple
Repositories<https://maven.apache.org/guides/mini/guide-multiple-repositories.html>
In fact the -P option will take a CSV list of profiles to activate if you wish
to activate multiple profiles simultaneously.. Note: The settings descriptor
documentation can be found on the Maven Local Settings Model Website..
Repository Order. Remote repository URLs are queried in the following order for
artifacts until one returns a valid result: ...
maven.apache.org
Non-resolvable import POM: Could not find artifact
org.glassfish.jersey:jersey-bom:pom:[2.0.0, 3.0.0)
In fact, calling curl -i
http://nexus:8081/content/groups/public/org/glassfish/jersey/jersey-bom/%5B2.0.0,%203.0.0)/jersey-bom-%5B2.0.0,%203.0.0).pom
tells us that such a URL does not exist: HTTP/1.1 400 Invalid repository path.
So am I doing or assuming something wrong here (e. g. possibly includes
deliberately will not resolve version ranges) or is that simply a bug in Maven
(which I should report in the issue tracker)?
MG>OTOH if you are setting up repo under a profile then you will need to
activate the repo
<profile>
<id>myprofile</id>
<repositories>
<repository>
......
MG>then activate the profile containing the repository with
MG>mvn -Pmyprofile
Maven – Guide to using Multiple Repositories
(apache.org)<https://maven.apache.org/guides/mini/guide-multiple-repositories.html>
MG>nexus is particular about which nx-user can access what repo...have you
tried to contact the creator of nexus repository to find out which user curl
should use to resolve repository-path ?
Users
(sonatype.com)<https://help.sonatype.com/repomanager3/nexus-repository-administration/access-control/users>
Users -
Sonatype<https://help.sonatype.com/repomanager3/nexus-repository-administration/access-control/users>
Figure: Creating or Editing a User. The ID can be defined upon initial creation
and remains fixed thereafter. In addition you can specify the users First Name,
Last Name and Email address.You also must enter and confirm a Password.. The
Status allows you to set an account to be Disabled or Active.The Roles control
allows you to add and remove defined roles to the user and therefore control
the ...
help.sonatype.com
Maven – Guide to using Multiple
Repositories<https://maven.apache.org/guides/mini/guide-multiple-repositories.html>
In fact the -P option will take a CSV list of profiles to activate if you wish
to activate multiple profiles simultaneously.. Note: The settings descriptor
documentation can be found on the Maven Local Settings Model Website..
Repository Order. Remote repository URLs are queried in the following order for
artifacts until one returns a valid result: ...
maven.apache.org
MG>IN CONCLUSION
MG>if you are using correct nexus nx-user
MG>AND you are not referencing a repository which is specific only to 1 build
MG>then you have indeed found a bug with version range and should report bug
with your full test-case !
Thanks!
-Markus
MG>gruss~