title: How to get all remote repositories of a maven project hierarchy?
body: <p>I'm redirecting all maven repository access to an Artifactory with the following <code>~/.m2/settings.xml</code>:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.1.0"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
  &lt;!-- unclear what version changes -&gt; use 1.1.0 because it's higher --&gt;
    &lt;servers&gt;
      &lt;server&gt;
        &lt;id&gt;central&lt;/id&gt;
        &lt;username&gt;admin&lt;/username&gt;
      &lt;/server&gt;
      &lt;server&gt;
        &lt;id&gt;snapshots&lt;/id&gt;
        &lt;username&gt;admin&lt;/username&gt;
      &lt;/server&gt;
    &lt;/servers&gt;
    &lt;mirrors&gt;
      &lt;mirror&gt;
        &lt;id&gt;artifactory&lt;/id&gt;
        &lt;name&gt;artifactory&lt;/name&gt;
        &lt;mirrorOf&gt;*&lt;/mirrorOf&gt;
        &lt;url&gt;https://[hostname]:[port]/artifactory/remote-repos/&lt;/url&gt;
      &lt;/mirror&gt;
    &lt;/mirrors&gt;
    &lt;profiles&gt;
      &lt;profile&gt;
        &lt;id&gt;artifactory&lt;/id&gt;
        &lt;repositories&gt;
          &lt;repository&gt;
            &lt;id&gt;central&lt;/id&gt;
            &lt;name&gt;remote-repos&lt;/name&gt;
            &lt;url&gt;https://[hostname]:[port]/artifactory/remote-repos&lt;/url&gt;
            &lt;snapshots&gt;
              &lt;enabled&gt;false&lt;/enabled&gt;
              &lt;updatePolicy&gt;interval:25200&lt;/updatePolicy&gt;
            &lt;/snapshots&gt;
          &lt;/repository&gt;
          &lt;repository&gt;
            &lt;id&gt;snapshots&lt;/id&gt;
            &lt;name&gt;remote-repos&lt;/name&gt;
            &lt;url&gt;https://[hostname]:[port]/artifactory/remote-repos&lt;/url&gt;
            &lt;snapshots /&gt;
          &lt;/repository&gt;
        &lt;/repositories&gt;
        &lt;pluginRepositories&gt;
          &lt;pluginRepository&gt;
            &lt;id&gt;central&lt;/id&gt;
            &lt;name&gt;remote-repos&lt;/name&gt;
            &lt;url&gt;https://[hostname]:[port]/artifactory/remote-repos&lt;/url&gt;
            &lt;snapshots&gt;
              &lt;enabled&gt;false&lt;/enabled&gt;
              &lt;updatePolicy&gt;interval:25200&lt;/updatePolicy&gt;
            &lt;/snapshots&gt;
          &lt;/pluginRepository&gt;
          &lt;pluginRepository&gt;
            &lt;id&gt;snapshots&lt;/id&gt;
            &lt;name&gt;remote-repos&lt;/name&gt;
            &lt;url&gt;https://[hostname]:[port]/artifactory/remote-repos&lt;/url&gt;
            &lt;snapshots /&gt;
          &lt;/pluginRepository&gt;
        &lt;/pluginRepositories&gt;
      &lt;/profile&gt;
    &lt;/profiles&gt;
    &lt;activeProfiles&gt;
      &lt;activeProfile&gt;artifactory&lt;/activeProfile&gt;
    &lt;/activeProfiles&gt;
  &lt;/settings&gt;
  </code></pre>
  
  <p>and thus have to add extra remote repositories which are specified by a project  (and its child projects) to the Artifactory instance. I currently use</p>
  
  <pre><code>find . -name pom.xml -exec grep -B 5 -C 5 '&lt;repository&gt;' {} +
  </code></pre>
  
  <p>which isn't very handy in case an URL is a variable and declared elsewhere and it doesn't skip duplicates. It's not the worst thing in the world, but maybe there's an improvement available.</p>
  
  <p>The following doesn't work:</p>
  
  <ul>
  <li><code>mvn versions:display-dependency-updates</code> doesn't display remote repositories</li>
  <li><code>mvn dependency:list-repositories</code> only works until the first dependency can't be fetched if the proxy is enabled so that I have to figure out where to get it from, add the researched remote repository to Artifactory or move <code>~/.m2/settings.xml</code> aside - less handy than the <code>find</code> command above</li>
  </ul>
  
  <p>The solution should work recursively, i.e. include all repositories in all child projects and childrens child projects, etc.</p>
  
  <p>It makes a lot of sense that a solutions don't require to download the dependencies directly from the remote repository first without the proxy since I'd like to transfer them through the Maven proxy immediately if possible - it's not a requirement, though.</p>