Multi-module maven dependency using repository, not local on Travis CI
<p>I have a multi-module project in which one of the two submodules depends upon the other.  <a href="https://stackoverflow.com/questions/2511908/how-can-i-make-one-maven-module-depend-on-another">This question</a> implies that <code>mvn install</code> is supposed to take care of these dependencies.  </p>

<p>Everything is working fine at a local level on my machine (both inside Eclipse and on the command line).  However, when I update the module which changes code the second module needs and commit to my github repository, the second module fails the Travis CI build.  I've traced the problem down to the fact that it is downloading its dependency from a repository rather than using the one it just compiled.</p>

<p>The problem is very similar to <a href="https://stackoverflow.com/questions/33548395/how-do-i-force-maven-to-use-my-local-repository-rather-than-going-out-to-remote">the one reported in this question</a>, except that instead of my local repository, I'm dealing with the Travis CI automated build.  The comments and answer on that question indicate that:</p>

<blockquote>
  <p>The dependency has a snapshot version. For snapshots, Maven will check
  the local repository and if the artifact found in the local repository
  is too old, it will attempt to find an updated one in the remote
  repositories.</p>
</blockquote>

<p>However, in this case, "too old" shouldn't apply. The local artifact was literally <em>just built</em>. It should be seconds old.</p>

<p>Here are the relevant sections of pom.xml of the <code>oshi-json</code> module, noting its dependence on <code>oshi-core</code> (both share their version number with the parent):</p>

<pre><code>&lt;parent&gt;
    &lt;groupId&gt;com.github.dblock&lt;/groupId&gt;
    &lt;artifactId&gt;oshi-parent&lt;/artifactId&gt;
    &lt;version&gt;3.0-SNAPSHOT&lt;/version&gt;
&lt;/parent&gt;

&lt;artifactId&gt;oshi-json&lt;/artifactId&gt;
&lt;packaging&gt;jar&lt;/packaging&gt;

&lt;name&gt;oshi-json&lt;/name&gt;

&lt;dependencies&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;${project.groupId}&lt;/groupId&gt;
        &lt;artifactId&gt;oshi-core&lt;/artifactId&gt;
        &lt;version&gt;${project.version}&lt;/version&gt;
    &lt;/dependency&gt;
&lt;/dependencies&gt;
</code></pre>

<p>And an excerpt from the parent pom.xml:</p>

<pre><code>&lt;groupId&gt;com.github.dblock&lt;/groupId&gt;
&lt;artifactId&gt;oshi-parent&lt;/artifactId&gt;
&lt;version&gt;3.0-SNAPSHOT&lt;/version&gt;
&lt;packaging&gt;pom&lt;/packaging&gt;

&lt;name&gt;oshi-parent&lt;/name&gt;

&lt;modules&gt;
    &lt;module&gt;oshi-core&lt;/module&gt;
    &lt;module&gt;oshi-json&lt;/module&gt;
&lt;/modules&gt;
</code></pre>

<p>The complete files are available here:</p>

<ul>
<li><a href="https://github.com/dbwiddis/oshi/blob/master/pom.xml" rel="nofollow noreferrer">oshi-parent pom.xml</a>  </li>
<li><a href="https://github.com/dbwiddis/oshi/blob/master/oshi-core/pom.xml" rel="nofollow noreferrer">oshi-core pom.xml</a> </li>
<li><a href="https://github.com/dbwiddis/oshi/blob/master/oshi-json/pom.xml" rel="nofollow noreferrer">oshi-json pom.xml</a></li>
</ul>

<p>Relevant excerpts from the log files are shown below.  A complete example of a <a href="https://travis-ci.org/dblock/oshi/builds/140242789" rel="nofollow noreferrer">failed Travis CI build can be found here</a>.  Note that the symptom (Compilation Error) is a result of Travis using the latest snapshot for oshi-core, which does not include the class referenced in  oshi-json; however, the class is in the submitted pull request and it compiles (and builds with mvn install) locally.</p>

<p>When I make a new commit, Travis executes the build as follows:</p>

<pre><code>$ mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V
</code></pre>

<p>The reactor properly arranges the builds in order:</p>

<pre><code>[INFO] Reactor Build Order:
[INFO] 
[INFO] oshi-parent
[INFO] oshi-core
[INFO] oshi-json
</code></pre>

<p>The parent builds, and then <code>oshi-core</code> builds, storing the compiled code locally:</p>

<blockquote>
  <p>[INFO] Building jar:
  /home/travis/build/dblock/oshi/oshi-core/target/oshi-core-3.0-SNAPSHOT.jar</p>
</blockquote>

<p>This is the jar that I want the next module dependent on.  However, when the <code>oshi-json</code> build starts, it instead downloads the artifact from maven instead:</p>

<blockquote>
  <p>[INFO] Downloading:
  <a href="https://oss.sonatype.org/content/repositories/snapshots/com/github/dblock/oshi-core/3.0-SNAPSHOT/oshi-core-3.0-20160624.032041-9.jar" rel="nofollow noreferrer">https://oss.sonatype.org/content/repositories/snapshots/com/github/dblock/oshi-core/3.0-SNAPSHOT/oshi-core-3.0-20160624.032041-9.jar</a></p>
  
  <p>[INFO] Downloaded:
  <a href="https://oss.sonatype.org/content/repositories/snapshots/com/github/dblock/oshi-core/3.0-SNAPSHOT/oshi-core-3.0-20160624.032041-9.jar" rel="nofollow noreferrer">https://oss.sonatype.org/content/repositories/snapshots/com/github/dblock/oshi-core/3.0-SNAPSHOT/oshi-core-3.0-20160624.032041-9.jar</a>
  (199 KB at 708.5 KB/sec)</p>
</blockquote>

<p><strong>EDIT:</strong> Just noticed the following warning which occurs just prior to the download, which may or may not be relevant (<a href="https://github.com/travis-ci/travis-ci/issues/4629" rel="nofollow noreferrer">an error in Travis settings</a>) however, fixing that warning still doesn't resolve my problem, <a href="https://travis-ci.org/dblock/oshi/builds/140252985" rel="nofollow noreferrer">here's a failed build without the warning</a>:</p>

<blockquote>
  <p>[WARNING] Failure to transfer
  com.github.dblock:oshi-core:3.0-SNAPSHOT/maven-metadata.xml from
  <a href="https://nexus.codehaus.org/snapshots/" rel="nofollow noreferrer">https://nexus.codehaus.org/snapshots/</a> was cached in the local
  repository, resolution will not be reattempted until the update
  interval of codehaus-snapshots has elapsed or updates are forced.
  Original error: Could not transfer metadata
  com.github.dblock:oshi-core:3.0-SNAPSHOT/maven-metadata.xml from/to
  codehaus-snapshots (<a href="https://nexus.codehaus.org/snapshots/" rel="nofollow noreferrer">https://nexus.codehaus.org/snapshots/</a>):
  nexus.codehaus.org</p>
</blockquote>

<p>This is a temporary problem associated only with Travis-CI; the pom setup will work fine once I actually release all the modules, and I can work around it by locally executing <code>mvn clean deploy</code> to push the new <code>oshi-core</code> to the OSS repository so Travis is happy.  However, this seems a poor workaround.</p>

<p>Is there a way I can tell Travis CI to use the jar that it just compiled rather than downloading a new one -- and to do so in a way that doesn't break the intended download of the dependency from the repository once it's published?</p>