Skip to content

Commit bde182d

Browse files
committed
build: jackson-yaml optional, drop unused jsonSchema + direct snakeyaml (F4)
F1 audit flagged jackson-module-jsonSchema and the direct snakeyaml declaration as unused, and called out jackson-dataformat-yaml as a candidate for optional-scope since it is consumed only by `com.demcha.compose.ConfigLoader.loadConfigWithEnv(...)` on the YAML code path. Library consumers that load JSON configs (or skip ConfigLoader entirely) should not pay the ~1.7MB SnakeYAML transitive cost. - Mark jackson-dataformat-yaml as <optional>true</optional>, mirroring the existing poi-ooxml pattern. ConfigLoader still compiles against the type but consumers must add jackson-dataformat-yaml explicitly if they load YAML configs through it; without it, ConfigLoader throws NoClassDefFoundError when it constructs YAMLFactory. - Remove jackson-module-jsonSchema entirely (no code reference). - Remove the explicit snakeyaml dependency and the snakeyaml.version property. SnakeYAML now resolves transitively (and optional) through jackson-dataformat-yaml at the version Jackson's BOM picks (2.5), which version-aligns it with the rest of the Jackson stack. - Add Javadoc on ConfigLoader.loadConfigWithEnv documenting the optional-dep requirement and the NoClassDefFoundError it raises when YAML support is requested without jackson-dataformat-yaml on the classpath. Consumer impact: callers that loaded YAML through ConfigLoader, or that relied on jackson-module-jsonSchema / snakeyaml flowing transitively through GraphCompose, must add those dependencies explicitly. Gates: 1031 tests pass; dependency:tree shows jackson-dataformat-yaml + snakeyaml as optional, no jackson-module-jsonSchema; japicmp vs v1.6.6 reports semver OK (no incompatible changes).
1 parent 09e07e4 commit bde182d

3 files changed

Lines changed: 47 additions & 14 deletions

File tree

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,26 @@ planned; the next minor with new canonical DSL primitives is
3434
calls through SLF4J. Previously the bridge was provided
3535
transitively via `flexmark-all`; making it explicit keeps the
3636
classpath reproducible after the flexmark narrowing above.
37+
- Marked `jackson-dataformat-yaml` as `<optional>true</optional>`,
38+
mirroring the existing `poi-ooxml` pattern. The only consumer is
39+
`ConfigLoader.loadConfigWithEnv(...)` when the caller passes a
40+
`.yaml` / `.yml` resource; library consumers that load JSON
41+
configs (or skip `ConfigLoader` altogether) no longer pull in the
42+
~1.7 MB SnakeYAML transitive footprint. Applications that load
43+
YAML configs through this helper must now declare
44+
`jackson-dataformat-yaml` in their own build.
45+
- Removed the unused `jackson-module-jsonSchema` dependency — no
46+
code path references it.
47+
- Removed the explicit `snakeyaml` dependency declaration and the
48+
`snakeyaml.version` property. SnakeYAML is now resolved
49+
transitively (and `optional`) through `jackson-dataformat-yaml`,
50+
which version-aligns it with Jackson's BOM.
51+
52+
### Documentation
53+
54+
- `ConfigLoader.loadConfigWithEnv` Javadoc now states the YAML
55+
path requires `jackson-dataformat-yaml` on the classpath and
56+
throws `NoClassDefFoundError` when the optional dep is absent.
3757

3858
### Internal
3959

pom.xml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
<poi.version>5.5.1</poi.version>
5555
<javafx.version>21.0.2</javafx.version>
5656
<slf4j.version>2.0.18</slf4j.version>
57-
<snakeyaml.version>2.6</snakeyaml.version>
5857
<zxing.version>3.5.4</zxing.version>
5958

6059
<!-- Test dependencies -->
@@ -204,20 +203,22 @@
204203
<artifactId>jackson-databind</artifactId>
205204
</dependency>
206205

206+
<!--
207+
jackson-dataformat-yaml is consumed only by `ConfigLoader.
208+
loadConfigWithEnv(...)` when the caller passes a *.yaml /
209+
*.yml resource. Library consumers that load JSON configs
210+
(or do not use ConfigLoader at all) should not pay the
211+
~1.7MB SnakeYAML transitive cost. Marked optional in
212+
v1.6.7 (F4), mirroring the existing `poi-ooxml` pattern.
213+
Apps that load YAML configs must add this dependency to
214+
their own classpath; without it `ConfigLoader` throws
215+
`NoClassDefFoundError` when it tries to construct
216+
`YAMLFactory`.
217+
-->
207218
<dependency>
208219
<groupId>com.fasterxml.jackson.dataformat</groupId>
209220
<artifactId>jackson-dataformat-yaml</artifactId>
210-
</dependency>
211-
212-
<dependency>
213-
<groupId>com.fasterxml.jackson.module</groupId>
214-
<artifactId>jackson-module-jsonSchema</artifactId>
215-
</dependency>
216-
217-
<dependency>
218-
<groupId>org.yaml</groupId>
219-
<artifactId>snakeyaml</artifactId>
220-
<version>${snakeyaml.version}</version>
221+
<optional>true</optional>
221222
</dependency>
222223

223224
<dependency>

src/main/java/com/demcha/compose/ConfigLoader.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,21 @@ private ConfigLoader() {
2121
}
2222

2323
/**
24-
* Load YAML from classpath resource into the given class.
24+
* Load YAML or JSON from a classpath resource into the given class.
2525
* Supports running from IDE and from a fat JAR.
26-
* Optionally resolves ${ENV} or ${ENV:default} placeholders from environment variables.
26+
* Optionally resolves {@code ${ENV}} or {@code ${ENV:default}} placeholders
27+
* from environment variables.
28+
*
29+
* <p><strong>Optional dependency:</strong> the YAML path requires
30+
* {@code com.fasterxml.jackson.dataformat:jackson-dataformat-yaml} on
31+
* the classpath. GraphCompose declares it as an optional Maven
32+
* dependency since {@code v1.6.7}; applications that load YAML
33+
* configs through this helper must add the artifact to their own
34+
* build. JSON configs work without it.
35+
*
36+
* @throws java.lang.NoClassDefFoundError if {@code fileName} ends with
37+
* {@code .yaml} / {@code .yml} and
38+
* {@code jackson-dataformat-yaml} is not on the classpath.
2739
*/
2840
public static <T> T loadConfigWithEnv(String fileName, Class<T> clazz, boolean resolveEnv) {
2941
log.info("Initializing variables from '{}'", fileName);

0 commit comments

Comments
 (0)