此内容没有您所选择的语言版本。

14.3. How a Maven Proxy Resolves Artifacts


Overview

A Maven proxy is essentially a Web server that is configured to behave like a standard Maven repository server. Remember that the purpose of the Maven proxy is to serve artifacts to remote HTTP clients, not to install artifacts locally. So, although Maven proxy configuration properties have similar names to the managed container case, they ultimately serve quite a different purpose.

Fabric8 Maven proxy server

The Fabric8 Maven proxy server is a HTTP server, implemented as a servlet inside the container's default Jetty container. Hence, the Maven proxy server shares the same port number, 8181, as many of the other Karaf container services. On a given host, Host, the Maven proxy can be accessed through the following URL:
http://Host:8181/maven/download
The Fabric8 Maven proxy server is configured by setting properties from the io.fabric8.maven PID and these properties are normally set in the default profile (recommended).
Note
Some other properties are configurable through the io.fabric8.maven.proxy PID, but these properties do not play an important role in artifact resolution.

Serving artifacts through the Maven proxy

Figure 14.2, “Maven Proxy Serving an Artifact” shows how a Maven proxy processes a HTTP download request, by locating the requested Maven artifact and then returning it to the client.

Figure 14.2. Maven Proxy Serving an Artifact

Maven Proxy Serving an Artifact

Steps to serve artifacts

The steps to serve the required Maven artifacts are, as follows:
  1. Resolution of a Maven artifact is triggered when a managed container sends a request to the Maven proxy server.
  2. The Maven proxy server parses the incoming HTTP request and then makes a call to the io.fabric8.maven layer, asking it to resolve the requested Maven artifact.
  3. The io.fabric8.maven layer reads its Maven configuration from the io.fabric8.maven PID in the default profile (and possibly also from the maven-settings.xml file, if so configured).
  4. When the Aether library is invoked, the first step is to look up the Maven default repositories to try and find the Maven artifact. The following default repositories are configured by default:
    InstallDir/system
    The JBoss Fuse system directory, which contains all of the Maven artifacts that are bundled with the JBoss Fuse distribution.
    InstallDir/data/maven/upload
    The Maven proxy's upload directory, which is used to store artifacts that have been directly uploaded to the Maven proxy—see Section 14.7, “Automated Deployment”.
    UserHome/.m2/repository
    The user's own local Maven repository in the user's home directory, UserHome.
    If the Maven artifact is found locally, skip straight to step 7.
  5. The Aether library now begins the process of consulting the remote repositories (as specified by the io.fabric8.maven/io.fabric8.maven.repositories PID property which references the io.fabric8.agent/org.ops4j.pax.url.mvn.repositories PID property). This process works in tandem with the local Maven repository (as specified by the io.fabric8.maven/io.fabric8.maven.localRepository PID property), which acts as a cache for the remote repositories.
    Note
    If your local network requires you to use a HTTP proxy to access the Internet, it is possible to configure Fabric8 to use a HTTP proxy. For example, see the section called “Configuring an HTTP proxy” for details.
  6. If the Maven artifact is found in a remote repository, Aether automatically installs the artifact into the local Maven repository, InstallDir/data/repository, so that another remote lookup will not be required.
  7. The Maven proxy server returns the successfully located Maven artifact to the client (or an error message, if the artifact could not be found).
Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.