How to use <mirrors> and <servers> in settings.xml only for some projects
<p>I have a set of related projects that use a self-hosted Nexus installation as a repository to download dependencies from. So I setup in my <code>~/.m2/settings.xml</code> file the following:</p>

<pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;settings xmlns="http://maven.apache.org/SETTINGS/1.1.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd"&gt;

  &lt;mirrors&gt;
    &lt;mirror&gt;
      &lt;id&gt;central&lt;/id&gt;
      &lt;name&gt;central&lt;/name&gt;
      &lt;url&gt;http://myserver/repository/maven-public/&lt;/url&gt;
      &lt;mirrorOf&gt;*&lt;/mirrorOf&gt;
    &lt;/mirror&gt;
  &lt;/mirrors&gt;

&lt;/settings&gt;
</code></pre>

<p>Everything works fine, except that when I want to work on the same machine on a project that is unrelated to that set of projects, Maven will try to use that Nexus repository to download the dependencies, and that is not desirable at this point.</p>

<p>I think the way to go is to set something in the pom.xml of the projects where I want to use my Nexus repository, but I can't figure it out.</p>

<p>I was reading about Maven profiles, but doesn't seem to be the right choice. <code>&lt;profiles&gt;</code> should be a tag on the same level that <code>&lt;mirrors&gt;</code> from <a href="https://maven.apache.org/settings.html#Quick_Overview" rel="nofollow">this example</a>, but how could I say that that mirror should only apply to some profile (that I was expecting to set in the pom.xml of my projects who want to use that repo).</p>