Skip to content

Commit b2614dc

Browse files
committed
Add Spring Boot starter for aether-datafixers: auto-configuration, actuator info contributor, and comprehensive tests
1 parent a38d32f commit b2614dc

36 files changed

Lines changed: 9277 additions & 13 deletions

README.md

Lines changed: 150 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ inspired by Minecraft's DataFixer Upper (DFU), with a focus on **simplicity**, *
2020
-**Testkit** — Fluent test data builders, custom assertions, and test harnesses for DataFix testing
2121
-**CLI Tool** — Migrate and validate data files from the command line with batch processing
2222
-**Schema Tools** — Schema diffing, validation, migration analysis, and type introspection
23+
-**Spring Boot 3.x** — Auto-configuration, MigrationService with fluent API, Actuator integration
2324
-**Migration Diagnostics** — Opt-in structured reports with timing, applied fixes, and snapshots
2425
-**Extended Rewrite Rules** — Batch operations, path-based transforms, conditional rules
2526
-**High-Performance APIs**`Rules.batch()` for single-pass multi-operation transforms
@@ -35,6 +36,7 @@ inspired by Minecraft's DataFixer Upper (DFU), with a focus on **simplicity**, *
3536
- **aether-datafixers-testkit** — Testing utilities for DataFix, Schema, and migration testing
3637
- **aether-datafixers-cli** — Command-line interface for data migration and validation
3738
- **aether-datafixers-schema-tools** — Schema analysis, validation, diffing, and introspection
39+
- **aether-datafixers-spring-boot-starter** — Spring Boot 3.x auto-configuration with Actuator support
3840
- **aether-datafixers-examples** — Practical examples demonstrating real-world usage
3941
- **aether-datafixers-bom** — Bill of Materials for coordinated dependency management
4042

@@ -84,7 +86,7 @@ Dynamic<?> updated = fixer.update(
8486

8587
```xml
8688
<dependency>
87-
<groupId>de.splatgames.aether</groupId>
89+
<groupId>de.splatgames.aether.datafixers</groupId>
8890
<artifactId>aether-datafixers-core</artifactId>
8991
<version>0.3.0</version>
9092
</dependency>
@@ -94,15 +96,15 @@ Dynamic<?> updated = fixer.update(
9496

9597
```groovy
9698
dependencies {
97-
implementation 'de.splatgames.aether:aether-datafixers-core:0.3.0'
99+
implementation 'de.splatgames.aether.datafixers:aether-datafixers-core:0.3.0'
98100
}
99101
```
100102

101103
**Gradle (Kotlin)**
102104

103105
```kotlin
104106
dependencies {
105-
implementation("de.splatgames.aether:aether-datafixers-core:0.3.0")
107+
implementation("de.splatgames.aether.datafixers:aether-datafixers-core:0.3.0")
106108
}
107109
```
108110

@@ -120,7 +122,7 @@ The Bill of Materials (BOM) ensures consistent versions across all Aether Datafi
120122
<dependencyManagement>
121123
<dependencies>
122124
<dependency>
123-
<groupId>de.splatgames.aether</groupId>
125+
<groupId>de.splatgames.aether.datafixers</groupId>
124126
<artifactId>aether-datafixers-bom</artifactId>
125127
<version>0.3.0</version>
126128
<type>pom</type>
@@ -132,11 +134,11 @@ The Bill of Materials (BOM) ensures consistent versions across all Aether Datafi
132134
<dependencies>
133135
<!-- No version needed -->
134136
<dependency>
135-
<groupId>de.splatgames.aether</groupId>
137+
<groupId>de.splatgames.aether.datafixers</groupId>
136138
<artifactId>aether-datafixers-core</artifactId>
137139
</dependency>
138140
<dependency>
139-
<groupId>de.splatgames.aether</groupId>
141+
<groupId>de.splatgames.aether.datafixers</groupId>
140142
<artifactId>aether-datafixers-codec</artifactId>
141143
</dependency>
142144
</dependencies>
@@ -146,23 +148,23 @@ The Bill of Materials (BOM) ensures consistent versions across all Aether Datafi
146148

147149
```groovy
148150
dependencies {
149-
implementation platform('de.splatgames.aether:aether-datafixers-bom:0.3.0')
151+
implementation platform('de.splatgames.aether.datafixers:aether-datafixers-bom:0.3.0')
150152
151153
// No version needed
152-
implementation 'de.splatgames.aether:aether-datafixers-core'
153-
implementation 'de.splatgames.aether:aether-datafixers-codec'
154+
implementation 'de.splatgames.aether.datafixers:aether-datafixers-core'
155+
implementation 'de.splatgames.aether.datafixers:aether-datafixers-codec'
154156
}
155157
```
156158

157159
**Gradle (Kotlin)**
158160

159161
```kotlin
160162
dependencies {
161-
implementation(platform("de.splatgames.aether:aether-datafixers-bom:0.3.0"))
163+
implementation(platform("de.splatgames.aether.datafixers:aether-datafixers-bom:0.3.0"))
162164

163165
// No version needed
164-
implementation("de.splatgames.aether:aether-datafixers-core")
165-
implementation("de.splatgames.aether:aether-datafixers-codec")
166+
implementation("de.splatgames.aether.datafixers:aether-datafixers-core")
167+
implementation("de.splatgames.aether.datafixers:aether-datafixers-codec")
166168
}
167169
```
168170

@@ -351,6 +353,138 @@ Add to your project:
351353

352354
---
353355

356+
## 🍃 Spring Boot Integration
357+
358+
The `aether-datafixers-spring-boot-starter` provides comprehensive Spring Boot 3.x integration.
359+
360+
### Installation
361+
362+
**Maven**
363+
364+
```xml
365+
<dependency>
366+
<groupId>de.splatgames.aether.datafixers</groupId>
367+
<artifactId>aether-datafixers-spring-boot-starter</artifactId>
368+
<version>0.4.0</version>
369+
</dependency>
370+
```
371+
372+
**Gradle (Kotlin)**
373+
374+
```kotlin
375+
implementation("de.splatgames.aether.datafixers:aether-datafixers-spring-boot-starter:0.4.0")
376+
```
377+
378+
### Quick Start
379+
380+
1. **Create a DataFixerBootstrap bean:**
381+
382+
```java
383+
@Configuration
384+
public class DataFixerConfig {
385+
@Bean
386+
public DataFixerBootstrap gameBootstrap() {
387+
return new GameDataBootstrap();
388+
}
389+
}
390+
```
391+
392+
2. **Inject and use MigrationService:**
393+
394+
```java
395+
@Service
396+
public class GameService {
397+
private final MigrationService migrationService;
398+
399+
public GameService(MigrationService migrationService) {
400+
this.migrationService = migrationService;
401+
}
402+
403+
public Dynamic<?> migratePlayerData(Dynamic<?> data, int fromVersion) {
404+
MigrationResult result = migrationService
405+
.migrate(data)
406+
.from(fromVersion)
407+
.toLatest()
408+
.execute();
409+
410+
if (result.isSuccess()) {
411+
return result.getData();
412+
}
413+
throw new MigrationException(result.getErrorMessage());
414+
}
415+
}
416+
```
417+
418+
### Configuration Properties
419+
420+
```yaml
421+
aether:
422+
datafixers:
423+
enabled: true # Enable/disable auto-config
424+
default-format: gson # gson | jackson
425+
default-current-version: 200 # Fallback version
426+
domains:
427+
game:
428+
current-version: 200
429+
primary: true
430+
user:
431+
current-version: 150
432+
actuator:
433+
include-schema-details: true
434+
include-fix-details: true
435+
metrics:
436+
timing: true
437+
counting: true
438+
```
439+
440+
### Multi-Domain Support
441+
442+
Support multiple DataFixers with `@Qualifier`:
443+
444+
```java
445+
@Configuration
446+
public class DataFixerConfig {
447+
@Bean
448+
@Qualifier("game")
449+
public DataFixerBootstrap gameBootstrap() {
450+
return new GameDataBootstrap();
451+
}
452+
453+
@Bean
454+
@Qualifier("user")
455+
public DataFixerBootstrap userBootstrap() {
456+
return new UserDataBootstrap();
457+
}
458+
}
459+
460+
// Usage
461+
MigrationResult result = migrationService
462+
.migrate(data)
463+
.usingDomain("game") // Select domain
464+
.from(100)
465+
.toLatest()
466+
.execute();
467+
```
468+
469+
### Actuator Endpoints
470+
471+
| Endpoint | Description |
472+
|------------------------|-------------------------------------------|
473+
| `/actuator/health` | Health indicator showing DataFixer status |
474+
| `/actuator/info` | Schema version information |
475+
| `/actuator/datafixers` | Detailed domain and version info |
476+
477+
### Micrometer Metrics
478+
479+
| Metric | Type | Description |
480+
|---------------------------------------------|--------------|-------------------------|
481+
| `aether.datafixers.migrations.success` | Counter | Successful migrations |
482+
| `aether.datafixers.migrations.failure` | Counter | Failed migrations |
483+
| `aether.datafixers.migrations.duration` | Timer | Migration duration |
484+
| `aether.datafixers.migrations.version.span` | Distribution | Version span statistics |
485+
486+
---
487+
354488
## 📖 Examples
355489

356490
The `aether-datafixers-examples` module provides a complete, runnable example demonstrating real-world usage patterns.
@@ -428,7 +562,10 @@ mvn test
428562
- **Convention checking** — Enforce naming conventions for types, fields, and classes
429563

430564
- **v0.4.0** (next)
431-
- **Spring Boot integration** — Auto-configuration for DataFixer in Spring apps
565+
- **Spring Boot Starter** — Auto-configuration, MigrationService with fluent API
566+
- **Actuator integration** — Health indicator, info contributor, custom endpoint, Micrometer metrics
567+
- **Multi-domain support** — Multiple DataFixers with @Qualifier annotations
568+
- **DynamicOps auto-configuration** — Conditional GsonOps/JacksonOps beans
432569
- **Extra ops modules** — Optional YAML/TOML support (format adapters)
433570
- **Debug utilities** — Pretty printers / tree diff for Dynamic structures (dev-facing)
434571

aether-datafixers-bom/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@
4747
<artifactId>aether-datafixers-cli</artifactId>
4848
<version>${project.version}</version>
4949
</dependency>
50+
<dependency>
51+
<groupId>de.splatgames.aether.datafixers</groupId>
52+
<artifactId>aether-datafixers-spring-boot-starter</artifactId>
53+
<version>${project.version}</version>
54+
</dependency>
5055
</dependencies>
5156
</dependencyManagement>
5257
</project>
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<parent>
8+
<groupId>de.splatgames.aether.datafixers</groupId>
9+
<artifactId>aether-datafixers</artifactId>
10+
<version>0.4.0-SNAPSHOT</version>
11+
</parent>
12+
13+
<artifactId>aether-datafixers-spring-boot-starter</artifactId>
14+
<packaging>jar</packaging>
15+
16+
<name>Aether Datafixers :: Spring Boot Starter</name>
17+
<description>Spring Boot 3.x auto-configuration for Aether Datafixers - provides AetherDataFixer beans,
18+
DynamicOps integration, MigrationService with fluent API, and Actuator endpoints.</description>
19+
20+
<properties>
21+
<spring-boot.version>3.4.1</spring-boot.version>
22+
</properties>
23+
24+
<dependencyManagement>
25+
<dependencies>
26+
<dependency>
27+
<groupId>org.springframework.boot</groupId>
28+
<artifactId>spring-boot-dependencies</artifactId>
29+
<version>${spring-boot.version}</version>
30+
<type>pom</type>
31+
<scope>import</scope>
32+
</dependency>
33+
</dependencies>
34+
</dependencyManagement>
35+
36+
<dependencies>
37+
<!-- ==================== Aether Datafixers Core ==================== -->
38+
<dependency>
39+
<groupId>de.splatgames.aether.datafixers</groupId>
40+
<artifactId>aether-datafixers-api</artifactId>
41+
</dependency>
42+
<dependency>
43+
<groupId>de.splatgames.aether.datafixers</groupId>
44+
<artifactId>aether-datafixers-core</artifactId>
45+
</dependency>
46+
<dependency>
47+
<groupId>de.splatgames.aether.datafixers</groupId>
48+
<artifactId>aether-datafixers-codec</artifactId>
49+
</dependency>
50+
51+
<!-- ==================== Spring Boot Core ==================== -->
52+
<dependency>
53+
<groupId>org.springframework.boot</groupId>
54+
<artifactId>spring-boot-autoconfigure</artifactId>
55+
</dependency>
56+
<dependency>
57+
<groupId>org.springframework.boot</groupId>
58+
<artifactId>spring-boot-configuration-processor</artifactId>
59+
<optional>true</optional>
60+
</dependency>
61+
62+
<!-- ==================== Optional Actuator Support ==================== -->
63+
<dependency>
64+
<groupId>org.springframework.boot</groupId>
65+
<artifactId>spring-boot-starter-actuator</artifactId>
66+
<optional>true</optional>
67+
</dependency>
68+
69+
<!-- ==================== Optional Micrometer Metrics ==================== -->
70+
<dependency>
71+
<groupId>io.micrometer</groupId>
72+
<artifactId>micrometer-core</artifactId>
73+
<optional>true</optional>
74+
</dependency>
75+
76+
<!-- ==================== JSON Libraries (Optional) ==================== -->
77+
<dependency>
78+
<groupId>com.google.code.gson</groupId>
79+
<artifactId>gson</artifactId>
80+
<optional>true</optional>
81+
</dependency>
82+
<dependency>
83+
<groupId>com.fasterxml.jackson.core</groupId>
84+
<artifactId>jackson-databind</artifactId>
85+
<optional>true</optional>
86+
</dependency>
87+
88+
<!-- ==================== SLF4J ==================== -->
89+
<dependency>
90+
<groupId>org.slf4j</groupId>
91+
<artifactId>slf4j-api</artifactId>
92+
</dependency>
93+
94+
<!-- ==================== JetBrains Annotations ==================== -->
95+
<dependency>
96+
<groupId>org.jetbrains</groupId>
97+
<artifactId>annotations</artifactId>
98+
</dependency>
99+
100+
<!-- ==================== Test Dependencies ==================== -->
101+
<dependency>
102+
<groupId>org.springframework.boot</groupId>
103+
<artifactId>spring-boot-starter-test</artifactId>
104+
<scope>test</scope>
105+
</dependency>
106+
<dependency>
107+
<groupId>de.splatgames.aether.datafixers</groupId>
108+
<artifactId>aether-datafixers-testkit</artifactId>
109+
<scope>test</scope>
110+
</dependency>
111+
<dependency>
112+
<groupId>org.junit.jupiter</groupId>
113+
<artifactId>junit-jupiter</artifactId>
114+
<scope>test</scope>
115+
</dependency>
116+
<dependency>
117+
<groupId>org.assertj</groupId>
118+
<artifactId>assertj-core</artifactId>
119+
<scope>test</scope>
120+
</dependency>
121+
</dependencies>
122+
123+
<build>
124+
<plugins>
125+
<plugin>
126+
<groupId>org.apache.maven.plugins</groupId>
127+
<artifactId>maven-compiler-plugin</artifactId>
128+
</plugin>
129+
<plugin>
130+
<groupId>org.apache.maven.plugins</groupId>
131+
<artifactId>maven-enforcer-plugin</artifactId>
132+
</plugin>
133+
<plugin>
134+
<groupId>org.apache.maven.plugins</groupId>
135+
<artifactId>maven-surefire-plugin</artifactId>
136+
</plugin>
137+
</plugins>
138+
</build>
139+
</project>

0 commit comments

Comments
 (0)