D
D
Denis2016-03-09 20:25:27
Maven
Denis, 2016-03-09 20:25:27

How to build individual modules in a multi-module maven project?

Please tell me how best to organize a multi-module project with the ability to assemble independent modules.
Perhaps I incorrectly initially planned the structure of such a project. I am new to maven and Java development in general.
The current structure is as follows:

- general [parent]
  - src
    -main
      -java
        - JSON_Builder (класс для специфической компоновки JSON)
        - JSON_Parser (тоже что-то специфическое)
- module_1
  - src
    -main
      -java
        - некий класс, использующий JSON_Builder
- module_2
  - src
    -main
      -java
        - некий класс, использующий JSON_Parser

The task is to assemble the functionality of some module at any time (you don’t have to rely on the life cycle of versions of the general module).
Is it advisable to copy dependent classes to the target/dependencies of the module being built at build time?
If there are links to the practices of creating complex dependency projects at hand, I would be very grateful.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Evhen, 2016-03-10
@DZD

  1. Somehow I have not yet met that some classes were declared in the parent. It is designed to combine modules and define common settings and dependencies;
    Here you can see an example of a multi-module project

P
Praytic, 2016-03-09
@Praytic

You create pom.xml, which will be your main one, and it will store links to pom, which you will have in each module is stored like this:

<modules>
        <module>child1</module>
        <module>child2</module>
    </modules>

Then you create a pom.xml for each module that will refer to its parent:
<parent>
        <groupId>groupIdParent</groupId>
        <artifactId>artifactIdParent</artifactId>
        <version>1.0</version>
    </parent>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question