Please, consider running the following command:
mvn -X -U compile
using this test pom.xml (note that the provided Jackson version not - yet - exists):
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>mvn-test</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>20.14.2</version>
</dependency>
</dependencies>
</project>
Please, note that among information Maven will provide the following logs:
[DEBUG] =======================================================================
[DEBUG] Using transporter WagonTransporter with priority -1.0 for https://repo.maven.apache.org/maven2
[DEBUG] Using connector BasicRepositoryConnector with priority 0.0 for https://repo.maven.apache.org/maven2
Downloading from central: https://repo.maven.apache.org/maven2/com/fasterxml/jackson/core/jackson-databind/20.14.2/jackson-databind-20.14.2.pom
[DEBUG] Writing tracking file /Users/jccampanero/.m2/repository/com/fasterxml/jackson/core/jackson-databind/20.14.2/jackson-databind-20.14.2.pom.lastUpdated
...
and this error trace:
Caused by: org.eclipse.aether.transfer.ArtifactNotFoundException: Could not find artifact com.fasterxml.jackson.core:jackson-databind:jar:20.14.2 in central (https://repo.maven.apache.org/maven2)
at org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed (ArtifactTransportListener.java:48)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run (BasicRepositoryConnector.java:369)
at org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run (RunnableErrorForwarder.java:75)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector$DirectExecutor.execute (BasicRepositoryConnector.java:628)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector.get (BasicRepositoryConnector.java:262)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads (DefaultArtifactResolver.java:513)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve (DefaultArtifactResolver.java:401)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts (DefaultArtifactResolver.java:229)
at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependencies (DefaultRepositorySystem.java:340)
As you can see, by default Maven uses BasicRepositoryConnector and Wagon to download the requested artifacts.
The actual download is performed in the get method: please, note it within the provided error trace.
For the actual download, among other things, it will use a RepositoryLayout provided by the configured RepositoryLayoutFactory by default, see here and here, Maven2RepositoryLayoutFactory.
Please, consider review the implemented getLocation methods for the default Maven2RepositoryLayoutFactory, written partially here for completeness:
public URI getLocation(Artifact artifact, boolean upload) {
StringBuilder path = new StringBuilder(128);
path.append(artifact.getGroupId().replace('.', '/')).append('/');
path.append(artifact.getArtifactId()).append('/');
path.append(artifact.getBaseVersion()).append('/');
path.append(artifact.getArtifactId()).append('-').append(artifact.getVersion());
if (artifact.getClassifier().length() > 0) {
path.append('-').append(artifact.getClassifier());
}
if (artifact.getExtension().length() > 0) {
path.append('.').append(artifact.getExtension());
}
return toUri(path.toString());
}
As you can see it matches exactly the path of the URL used for the actual download:
https://repo.maven.apache.org/maven2/com/fasterxml/jackson/core/jackson-databind/20.14.2/jackson-databind-20.14.2.jar
You can include new repository layouts if required although I never did myself: I came across some blogs like this one that could be of help.
I am aware that the repository layout is typically conceived for local directory structure, but as described in the RepositoryLayoutFactory interface javadoc:
/**
* A factory to obtain repository layouts. A repository layout is responsible to map an artifact or some metadata to a
* URI relative to the repository root where the resource resides. When the repository system needs to access a given
* remote repository, it iterates the registered factories in descending order of their priority and calls
* {@link #newInstance(RepositorySystemSession, RemoteRepository)} on them. The first layout returned by a factory will
* then be used for transferring artifacts/metadata.
*/
And the description of the getLocation methods in RepositoryLayout:
/**
* Gets the location within a remote repository where the specified artifact resides. The URI is relative to the
* root directory of the repository.
*
* @param artifact The artifact to get the URI for, must not be {@code null}.
* @param upload {@code false} if the artifact is being downloaded, {@code true} if the artifact is being
* uploaded.
* @return The relative URI to the artifact, never {@code null}.
*/
URI getLocation(Artifact artifact, boolean upload);
/**
* Gets the location within a remote repository where the specified metadata resides. The URI is relative to the
* root directory of the repository.
*
* @param metadata The metadata to get the URI for, must not be {@code null}.
* @param upload {@code false} if the metadata is being downloaded, {@code true} if the metadata is being
* uploaded.
* @return The relative URI to the metadata, never {@code null}.
*/
URI getLocation(Metadata metadata, boolean upload);
That means that in order to resolve the URL of a certain artifact there is not a single answer, it will depend on the Maven Repository Layout provided.