To start using Naryo, you need to embed and instantiate it manually inside your project. There are two main ways to use this library:
- ✅ Spring Boot integration (recommended) — Simplifies setup using Spring context and YAML configuration.
- ⚙️ Core module (framework-agnostic) — Gives you full control but requires manual instantiation and wiring.
Since our artifacts are hosted on GitHub Package Registry, you'll need to configure authentication in your Gradle or Maven settings. Please refer to the GitHub documentation to configure the access token.
Add the following to your settings.gradle or build.gradle file:
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/LF-Decentralized-Trust-labs/Naryo")
credentials {
username = project.findProperty("gpr.user") ?: System.getenv("GITHUB_USERNAME")
password = project.findProperty("gpr.key") ?: System.getenv("GITHUB_TOKEN")
}
}
mavenCentral()
}You can provide your GitHub credentials either through environment variables or Gradle properties in your
gradle.properties file:
gpr.user=YOUR_GITHUB_USERNAME
gpr.key=YOUR_GITHUB_PERSONAL_ACCESS_TOKENMake sure your GitHub token has the
read:packagesscope.
Add the following to your settings.xml file:
<settings>
<servers>
<server>
<id>github</id>
<username>${env.GITHUB_USERNAME}</username>
<password>${env.GITHUB_TOKEN}</password>
</server>
</servers>
</settings>And add this repository to your pom.xml:
<repositories>
<repository>
<id>github</id>
<url>https://maven.pkg.github.com/LF-Decentralized-Trust-labs/Naryo</url>
</repository>
</repositories>Gradle
Add Spring Boot plugin and dependency management (recommended setup, see more in here):
plugins {
id 'java'
id 'org.springframework.boot' version '3.5.4'
id 'io.spring.dependency-management' version '1.1.7'
}
ext {
naryoVersion = "0.0.1" // Replace with the actual version
}
dependencies {
// Core module
implementation("io.naryo:core:${naryoVersion}")
// Spring Boot integration
implementation("io.naryo:spring-core:${naryoVersion}")
// Typical Spring Boot starters you may need
implementation("org.springframework.boot:spring-boot-starter")
implementation("org.springframework.boot:spring-boot-starter-web")
// ...
}Maven
Add Spring Boot parent for dependency management and starters:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.5.4</version>
</parent>
<variables>
<naryoVersion>0.0.1</naryoVersion> // Replace with the actual version
</variables>
<dependencies>
<!-- Core module -->
<dependency>
<groupId>io.naryo</groupId>
<artifactId>core</artifactId>
<version>${naryoVersion}</version>
</dependency>
<!-- Spring Boot integration -->
<dependency>
<groupId>io.naryo</groupId>
<artifactId>spring-core</artifactId>
<version>${naryoVersion}</version>
</dependency>
<!-- Spring Boot starters -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>-
Add the Spring Boot plugin and dependency management (for Gradle:
org.springframework.bootandio.spring.dependency-management; for Maven: usespring-boot-starter-parent) and include the needed Spring Boot starters (for example,spring-boot-starter,spring-boot-starter-web) along with Naryo’s spring-core dependency. -
Define your configuration in
application.yml:naryo: nodes: - name: default #...
Please refer to the Configuration Documentation for more details.
-
Start naryo when your application starts:
@SpringBootApplication
public class Application implements InitializingBean {
private final NodeInitializer nodeInitializer;
public Application(NodeInitializer nodeInitializer) {
this.nodeInitializer = nodeInitializer;
}
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Override
public void afterPropertiesSet() throws Exception {
NodeContainer container = nodeInitializer.init();
container.start();
}
}Spring will automatically parse the YAML and inject dependencies.
-
Instantiate all required components manually and start them:
NodeRunner nodeRunner = new NodeRunner(...); NodeContainer container = new NodeContainer(List.of(nodeRunner)); container.start();
-
You are responsible for building and wiring all components. No YAML parsing is provided out-of-the-box.
Need help setting it up in your use case? Let us know or check out the tutorials.