Skip to content

refactor(build): compile the examples as their own module - #475

Merged
dargmuesli merged 2 commits into
betafrom
refactor/build/examples-module
Sep 2, 2026
Merged

dargmuesli merged 2 commits into
betafrom
refactor/build/examples-module

Conversation

@dargmuesli

@dargmuesli dargmuesli commented Sep 2, 2026 •

Copy link
Copy Markdown
Member

The examples were a second source root of the library, added by build-helper in the default profile. Once module-info.java landed in src/main/java, javac compiled them as part of module se.michaelthelin.spotify, so their root packages (data.*, authorization.*) ended up inside the module. The release profile has no build-helper, so the published module never contained them: mvn package produced a 3351-byte descriptor against 2828 from -P release. CI was validating a module that was never published, and the CI jar shipped 115 example classes that were not meant to be in it.

They are now their own Maven project with their own module descriptor, compiling against the installed library rather than alongside it. Both profiles produce a 2828-byte descriptor and the jar carries no example classes.

Making them a separate module buys something the previous arrangement could not. examples/module-info.java requires only se.michaelthelin.spotify, so everything else they touch, Gson and HttpComponents among it, has to reach them through the library's own requires transitive. A package the library forgets to export, or a requires that should have been transitive, now fails this build instead of someone else's. Deleting a single exports line from the library and rebuilding gives package se.michaelthelin.spotify.enums is not visible across six examples, which is a class of mistake nothing caught before.

The files stay exactly where they are. README.md links all 115 of them by path and ci/check-docs.py validates those links, so the project points sourceDirectory at examples/ and sends build output to target/examples rather than moving everything under a conventional src/main/java and rewriting the index.

CI installs the library and then runs mvn -f examples/pom.xml clean compile. The clean is load-bearing: an incremental build reuses classes compiled against the previous descriptor and reports nothing, which is how the first version of this passed when it should have failed.

The examples version is a third place the release version lives, so ci/check-docs.py now fails when it falls behind pom.xml, and AGENTS.md records both that and how to build the examples.

Build-only, no library code changes: 402 tests, 116 example sources compiled on the module path, check-docs clean and javadoc without warnings.

CONTRIBUTING.md is brought back in line at the same time, because this change is one of the things that dated it. Its release section named the wrong number of files to bump and said nothing about ci/check-docs.py now catching a missed one; its documentation rule asked for complete Javadoc, which contradicts a codebase that deliberately leaves model builder setters undocumented and runs doclint as all,-missing; it pointed at Spotify's live documentation for questions spec/openapi.yaml now answers; and it described neither the module descriptor, though a class in a new package is unreachable until that package is exported, nor which branch a contribution belongs on. That last one is now spelled out: main takes anything that can ship in a patch or minor release, new endpoints and parameters included, while beta takes changes that break the published API and accumulates the next major; pre-releases are tagged from beta and stable releases from main.

AGENTS.md is the file agents load at startup and it never referenced the guide at all, so it now links to it up front and defers the release steps to it rather than keeping a second copy that can drift.

They were a second source root of the library, so mvn package folded their packages into the module while -P release did not, and CI validated a module that was never published. As a separate project they compile against the built library the way a consumer does, which also makes a missing export fail here instead of downstream.
@codecov

codecov Bot commented Sep 2, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 46.11%. Comparing base (9bd564a) to head (d73b7d3).
⚠️ Report is 1 commits behind head on beta.

Additional details and impacted files
@@              Coverage Diff              @@
##               beta     #475       +/-   ##
=============================================
+ Coverage     31.65%   46.11%   +14.46%     
  Complexity      683      683               
=============================================
  Files           324      209      -115     
  Lines          9109     6252     -2857     
  Branches        777      753       -24     
=============================================
  Hits           2883     2883               
+ Misses         5669     2812     -2857     
  Partials        557      557               

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dargmuesli
dargmuesli force-pushed the refactor/build/examples-module branch from d22d22b to 9ddc427 Compare September 2, 2026 08:35
The release section predated the examples project and the module descriptor, and the Javadoc rule contradicted what doclint enforces. AGENTS.md was the only file agents read and never mentioned the guide, so it now links to it and stops restating the release steps.
@dargmuesli
dargmuesli force-pushed the refactor/build/examples-module branch from 9ddc427 to d73b7d3 Compare September 2, 2026 08:39
@dargmuesli
dargmuesli merged commit e60028f into beta Sep 2, 2026
9 checks passed
@dargmuesli
dargmuesli deleted the refactor/build/examples-module branch September 2, 2026 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant