1

I am trying to figure out how to use Maven for the build process of the project I am involved in. I want something like this:

Let's say we have two or three projects with the following structure:

 .
   |-src
   |---main
   |-----java
   |-------com
   |---------mycompany
   |-----------app
   |---test
   |-----java
   |-------com
   |---------mycompany
   |-----------app

Building this project will be easy using a pom.xml file. Let's say this file/folder structure are under sampleProject1 and I want to have another sample project called sampleProject2, which end up like this:

sampleProject1
   |-src
   |---main
   |-----java
   |-------com
   |---------mycompany
   |-----------app
   |---test
   |-----java
   |-------com
   |---------mycompany
   |-----------app
   |-target
   |---classes
   |-----com
   |-------mycompany
   |---------app
   |---maven-archiver
   |---surefire-reports
   |---test-classes
   |-----com
   |-------mycompany
   |---------app



sampleProject2
   |-src
   |---main
   |-----java
   |-------com
   |---------mycompany
   |-----------app
   |---test
   |-----java
   |-------com
   |---------mycompany
   |-----------app
   |-target
   |---classes
   |-----com
   |-------mycompany
   |---------app
   |---maven-archiver
   |---surefire-reports
   |---test-classes
   |-----com
   |-------mycompany
   |---------app

I can use pom.xml in the sampleProject1 and sampleProject2 to build the project. What I am looking for is to have one pom.xml file to build this two projects. I don't want to copy two projects in one folder structure and create a new sampleProject3 which have all the files.

My background is Ant, so may be I need to think different using Maven, appreciate any insights.

1 Answer 1

4

You have to create a multi-module build:

Parent
  +--- pom.xml
  +--- project1
          +--- pom.xml
          +--- src/...
  +--- project2
          +--- pom.xml
          +--- src/...

Take a deeper look into the documentation of Maven about multi-module builds.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.