Subproject dependencies in pants
<p>I am new to using <a href="http://www.pantsbuild.org/" rel="nofollow">pantsbuild</a> and I can't seem to find any good questions, answers, or documentation around my dillema.</p>

<p>I have a Pants project which should be buildable on its own. It has its own <code>pants</code> and <code>pants.ini</code> file as well as all <code>BUILD</code> files containing paths relative to the project root (where <code>pants.ini</code> is). This project is hosted on GitHub.</p>

<p>I'd like to use this project as a dependency in a second project. I've chosen to use git submodules to do this. Now, I have a layout like the following:</p>

<pre><code>path
âââ pants
âââ pants.ini
âââ projectA
âÂ Â  âââ src
âÂ Â      âââ python
|           âââ main
âÂ Â              âââ BUILD
âÂ Â              âââ main.py
âââ projectB
    âââ pants
    âââ pants.ini
    âââ src
        âââ python
            âââ libA
            |   âââ BUILD
            |   âââ lib.py
            âââ libB
                âââ BUILD
                âââ lib.py
</code></pre>

<p>Naturally, I am looking to use projectB's BUILD targets from within projectA, so in projectA's <code>BUILD</code>, I have something of the sort:</p>

<pre><code>dependencies = [ "projectB/src/python:libA" ]
</code></pre>

<p>This is all well and good. However, since projectB is an independent project, it's <code>src/python/libA/BUILD</code> file contains something of the sort:</p>

<pre><code>dependencies = [ "src/python:libB" ]
</code></pre>

<p>Because of this, projectB can indeed be built independently. However, when trying to build projectA, the build targets from projectB search starting from projectA's project root, for instance:</p>

<pre><code>Exception Message: libB was not found in BUILD files from path/src/python
</code></pre>

<p>Does pantsbuild have any clean way to handle these subproject dependencies? Or would I be forced to alter the BUILD files of the subproject in order to fit them within my project layout (Causing the project to be unbuildable independently)?</p>

<p>Any solutions or advice is welcomed!</p>

<blockquote>
  <p>This is all well and good. However, since projectA is an independent project, it's src/python/libA/BUILD file contains something of the sort:</p>
  
  <blockquote>
    <p>dependencies = [ "src/python:libB" ]</p>
  </blockquote>
</blockquote>

<p>iiuc <code>src/python:libB</code> needs to be <code>projectB/src/python:libB</code>. All target paths in the repo should be relative to the build root which is <code>path</code> in your example. </p>

python pants