Skip to content

Fix outdated docs code samples and run the docs tests in CI - #898

Merged
mkurz merged 3 commits into
playframework:mainfrom
mkurz:update-docs-samples
Oct 8, 2026
Merged

mkurz merged 3 commits into
playframework:mainfrom
mkurz:update-docs-samples

Conversation

@mkurz

@mkurz mkurz commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

Requires #895: without it the docs project doesn't compile on main (it has no models package), so this PR includes its commits. Please merge #895 first.

The docs code samples were outdated and did not compile anymore:

  • MyServerConfigStartup used io.ebean.config.ServerConfig, which doesn't exist anymore. ServerConfigStartup.onStart takes a DatabaseBuilder now.
  • The transaction samples used the io.ebean.Ebean class, which doesn't exist anymore either. They now use io.ebean.DB, and the "traditional" sample uses a try-with-resources Transaction (DB has no commitTransaction()/endTransaction()). The text also mentioned TxRunnable and TxCallable, which are gone as well.

This went unnoticed, because CI only ran validateCode for the docs, which never compiles the samples. The docs job now also runs the docs tests, like e.g. twirl and play-slick do. For that, the docs build now enhances the models of its test sources (where the samples live); before, it only set Test / playEbeanModels, without actually wiring up the enhancement for Test.

Also, the docs now point out that a ServerConfigStartup has to be covered by an ebean. config line: Play Ebean registers the configured classes with Ebean explicitly, which disables Ebean's classpath scanning, so any other ServerConfigStartup gets silently ignored. That's what happened in #355.

Testing

cd docs && sbt "validateCode; test": all 4 JavaEbeanTest tests pass.

Backports: #899 (8.x), #900 (7.x)

mkurz added 2 commits October 8, 2026 12:06
The sbt plugin passed the configured models as they are to Ebean's
enhancer, which treats every entry as a package directory. So single
classes (e.g. "models.Task", as shown in the docs) and packages without
compiled classes (e.g. not existing yet, or provided by a dependency)
made it throw.

Up to the sbt 2 cross build, the plugin swallowed that error, which also
skipped all following entries, so entities silently stayed unenhanced
and the application failed at runtime. Since then, compilation fails.

Now single classes get enhanced via their package and packages without
compiled classes get skipped.
The ServerConfigStartup and transaction samples still used Ebean APIs
that have been removed in the meantime (ServerConfig and the Ebean
class), so they did not compile anymore. That went unnoticed, because
CI only validated the docs, but never compiled or ran the samples.
Their models did not even get enhanced, as the docs build did not
enhance its test sources.

Also point out that a ServerConfigStartup has to be covered by an
"ebean." config line, since Ebean does not scan the classpath for it
when used with Play Ebean.
playEbeanModels can also contain package names without a ".*" suffix,
e.g. Seq("models"), which Ebean's enhancer handles just like "models.*".
However, the previous commit took them for single classes and enhanced
their parent package instead, which for "models" is the whole classes
directory.

Now only entries that are no package with compiled classes are treated
as single classes.
@mergify

mergify Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again.

@mkurz
mkurz merged commit 67128d3 into playframework:main Oct 8, 2026
80 checks passed
@mkurz
mkurz deleted the update-docs-samples branch October 8, 2026 11:03
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