Skip to content

Getting Started

A248 edited this page Mar 12, 2021 · 8 revisions

First, you'll need to add the dependency to your project

Dependency Information

The artifact you choose will depend on which configuration format you desire. In this example, I'll use YAML which relies on the SnakeYaml library.

Maven Example

<dependency>
	<groupId>space.arim.dazzleconf</groupId>
	<artifactId>dazzleconf-ext-snakeyaml</artifactId>
	<version>1.2.0-M2</version>
</dependency>

Gradle Example

dependencies {
    implementation 'space.arim.dazzleconf:dazzleconf-ext-snakeyaml:1.2.0-M2'
}

Version

The latest version of DazzleConf may be slightly more up-to-date than the one in this wiki.

Maven Central

Available formats

You only need to declare a dependency on the format you choose. There is a transitive dependency on dazzleconf-core.

Gson

Dependency: space.arim.dazzleconf:dazzleconf-ext-gson

SnakeYaml

Dependency: space.arim.dazzleconf:dazzleconf-ext-snakeyaml

Snapshot dependencies

If you want to use a version which ends in -SNAPSHOT, you will need to add the OSSRH repository.

With Maven:

<repository>
  <id>ossrh</id>
  <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</repository>

With Gradle:

repositories {
    maven {
        url "https://oss.sonatype.org/content/repositories/snapshots/"
    }
}

Shading and Relocation

In order for your project to work at runtime, you'll need to shade this library using your build system.

With Maven, that would be the maven-shade-plugin. With Gradle, shadowJar.

I won't go over the specifics of shading because it is assumed you already know that.

Relocation

Relocating space.arim.dazzleconf is important. Always relocate shaded dependencies when there is the possibility of a conflict.

Transitive Dependencies

Depending on the configuration format you use, your build setup may inadvertently shade the configuration format library, such as SnakeYaml or Gson.

In several cases, the configuration library you use is already provided by the environment, and shouldn't be shaded. To fix this, declare the dependency explicitly and set its scope to provided:

<dependency>
	<groupId>org.yaml</groupId>
	<artifactId>snakeyaml</artifactId>
	<version>1.28</version>
	<scope>provided</scope> <!-- Prevents it from being shaded -->
</dependency>
Clone this wiki locally