This is a multi-module project:
- /: The root (parent of all submodules)
- metricshub-engine: The brain, the heart of this project. It houses the core logic and essential functionalities that power the entire system.
- hardware: Hardware Energy and Sustainability module, dedicated to managing and monitoring hardware-related metrics, focusing on energy consumption and sustainability aspects.
- metricshub-agent: The MetricsHub Agent module includes a Command-Line Interface (CLI) and is responsible for interacting with the MetricsHub engine. It acts as an entry point, collecting and transmitting data to the OpenTelemetry Collector.
- metricshub-windows: Builds the MSI (Microsoft Installer) package for MetricsHub on Windows platforms.
- metricshub-rhel: Builds the RPM (Red Hat Package Manager) package.
- metricshub-debian: Builds the Debian package of MetricsHub.
- metricshub-doc: Houses the documentation for MetricsHub.
- Have Maven 3.x properly installed and configured, with access to Sentry's repository.
- Latest LTS Release of JDK 21.
To build the MetricsHub package, from ./metricshub:
$ mvn clean package- Host: Windows
- WiXToolSet Installation: Download and install WiX Toolset under
C:\Program Files (x86)\WiX Toolset v3.11. - Execute the
mvn packagecommand within the MetricsHub root directory (metricshub). You can find the.msipackage in themetricshub/metricshub-windows/targetdirectory upon completion (metricshub-windows-<version>.msi).
- Host: Debian Linux
- Additional Packages: Install the following packages:
fakeroot(/usr/bin/fakeroot)gcc-multilib
- Execute the
mvn packagecommand within the MetricsHub root directory (metricshub). You can find the.debpackage in themetricshub/metricshub-debian/targetdirectory upon completion (metricshub-debian-<version>-amd64.deb).- The
Dockerpackage that is compatible with thedebian:latestimage will also be generated under themetricshub/metricshub-debian/targetdirectory (metricshub-debian-<version>-docker.tar.gz).
- The
- Host: Red Hat Enterprise Linux (Centos, etc.)
- Additional Packages: Install the
rpm-buildpackage (/usr/bin/rpmbuild). - Execute the
mvn packagecommand within the MetricsHub root directory (metricshub). You can find the.rpmpackage in themetricshub/metricshub-rhel/targetdirectory upon completion (metricshub-rhel-<version>-1.x86_64.rpm).
In this project, we use Checkstyle to ensure consistent and clean Java code across our codebase.
Maven Checkstyle Plugin is configured globally in the main pom.xml file, and it verifies the Java code during the build process:
<plugin>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<sourceEncoding>${project.build.sourceEncoding}</sourceEncoding>
<configLocation>checkstyle.xml</configLocation>
</configuration>
<executions>
<execution>
<id>validate</id>
<phase>validate</phase>
<goals>
<goal>checkstyle</goal>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>The Checkstyle rules that govern our code quality and style are defined in the ./checkstyle.xml file. It's important to adhere to these rules to maintain code consistency and quality throughout the project.
The build will fail if one or more Checkstyle rules are violated.
To perform Checkstyle analysis and generate a report on violations, navigate to the directory of the Maven project you wish check and run the following mvn command:
mvn checkstyle:checkstyleAll the encountered Checkstyle issues are reported under the target/site directory.
To perform Checkstyle analysis and output violations to the console, navigate to the directory of the Maven project you wish check and run the following mvn command:
mvn checkstyle:checkIn this project, we maintain code formatting using prettier-java, a tool that helps ensure clean and consistent Java code. It automatically formats your code according to a predefined set of rules.
To automatically format the Java code in a specific Maven module, navigate to the directory of the Maven project you wish to format and run the following mvn command:
mvn prettier:writeTo validate the formatted code, navigate to the directory of the Maven project you wish to check and run the following mvn command:
mvn prettier:checkThe build will fail if you forgot to run Prettier.
Before you submit a PR, make sure to use the available tools for code formatting, and ensure that the style checks and unit tests pass.
License is GNU Affero General Public License v3.0. Each source file must include the AGPL-3.0 header (build will fail otherwise). To update source files with the proper header, simply execute the below command:
mvn license:update-file-header