I am trying to download a Maven dependency using the following command:
mvn dependency:get -Dartifact=org.webjars:jquery:jar:3.6.1
Note that the coordinates specify the “jar” packaging.
I am connecting to a custom repository server called repo1.ek
(not public reachable) for the project I am working on.
This is the output:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< org.apache.maven:standalone-pom >-------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- dependency:3.6.1:get (default-cli) @ standalone-pom ---
[INFO] Resolving org.webjars:jquery:3.6.1:jar with transitive dependencies
Downloading from repo: http://repo1.ek/content/groups/public/org/webjars/jquery/jar/jquery-jar.pom
[WARNING] The POM for org.webjars:jquery:3.6.1:jar is missing, no dependency information available
Downloading from repo: http://repo1.ek/content/groups/public/org/webjars/jquery/jar/jquery-jar.3.6.1
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.688 s
[INFO] Finished at: 2024-05-09T07:10:24+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:3.6.1:get (default-cli) on project standalone-pom: Couldn't download artifact: org.eclipse.aether.resolution.DependencyResolutionException: The following artifacts could not be resolved: org.webjars:jquery:3.6.1:jar (absent): Could not find artifact org.webjars:jquery:3.6.1:jar in repo (http://repo1.ek/content/groups/public) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
It seems like Maven tried to download the JAR from this URL, and cannot find it there:
http://repo1.ek/content/groups/public/org/webjars/jquery/jar/jquery-jar.3.6.1
The following URL would have worked:
http://repo1.ek/content/groups/public/org/webjars/jquery/3.6.1/jquery-3.6.1.jar
I found this source for both the colon-syntax for coordinates and the URL pattern used: https://books.sonatype.com/mvnex-book/reference/simple-project-sect-simple-core.html#:~:text=Maven%20coordinates%20are%20often%20written,%3Ajar%3A1.0%2DSNAPSHOT%20.&text=The%20group%2C%20company%2C%20team%2C,%2C%20project%2C%20or%20other%20group.
It says:
Maven coordinates are often written using a colon as a delimiter in the following format: groupId:artifactId:packaging:version
and
The standard for a Maven repository is to store an artifact in the following directory
relative to the root of the repository:
/<groupId>/<artifactId>/<version>/<artifactId>-<version>.<packaging>
So it seems to me that org.webjars:jquery:jar:3.6.1
is using the correct order for the colon-syntax, and the URL expected by the repository server is also correct. Rather it seems to be Maven that builds an incorrect URL from the coordinates.
This is my .m2/settings.xml, in case it is relevant. The file has been prescribed by the project I am working on, so I can’t comment on why it is that way, but if the error is caused by it then fixing it is “allowed”.
<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<mirrors>
<mirror>
<mirrorOf>*</mirrorOf>
<name>repo</name>
<url>http://repo1.ek/content/groups/public</url>
<id>repo</id>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<!--Enable snapshots for the built in central repo to direct -->
<!--all requests to nexus via the mirror -->
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>nexus</activeProfile>
</activeProfiles>
</settings>
Maven version is: Apache Maven 3.9.6 (bc0240f3c744dd6b6ec2920b3cd08dcc295161ae)