title: How to build two different project in single repository, using jenkins
body: <p>I am in a situation, it's been more than two weeks but I could not solve the problem. Sorry for the long description of the question. What I am trying to do is:</p>
  
  <p>I have two different projects, say <code>A</code> and <code>B</code> and I have to build them using Jenkins. Though they are independent they work together. So I created to different repositories and called them <code>Repo-A</code> and <code>Repo-B</code> and I was able to build them.</p>
  
  <p>Here is a real problem: Now I want to build them together from single repository. So I created a repository called <code>Demo</code> in Bitbucket and now I have both projects <code>A</code> and <code>B</code> in <code>Demo</code> repository.</p>
  
  <p>Now I created a <code>pom.xml</code> file in the <code>Demo</code> repository so that I can use it as parent POM and each of the projects <code>A</code> and <code>B</code> have their own <code>pom.xml</code>.</p>
  
  <h3>Project Demo's <code>pom.xml</code></h3>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
    &lt;groupId&gt;com.demo.parent&lt;/groupId&gt;
    &lt;artifactId&gt;Parent&lt;/artifactId&gt;
    &lt;packaging&gt;pom&lt;/packaging&gt;
    &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
    &lt;name&gt;Maven Webapp&lt;/name&gt;
    &lt;url&gt;http://localhost:8081/nexus/content/repositories/releases&lt;/url&gt;
  
    &lt;!--&lt;url&gt;http://maven.apache.org&lt;/url&gt; --&gt;
  
    &lt;modules&gt;
      &lt;module&gt;A&lt;/module&gt;
      &lt;module&gt;B&lt;/module&gt;
    &lt;/modules&gt;
  
   &lt;distributionManagement&gt;
      &lt;snapshotRepository&gt;
          &lt;id&gt;my-snapshots&lt;/id&gt;
          &lt;name&gt;Internal Repository&lt;/name&gt;
          &lt;url&gt;http://localhost:8081/nexus/content/repositories/snapshots&lt;/url&gt;
      &lt;/snapshotRepository&gt;
  
      &lt;repository&gt;
          &lt;id&gt;my-releases&lt;/id&gt;
          &lt;name&gt;Internal Repository&lt;/name&gt;
          &lt;url&gt;http://localhost:8081/nexus/content/repositories/releases&lt;/url&gt;
      &lt;/repository&gt;
  &lt;/distributionManagement&gt;
  
  &lt;/project&gt;
  </code></pre>
  
  <h3>Project A's <code>pom.xml</code></h3>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
    &lt;groupId&gt;com.a.batch&lt;/groupId&gt;
  
      &lt;parent&gt;
          &lt;groupId&gt;com.demo.parent&lt;/groupId&gt;
          &lt;artifactId&gt;Parent&lt;/artifactId&gt;
          &lt;version&gt;0.01-SNAPSHOT&lt;/version&gt;
      &lt;/parent&gt;
  
    &lt;artifactId&gt;A&lt;/artifactId&gt;
    &lt;packaging&gt;war&lt;/packaging&gt;
    &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
    &lt;name&gt;A Maven Webapp&lt;/name&gt;
    &lt;url&gt;http://localhost:8081/nexus/content/repositories/releases&lt;/url&gt;
  
    &lt;dependencies&gt;
          &lt;!-- Spring ORM support --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-orm&lt;/artifactId&gt;
              &lt;version&gt;3.2.13.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;!-- Spring Batch --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.batch&lt;/groupId&gt;
              &lt;artifactId&gt;spring-batch-core&lt;/artifactId&gt;
              &lt;version&gt;3.0.1.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.batch&lt;/groupId&gt;
              &lt;artifactId&gt;spring-batch-infrastructure&lt;/artifactId&gt;
              &lt;version&gt;3.0.1.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.axis2&lt;/groupId&gt;
              &lt;artifactId&gt;axis2&lt;/artifactId&gt;
              &lt;version&gt;1.6.2&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.xmlbeans&lt;/groupId&gt;
              &lt;artifactId&gt;xmlbeans&lt;/artifactId&gt;
              &lt;version&gt;2.5.0&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.axis2&lt;/groupId&gt;
              &lt;artifactId&gt;axis2-transport-local&lt;/artifactId&gt;
              &lt;version&gt;1.6.1&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.axis2&lt;/groupId&gt;
              &lt;artifactId&gt;axis2-transport-http&lt;/artifactId&gt;
              &lt;version&gt;1.6.1&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;commons-codec&lt;/groupId&gt;
              &lt;artifactId&gt;commons-codec&lt;/artifactId&gt;
              &lt;version&gt;1.6&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.poi&lt;/groupId&gt;
              &lt;artifactId&gt;poi&lt;/artifactId&gt;
              &lt;version&gt;3.9&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;c3p0&lt;/groupId&gt;
              &lt;artifactId&gt;c3p0&lt;/artifactId&gt;
              &lt;version&gt;0.9.1.1&lt;/version&gt;
          &lt;/dependency&gt;
  &lt;/project&gt;
  </code></pre>
  
  <h3>Project <code>B</code>'s <code>pom.xml</code></h3>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;groupId&gt;com.B&lt;/groupId&gt;
      &lt;parent&gt;
          &lt;groupId&gt;com.demo.parent&lt;/groupId&gt;
          &lt;artifactId&gt;Parent&lt;/artifactId&gt;
          &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
      &lt;/parent&gt;
      &lt;artifactId&gt;B&lt;/artifactId&gt;
      &lt;packaging&gt;war&lt;/packaging&gt;
      &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
      &lt;name&gt;B Maven Webapp&lt;/name&gt;
      &lt;!--url&gt;http://maven.apache.org&lt;/url--&gt;
       &lt;url&gt;http://localhost:8081/nexus/content/repositories/releases&lt;/url&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;junit&lt;/groupId&gt;
              &lt;artifactId&gt;junit&lt;/artifactId&gt;
              &lt;version&gt;3.8.1&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;log4j&lt;/groupId&gt;
              &lt;artifactId&gt;log4j&lt;/artifactId&gt;
              &lt;version&gt;1.2.14&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-webmvc&lt;/artifactId&gt;
              &lt;version&gt;3.2.13.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-web&lt;/artifactId&gt;
              &lt;version&gt;3.2.13.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-core&lt;/artifactId&gt;
              &lt;version&gt;3.2.13.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-context-support&lt;/artifactId&gt;
              &lt;version&gt;3.2.13.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-jdbc&lt;/artifactId&gt;
              &lt;version&gt;3.2.13.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;commons-lang&lt;/groupId&gt;
              &lt;artifactId&gt;commons-lang&lt;/artifactId&gt;
              &lt;version&gt;2.2&lt;/version&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>Now when I am building using Jenkins the build is successful but Jenkins is not generating any <code>war</code> file. It is generating three different <code>pom</code> projects instead.</p>
  
  <pre><code>[INFO] A Maven Webapp ........................... SUCCESS [  0.351 s]
  [INFO] Demo Maven Webapp ............................ SUCCESS [  0.056 s]
  [INFO] B Maven Webapp ....................... SUCCESS [  0.075 s]
  
  
  [INFO] ------------------------------------------------------------------------
  [INFO] BUILD SUCCESS
  [INFO] ------------------------------------------------------------------------
  [INFO] Total time: 1.453 s
  [INFO] Finished at: 2016-04-30T02:59:14+05:30
  [INFO] Final Memory: 7M/176M
  [INFO] ------------------------------------------------------------------------
  [JENKINS] Archiving /var/lib/jenkins/jobs/Jenkins_Projects/workspace/A/pom.xml to com.A/A/1.0-SNAPSHOT/A-1.0-SNAPSHOT.pom
  [JENKINS] Archiving /var/lib/jenkins/jobs/Jenkins_Projects/workspace/B/pom.xml to com.B/B/1.0-SNAPSHOT/B-1.0-SNAPSHOT.pom
  [JENKINS] Archiving /var/lib/jenkins/jobs/Jenkins_Projects/workspace/Demo/pom.xml to Demo.Demo/Parent/1.0-SNAPSHOT/Parent-1.0-SNAPSHOT.pom
  channel stopped
  Finished: SUCCESS
  </code></pre>
  
  <p>If I build the projects standalone, the builds are successful and I am getting <code>.war</code> files as well.</p>
  
  <p>But when I am building from same repository <code>Demo</code> and using parent <code>pom.xml</code> I do not see any <code>.war</code> files though the build is successful.</p>
  
  <p>How do I solve this problem?</p>
  
  <p>What is the way to build two projects together?</p>
  
  <p>Why am I getting <code>pom</code> instead of <code>.war</code>?</p>
  
  <p>Why am I getting <code>Parent-1.0-SNAPSHOT.pom</code> though this is not a project. it is just a <code>pom</code> inside repository.</p>
  
  <p>Please guide me.</p>