Repository navigation
[8.x] Fix enhancing single model classes and packages without classes - #896
Merged
Merged
Conversation
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. The plugin swallowed that error, which also skipped all following entries, so entities silently stayed unenhanced and the application failed at runtime. Now single classes get enhanced via their package and packages without compiled classes get skipped. Other enhancement errors are not swallowed anymore.
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. |
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #895 to
8.x.The sbt plugin passed the configured models (the
ebean.*entries, ormodels.*by default) as they are to Ebean's offline enhancer, which treats every entry as a package directory below the classes directory and throws if that directory doesn't exist. That's the case for:ebean.orders = ["models.Order", "models.OrderItem"], as shown in the docs (models/Orderis not a directory)The plugin swallowed that exception. However, the enhancer processes the entries one after the other, so that also silently skipped all following entries: entities stayed unenhanced and the application failed at runtime with a
BeanNotEnhancedException.Now the plugin keeps packages as they are (
models.*, or plain package names likemodels, which can be set viaplayEbeanModels), turns single classes into their package, and skips entries without compiled classes. If nothing is left, it doesn't call the enhancer at all, since an empty list would make it process all classes. Other enhancement errors are not swallowed anymore, but fail the build.Testing
New scripted test
enhancement-model-entrieswithebean.default = [ "missing.*", "models.Task" ](the missing package comes first, so it must not stop the enhancement of the class):BeanNotEnhancedException: Bean class models.Task is not enhanced?at runtime.enhancement-plain-packagewithCompile / playEbeanModels := Seq("models")checks thatmodels.Taskgets enhanced, but an entity in another package doesn't (plain package names must not be taken for classes).