0

I have a project built and installed in the local maven repository ~/.m2 named com.example.project. From time to time, not always, when I build another project that depends on com.example.project, maven says in debug messages:

Downloading: https://repo.maven.apache.org/maven2/com/example/project/maven-metadata.xml

Why is maven querying that URL and why does this happen occasionally? First, there is nothing on that URL, second, the jar already exists on local repository, third, I didn't change the version number of the local jar dependency. So let us say I have 1000 local projects, will it query URL1, URL2, ..., URL1000. What is the logic of this query to a non-existing URL?

  • You wouldn't happen to launch Maven with the `-U` switch right? – Tunaki Jun 01 '16 at 09:04
  • See also [How does the updatePolicy in maven really work?](http://stackoverflow.com/questions/3805329/how-does-the-updatepolicy-in-maven-really-work). – Gerold Broser Jun 01 '16 at 10:28

1 Answers1

1

Why is maven querying that URL and why does this happen occasionally?

occasionally: is specifically daily, because it is the default updatepolicy for the maven builtin Central Repository.

If you take a look at the maven super POM, which all pom files inherited from, you will find the repository is configured as follows

<repositories>
<repository>
  <id>central</id>
  <name>Central Repository</name>
  <url>https://repo.maven.apache.org/maven2</url>
  <layout>default</layout>
  <snapshots>
    <enabled>false</enabled>
  </snapshots>
</repository>
</repositories>

<release> element is not appearing here, so that means the repository will take the default values for it.

enabled (default is true)

updatePolicy (default is daily) --> possible values: "always", "daily" (default), "interval:XXX" (in minutes) or "never" (only if it doesn't exist locally).

hope this helps

Hisham Khalil
  • 1,054
  • 8
  • 9
  • this does answer your question "why maven queries a remote repository". again in another words maven is preconfigured to update your jars daily from central repository. – Hisham Khalil Jun 01 '16 at 12:37