Bu tag ana proje (parent proje)pom.xml dosyasında kullanılır. Proje'ye ait alt modülleri belirtir. Açıklaması şöyle.
When you create a module, you must specify a parent project. When you specify the parent project, it adds a <modules> section to the parent projects pom.xml. That section basically says to the parent project, "run every command I get against all of my modules first". So if you run, "mvn package" on the top level project, it will run "mvn package" against all it's module projects first.
Ayrıca parent projedeki paketleme tipi pom olmalıdır. Açıklaması şöyle
The main difference between multi-module parent pom and normal pom is its packaging type. For a multi-module parent pom, its packaging type becomes ‘pom’.<packaging>pom</packaging>Also in parent pom, it is referring to the submodules with <submodule> tag.<modules><module>email-service</module><module>frontend</module><module>data-service</module></modules>
Maven modüller arasındaki bağımlılıkları da kendisi hallediyor. Açıklaması şöyle
When Maven is executed against a project with submodules, Maven first loads the parent POM and locates all of the submodule POMs. Maven then puts all of these project POMs into something called the Maven Reactor which analyzes the dependencies between modules. The Reactor takes care of ordering components to ensure that interdependent modules are compiled and installed in the proper order....Once the Reactor figures out the order in which projects must be built, Maven then executes the specified goals for every module in the multi-module build.
Ben şu yapıda kullandım.
myproject/
myproject-core/
myproject-api/
myproject-app/
pom.xml
Örnek
Ana proje (A) ve bunun B,C alt projeleri olsun. A projesinde şöyle yaparız.
<project ...>
<groupId>com.foo.bar</groupId>
<artifactId>parent</artifactId>
<packaging>pom</packaging>
<version>2.3.0</version>
<modules>
<module>B</module>
<module>C</module>
</modules>
<dependencyManagement>
...
</dependencyManagement>
</project>
Burada packaging olarak pom seçiliyor. Açıklaması şöyle. Çünkü ana projenin bir jar üretmesi beklenmiyor.The parent project doesn’t create a JAR or a WAR like our previous projects; instead, it is simply a POM that refers to other Maven projects. The appropriate packaging for a project like simple-parent that simply provides a Project Object Model is pom.
Hiç yorum yok:
Yorum Gönder