c-guntur / maven4

Comparison between Apache Maven 3 and Apache Maven 4

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Maven Multi Module

Slides for this project:

About the project

This is a greeter project. The running of the main class in this project prints a
"Good [morning, afternoon or evening], today is: <yyyy-MM-dd>".

Module dependency

The root POM is an aggregator that declares three modules:

datetime-fetcher

The datetime-fetcher module provides the local date time as well as a mapper to time periods of morning, afternoon and evening. The module-info.java exports and opens packages for use in other modules. The POM declares itself a child of the aggregator root POM.

greeting

The greeting module formats the date time information and time period into a string. The module-info.java specifies the requirement of the datetime-fetcher module and exports the greeting classes for use in other modules. The POM declares itself a child of the aggregator root POM and among other things, declares a dependency on the datetime-fetcher jar.

greeting-generator

The greeting-generator module invokes the greeting module. The module-info.java specifies the requirement of the greeting module. The POM declares itself a child of the aggregator root POM and among other things, declares a dependency on the greeting jar.

Understanding "modules"

Maven modules

Maven has a concept of modules that define project structure to better organize grouping of code and provide for a possible independent control of versions and dependencies. A POM declaring modules specifies a downward hierarchy of sub-projects that are aggregated. A child POM can additionally declare a parent to declare an upward hierarchy for the specific subproject.

IntelliJ modules

IntelliJ modules are quite similar in perspective to maven modules. IntelliJ modules focus on specific JDK versions, customizable sources and resources per module etc. Each module notably, has a specific entry in the .idea/modules.xml and .idea/compiler.xml, among other things.

Java modules

Java modules focus on strong encapsulation and setting up a modular set of permissions and restrictions on a package-level for Java classes. Java modules do not control either the versions of Java used or the version of the subproject artifact.

Project Structure

.
|____pom.xml                        <----- Aggregator (reactor) POM parent for all others
|____IDE                            <----- IDE Run Configuration for a maven clean install
|____README.adoc                    <----- This file
|____datetime-fetcher
| |____pom.xml                      <----- datetime-fetcher child POM
| |____src
| | |____main
| | | |____java
| | | | |____module-info.java       <----- Exports and Opens a few packages
| | | | |____none
| | | | | |____cvg
| | | | | | |____maven
| | | | | | | |____datetime
| | | | | | | | |____fetch          <----- Package exported (and open)
| | | | | | | | |____runtime        <----- Package opened
| | |____test
| | | |____java
| | | | |____none
| | | | | |____cvg
| | | | | | |____maven
| | | | | | | |____datetime
| | | | | | | | |____fetch          <----- Package exported (and open)
|____greeting
| |____pom.xml
| |____src
| | |____main
| | | |____java
| | | | |____module-info.java       <----- Requires datetime-fetcher & exports  greeting
| | | | |____none
| | | | | |____cvg
| | | | | | |____maven
| | | | | | | |____greeting         <----- Package exported
|____greeting-generator
| |____pom.xml
| |____src
| | |____main
| | | |____java
| | | | |____module-info.java       <----- Required modules declared
| | | | |____none
| | | | | |____cvg
| | | | | | |____maven
| | | | | | | |____datetime
| | | | | | | | |____greetinggen

About

Comparison between Apache Maven 3 and Apache Maven 4

License:MIT License


Languages

Language:Java 100.0%