CINXE.COM

Maven Remote Repositories – Maven

<!DOCTYPE html> <!-- | Generated by Apache Maven Doxia Site Renderer 2.0.0 from content/markdown/repositories/remote.md at 2024-11-18 | Rendered using Apache Maven Fluido Skin 2.0.0 --> <html xmlns="http://www.w3.org/1999/xhtml" lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="generator" content="Apache Maven Doxia Site Renderer 2.0.0" /> <title>Maven Remote Repositories – Maven</title> <link rel="stylesheet" href="../css/apache-maven-fluido-2.0.0.min.css" /> <link rel="stylesheet" href="../css/site.css" /> <link rel="stylesheet" href="../css/print.css" media="print" /> <script src="../js/apache-maven-fluido-2.0.0.min.js"></script> <!-- Matomo --> <script> var _paq = window._paq = window._paq || []; _paq.push(['disableCookies']); _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); (function() { var u="https://analytics.apache.org/"; _paq.push(['setTrackerUrl', u+'/matomo.php']); _paq.push(['setSiteId', '3']); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.async=true; g.src=u+'/matomo.js'; s.parentNode.insertBefore(g,s); })(); </script> <!-- End Matomo Code --> </head> <body> <div class="container-fluid container-fluid-top"> <header> <div id="banner"> <div class="pull-left"><div id="bannerLeft"><h1><a href="https://www.apache.org/"><img class="class java.lang.Object" src="../images/apache-maven-project.png" /></a></h1></div></div> <div class="pull-right"><div id="bannerRight"><h1><a href=".././"><img class="class java.lang.Object" src="../images/maven-logo-black-on-white.png" /></a></h1></div></div> <div class="clear"><hr/></div> </div> <div id="breadcrumbs"> <ul class="breadcrumb"> <li><a href="https://www.apache.org/" class="externalLink">Apache</a><span class="divider">/</span></li> <li><a href="../index.html">Maven</a><span class="divider">/</span></li> <li class="active">Maven Remote Repositories <a href="https://github.com/apache/maven-site/tree/master/content/markdown/repositories/remote.md"><img src="../images/accessories-text-editor.png" alt="Edit" /></a></li> <li id="publishDate" class="pull-right"><span class="divider">|</span> Last Published: 2024-11-18</li> <li class="pull-right"><span class="divider">|</span> <a href="../scm.html">Get Sources</a></li> <li class="pull-right"><a href="../download.cgi">Download</a></li> </ul> </div> </header> <div class="row-fluid"> <header id="leftColumn" class="span2"> <nav class="well sidebar-nav"> <ul class="nav nav-list"> <li><a href="../index.html">Welcome</a></li> <li><a href="https://www.apache.org/licenses/" class="externalLink">License</a></li> <li class="nav-header">About Maven</li> <li><a href="../what-is-maven.html">What is Maven?</a></li> <li><a href="../maven-features.html">Features</a></li> <li><a href="../download.html">Download</a></li> <li><a href="../users/index.html"><span class="icon-chevron-right"></span>Use</a></li> <li><a href="../docs/history.html">Release Notes</a></li> <li class="nav-header">Documentation</li> <li><a href="../plugins/index.html">Maven Plugins</a></li> <li><a href="../extensions/index.html">Maven Extensions</a></li> <li><a href="../guides/index.html">Index (category)</a></li> <li><a href="../users/index.html"><span class="icon-chevron-right"></span>User Centre</a></li> <li><a href="../plugin-developers/index.html"><span class="icon-chevron-right"></span>Plugin Developer Centre</a></li> <li><a href="../repositories/index.html"><span class="icon-chevron-down"></span>Maven Repository Centre</a> <ul class="nav nav-list"> <li><a href="../repository/index.html"><span class="icon-chevron-right"></span>Maven Central Repository</a></li> <li><a href="../repositories/artifacts.html">Maven Artifacts</a></li> <li><a href="../repositories/metadata.html">Maven Metadata</a></li> <li><a href="../repositories/layout.html">Maven Layout</a></li> <li><a href="../repositories/local.html">Maven Local Repository</a></li> <li class="active"><a>Maven Remote Repositories</a></li> </ul></li> <li><a href="../developers/index.html"><span class="icon-chevron-right"></span>Maven Developer Centre</a></li> <li><a href="../articles.html">Books and Resources</a></li> <li><a href="../security.html">Security</a></li> <li class="nav-header">Community</li> <li><a href="../community.html">Community Overview</a></li> <li><a href="../project-roles.html">Project Roles</a></li> <li><a href="../guides/development/guide-helping.html">How to Contribute</a></li> <li><a href="../users/getting-help.html">Getting Help</a></li> <li><a href="../issue-management.html">Issue Management</a></li> <li><a href="../scm.html">Getting Maven Source</a></li> <li><a href="../team.html">The Maven Team</a></li> <li class="nav-header">Project Documentation</li> <li><a href="../project-info.html"><span class="icon-chevron-right"></span>Project Information</a></li> <li class="nav-header">Maven Projects</li> <li><a href="../ref/current">Maven</a></li> <li><a href="../archetypes/index.html">Archetypes</a></li> <li><a href="../extensions/index.html">Extensions</a></li> <li><a href="../pom/index.html">Parent POMs</a></li> <li><a href="../plugins/index.html">Plugins</a></li> <li><a href="../skins/index.html">Skins</a></li> <li><a><span class="icon-chevron-down"></span>Components</a> <ul class="nav nav-list"> <li><a href="../archetype/index.html">Archetype</a></li> <li><a href="../resolver/index.html">Artifact Resolver</a></li> <li><a href="../doxia/index.html">Doxia</a></li> <li><a href="../maven-indexer/index.html">Indexer</a></li> <li><a href="../jxr/index.html">JXR</a></li> <li><a href="../plugin-testing/index.html">Plugin Testing</a></li> <li><a href="../plugin-tools/index.html">Plugin Tools</a></li> <li><a href="../apache-resource-bundles/index.html">Resource Bundles</a></li> <li><a href="../scm/index.html">SCM</a></li> <li><a href="../shared/index.html">Shared Components</a></li> <li><a href="../surefire/index.html">Surefire</a></li> <li><a href="../wagon/index.html">Wagon</a></li> </ul></li> <li class="nav-header">ASF</li> <li><a href="https://www.apache.org/foundation/how-it-works.html" class="externalLink">How Apache Works</a></li> <li><a href="https://www.apache.org/foundation/" class="externalLink">Foundation</a></li> <li><a href="https://privacy.apache.org/policies/privacy-policy-public.html" class="externalLink">Data Privacy</a></li> <li><a href="https://www.apache.org/foundation/sponsorship.html" class="externalLink">Sponsoring Apache</a></li> <li><a href="https://www.apache.org/foundation/thanks.html" class="externalLink">Thanks</a></li> </ul> </nav> <div class="well sidebar-nav"> <div id="poweredBy"> <div class="clear"></div> <div class="clear"></div> <a href="https://maven.apache.org/" class="builtBy" target="_blank"><img class="builtBy" alt="Built by Maven" src="../images/logos/maven-feather.png" /></a> </div> </div> </header> <main id="bodyColumn" class="span10"> <section><a id="Maven_Remote_Repositories"></a> <h1>Maven Remote Repositories</h1><!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <p>Remote repositories usually refer to repositories like <a href="/repository/index.html">Maven Central Repository</a>. These repositories are holding the artifacts to be consumed by Maven builds.</p> <p>The two most important properties of remote repositories are:</p> <ul> <li>baseURL</li> <li>repository policy</li> </ul> <p>In essence, Maven using <a href="layout.html">Layout</a> produces relative paths for <a href="artifacts.html">Artifacts</a>, that in turn are resolved against baseURL of Remote Repositories ending in absolute URLs. The policy decides should a release or snapshot artifact looked for in given repository.</p><section><a id="The_baseVersion_Artifact_Property"></a> <h2>The <code>baseVersion</code> Artifact Property</h2> <p>In case of snapshot artifacts (hence Snapshot Remote Repositories implied) we already hinted that some sort of &#x201c;version transformation&#x201d; happens. We can distinguish two cases:</p><section><a id="Deploying_Snapshot_Artifact"></a> <h3>Deploying Snapshot Artifact</h3> <p>Your POM locally usually contains snapshot versions in a form of a string that ends with &#x201c;SNAPSHOT&#x201d; constant string (for example &#x201c;1.0-SNAPSHOT&#x201d;). But, in case of deploy, this version is being transformed to a &#x201c;timestamped snapshot&#x201d; on the fly (by Maven) and when you check the deployed result, you will see that artifact file does not end up with &#x201c;SNAPSHOT&#x201d; anymore, but a timestamp and build number. Also, during deploy, Maven will deploy required Maven V Level Metadata as well that will describe for consumers of this snapshot how to &#x201c;reverse&#x201d; this process.</p> <p>So, in case of snapshot deploy, version transformation happens in form of:</p> <pre class="prettyprint linenums"><code class="nohighlight nocode">1.0-SNAPSHOT -&gt; Maven (on the fly) -&gt; 1.0-${YYYYMMDD.HHMMSS}-${counter} </code></pre> <p>Where the date in <code>Etc/UTC</code> timezone (used in <code>YYYYMMDD.HHMMSS</code> format) is constant across deploy from same session (is time when Maven Session was created), and counter is increased counter from previously deployed metadata (or if no remote metadata exists, is initialized with 1).</p></section><section><a id="Consuming_Snapshot_Artifacts"></a> <h3>Consuming Snapshot Artifacts</h3> <p>If your project depends on SNAPSHOT dependencies, the POM of your project usually contains <code>version</code> value that ends with &#x201c;SNAPSHOT&#x201d; (for example &#x201c;1.0-SNAPSHOT&#x201d;), still, as we see above, remote repositories do NOT contain such versions, but only timestamped ones. Maven snapshots are &#x201c;moving targets&#x201d;, hence, during resolution Maven will use the deployed metadata first, to figure out <code>baseVersion</code> -&gt; <code>version</code> (timestamped) mapping, and only then will fetch the required files.</p> <p>In case of consuming snapshot, the following transformation happens:</p> <pre class="prettyprint linenums"><code class="nohighlight nocode">1.0-SNAPSHOT -&gt; Remote V Level Repository Metadata -&gt; 1.0-YYYYMMDD.HHMMS-X </code></pre> <p>Due this indirection (the real filename of artifact, the version part) is figured from deployed Maven repository metadata, the snapshot artifacts are &#x201c;moving target&#x201d;: each snapshot deployment as above will deploy new metadata, hence, will alter this transformation here (Maven will download different snapshot artifact).</p> <p>Note: it is possible to &#x201c;lock down&#x201d; snapshot artifacts, by using timestamped version in version field of a dependency, and it will ensure Maven downloads always same artifact (is not &#x201c;moving target&#x201d; anymore), but <strong>Maven will still consider that dependency as snapshot</strong>, and all the fine print applies (for example, release plugin will refuse to release such a project).</p></section></section></section> </main> </div> </div> <hr/> <footer> <div class="container-fluid"> <div class="row-fluid"> <p>© 2002–2024 <a href="https://www.apache.org/">The Apache Software Foundation</a> </p> </div> </div> </footer> </body> </html>

Pages: 1 2 3 4 5 6 7 8 9 10