Cleanup & fix annotation reading for classpath scanning #1836
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.
I've been debugging the gorm-hibernate5 tests and discovered that any classpath based initialization of the HibernateDatastore was failing. @jamesfredley changed the
AnnotationMetadataReaderto use the helperAnnotationMetadata.from()from Spring. It was failing because this helper restricts to the spring & java packages.For now, I've copied their StandardMetadata implementation and enhanced it to take an annotation filter, which I can then use to initialize
AnnotationMetadataReaderFactoryproperly. I renamedAnnotationMetadataReaderFactoryto reflect it's only for entities since I'm now passing that filter explicitly. From searching the grails repos, I don't see any other usage of it. I hope to open an upstream PR with spring to see if they'll accept an additional argument to specify custom annotation filters.This PR also removes some left over imports from the inheritance fixes & it fixes an ignored test - the $target method added by the AST transformation is now found by the groovy getObjectProperties in DefaultJsonGenerator, which causes a stackoverflow since it's recursive. This may be a larger issue for json in groovy4, but for now I've explicitly ignored the found field to fix the test. I assume most people will be using Jackson and will just igore it as part of converting to Grails 7.