title: How to make one module depend on another module artifact?
body: <p>I have maven multiple-module project.</p>
  
  <pre><code> A: parent.
      B: child1.
      C: child2.
  </code></pre>
  
  <p>B will be packaged to get jar file and then c will use this jar file to compile the code.</p>
  
  <p>In B, if I run <code>mvn package</code>, it will create <code>b.jar</code> (stays in <code>B/target/jars</code> not in <code>B/target</code> -for another purpose).</p>
  
  <p>In C, I need to use that <code>b.jar</code> to compile the code. </p>
  
  <p>Now, from A, when I run: <code>mvn package</code>. First, I am successful to create <code>b.jar</code> file for B.</p>
  
  <p>But when it come to C's compilation phase, it looks like C doesn't recognize <code>b.jar</code> in the classpath (the compilation gets errors because C's code can not import the class file from B). </p>
  
  <p>My question is: How can I solve this problem? </p>
  
  <p>---------- <code>Below</code> are the pom files</p>
  
  <pre><code>A: pom.xml
    &lt;groupId&gt;AAA&lt;/groupId&gt;
    &lt;artifactId&gt;A&lt;/artifactId&gt;
    &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
    &lt;packaging&gt;pom&lt;/packaging&gt;
  
     &lt;modules&gt;
     &lt;module&gt;C&lt;/module&gt;
     &lt;module&gt;B&lt;/module&gt;
     &lt;/modules&gt;
  
  B: pom.xml
          &lt;groupId&gt;AAA&lt;/groupId&gt;
   &lt;artifactId&gt;B&lt;/artifactId&gt;
   &lt;packaging&gt;jar&lt;/packaging&gt;
   &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
   &lt;parent&gt;
    &lt;artifactId&gt;A&lt;/artifactId&gt;
    &lt;groupId&gt;AAA&lt;/groupId&gt;
    &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
   &lt;/parent&gt;
  
  C: pom.xml
         &lt;parent&gt;
    &lt;artifactId&gt;A&lt;/artifactId&gt;
    &lt;groupId&gt;AAA&lt;/groupId&gt;
    &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
   &lt;/parent&gt;
  
   &lt;groupId&gt;AAA&lt;/groupId&gt;
   &lt;artifactId&gt;C&lt;/artifactId&gt;
   &lt;packaging&gt;war&lt;/packaging&gt;
   &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
  
   &lt;dependencies&gt;
  
    &lt;dependency&gt;
     &lt;groupId&gt;AAA&lt;/groupId&gt;
     &lt;artifactId&gt;B&lt;/artifactId&gt;
     &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
    &lt;/dependency&gt;
  ....
  </code></pre>