0

I have a scenario as below:

we don't use the module and cant auto build.

there are four projects depend one by one, just simple dependency such as

D Service:
<dependency>
     <groupId>c</groupId>   
     <artifactId>c</artifactId> 
</dependency> 
C service: 
<dependency>
    <groupId>B</groupId>    
    <artifactId>B</artifactId> 
</dependency> 
 ...

if we modify A, we must mvn insall the project one by one. So my question is "does the maven provide the command to install all the service one time?"

Eumendies
  • 93
  • 1
  • 13

1 Answers1

0

You need a parent project that declares:

<modules>
    <module>B</module>
    <module>C</module>
    <module>D</module>
</modules>

And in each module, you will need to declare the parent like (not a mandatory step, but a good practice, see @Sean's comment):

<parent>
    <artifactId>artifactIdA</artifactId>
    <groupId>groupIdA</groupId>
    <version>VersionInA</version>
</parent>

See this guide for more examples. Check also Maven the complete reference for more information on how Maven works.

Edited: Add of @Sean's comment on the answer

Adonis
  • 4,670
  • 3
  • 37
  • 57
  • The second part is optional Projects in a Maven reactor do not need to have a common parent. It's just a good practice. – Sean Patrick Floyd Mar 08 '17 at 14:01
  • Correct me if I'm wrong, but when submodules depend on one another, the parent declaration needs to be done so that when building the parent, it gets the right build order, or did I misunderstand something? – Adonis Mar 08 '17 at 14:04
  • You build the reactor root, which may or may not be the parent. Maven is smart enough to sort the projects by the dependency tree, even if they don't have a common parent. – Sean Patrick Floyd Mar 08 '17 at 14:07
  • I know the modules, but now the project doesn't allow me to refactor the structure. so I need use a command to implement it – Eumendies Mar 09 '17 at 04:35
  • You can't from the command line, see @khmarbaise's post: http://stackoverflow.com/a/4023629/4121573 – Adonis Mar 09 '17 at 10:55