This document outlines the process to set up a development environment for the mirror node. It covers the required software, environment setup, IDE configurations, project compilation, and how to run tests.
To contribute to the mirror node project, you need to install the following software and tools:
Requires Java 25 for development. On Ubuntu and macOS we recommend using SDKMAN! to manage JVM versions:
curl -s "https://get.sdkman.io" | bash
sdk install java 25-tem
sdk use java 25-tem
java -versionDocker is used to manage and run containerized services (such as databases) for the mirror node. To install Docker, follow the get started guide on docker.com.
We follow best practices to ensure that code quality and maintainability remain high. Below are the key coding standards to follow:
- Java Coding Style: Follow the Google Java Style Guide for writing clean and readable Java code.
- Kotlin Style: Follow the Kotlin Style Guide for Kotlin-based files.
- Spotless Plugin: The project uses the Spotless plugin to enforce consistent formatting. You can run this before
submitting code:
./gradlew spotlessApply
We recommend using IntelliJ IDEA for development.
-
Install IntelliJ IDEA:
- Download IntelliJ IDEA from JetBrains.
-
Set up Project SDK:
- Go to
File > Project Structure > Project. - Set Project SDK to the version of Java installed previously.
- Set Project language level to
SDK Default.
- Go to
-
Gradle Configuration:
- Go to
IntelliJ IDEA > Settings > Build, Execution, Deployment > Build Tools > Gradle - Ensure Gradle JVM is set to
Project SDK.
- Go to
-
Enable Save Actions:
- Go to
IntelliJ IDEA > Settings > Tools > Actions on Save - Enable the following save actions:
Reformat code: Ensures consistent code style by reformatting code on save.Optimize imports: Automatically removes unused imports and arranges them.Rearrange code: Arranges code based on predefined rules.Run code cleanup: Cleans up unnecessary elements in the code.Build project: Automatically builds the project upon saving if needed.
- Go to
-
Import Java Code Style:
- Download the Java code file located in the repository at docs/palantir-style.xml
- Go to
IntelliJ IDEA > Settings > Editor > Code Style > Java. - Choose
⚙️ (gear icon) > Import Scheme > IntelliJ IDEA code style XML. - Import the downloaded Java code style file to ensure consistent formatting across the project.
This project uses Gradle for building and managing dependencies. It's not necessary to install Gradle locally as the project automatically downloads it via the Gradle Wrapper.
-
Clean and Build the Project: Run the following command to clean and build the project:
./gradlew clean build
This command will:
- Clean previous builds.
- Compile the source code.
- Download any required dependencies.
- Run tests.
-
Compile Specific Subprojects: If you want to build a specific subproject (e.g.,
monitor), run:./gradlew :monitor:build
You can run the project’s tests using Gradle.
-
Run All Tests: To run all the tests, use:
./gradlew test -
Run Tests for a Specific Subproject: To run tests for a specific subproject (e.g.,
common):./gradlew :common:test
-
Running Specific Tests: You can also run specific test classes or methods:
./gradlew test --tests "*YourTestClassName"
or:
./gradlew test --tests "*YourTestClassName.yourTestMethodName"
The mirror node often depends on containerized services such as PostgreSQL or Redis. These services are
defined in docker-compose files within the repository.
-
Start Docker Services: To start all services needed for local development:
docker compose up
-
Stop Docker Services: To stop the services:
docker compose down
For production or deployment, you may need to generate container images.
-
Build Container Images: You can build container images using Gradle and specify custom properties to control the platform, registry, and tag.
./gradlew dockerBuild \ -PimagePlatform=linux/amd64 \ -PimageRegistry=docker.io/mydockerid \ -PimageTag=1.0.0-SNAPSHOT
-
Push Container Images: After building the container image, you can push it to the specified image registry to make it available for use in a remote Kubernetes environment.
./gradlew dockerPush \ -PimagePlatform=linux/amd64 \ -PimageRegistry=docker.io \ -PimageTag=1.0.0-SNAPSHOT
Note: Ensure you are logged into the image registry if authentication is required. This command will push the image with the specified tag to the registry.