Dependency Management
Centralized Maven Bill of Materials (BOM) for all the OpenEPCIS modules.
Quick links
Please find below the links to the codes referenced on this documentation page:
• EPCIS parent POM for dependency management application code : https://github.com/openepcis/openepcis-bom
Introduction
The OpenEPCIS-BOM project serves as a centralized Maven Bill of Materials (BOM) for all OpenEPCIS project. It simplifies dependency management across all OpenEPCIS modules by providing a consistent and versioned set of dependencies. This documentation aims to explain the purpose, benefits, and usage of this BOM, offering a guide for developers and users working with OpenEPCIS.
What is a Maven BOM?
A Maven Bill of Materials (BOM) is a special type of POM (Project Object Model) that is used to control the versions of dependencies used in a project and its sub-modules. It does not contain any build logic or source code but instead defines a list of dependencies with their respective versions.
Key characteristics of a Maven BOM:
- Dependency Management: It centralizes dependency version management, ensuring consistency across multiple modules.
- Version Control: It allows for easy updates and maintenance of dependency versions.
- Simplified Dependency Declarations: Child modules can declare dependencies without specifying versions, and simply inherit them from the BOM.
- Reduced Conflicts: It minimizes the risk of dependency conflicts by enforcing consistent versions.
Benefits of using a BOM:
- Maintainability: Easier to update dependency versions across multiple modules.
- Consistency: Ensures all modules use the same versions of dependencies.
- Improved Build Reliability: Reduces the risk of unexpected dependency conflicts.
OpenEPCIS-BOM
The OpenEPCIS project utilizes a modular architecture, where individual modules rely on various dependencies. To ensure uniform dependency versions and management across the project, the OpenEPCIS-BOM project was created.
Functionality:
- The project defines a POM file that lists all dependencies required by various OpenEPCIS modules.
- It specifies the versions of these dependencies, ensuring consistency across the project.
- OpenEPCIS modules can import this BOM to inherit the dependency versions.
- If new dependencies are introduced to OpenEPCIS modules, they are added to the OpenEPCIS-BOM with specified versions.
Using the OpenEPCIS-BOM
To use the OpenEPCIS-BOM in OpenEPCIS module, we need to import it into your module's POM file.
Steps:
- Import the BOM:
- Add the following
<parent>
section to module's POM file. - Replace
${openepcis.version}
with the desired version of the OpenEPCIS-BOM. This variable is typically defined in the parent pom.
- Add the following
<parent>
<groupId>io.openepcis</groupId>
<artifactId>openepcis-bom</artifactId>
<version>`${openepcis.version}`</version>
</parent>
- Declare Dependencies:
- In the
<dependencies>
section of your module's POM file, declare the dependencies you need without specifying versions. - The versions will be inherited from the OpenEPCIS-BOM.
- In the
<dependencies>
<!-- Simple Logging Facade for Java (SLF4J) API -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<!-- Java library for processing JSON data -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
</dependencies>
Example POM Snippet:
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.openepcis</groupId>
<artifactId>openepcis-bom</artifactId>
<version>`${openepcis.version}`</version>
</parent>
<artifactId>openepcis-module-name</artifactId>
<name>openepcis-module-name</name>
<packaging>pom</packaging>
<dependencyManagement>
<dependencies>
<!-- Simple Logging Facade for Java (SLF4J) API -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<!-- Java library for processing JSON data -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
</dependencies>
</dependencyManagement>
</project>