-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add resource container selector resolver #3718
Add resource container selector resolver #3718
Conversation
As a follow up for junit-team#3630 and junit-team#3705 this adds a `addResourceContainerSelectorResolver()` method to `EngineDiscoveryRequestResolver.Builder` analogous to `addClassContainerSelectorResolver()`. Points of note: * As classpath resources can be selected from packages, the package filter should also be applied. To make this possible the base path of a resource is rewritten to a package name prior to being filtered. * The `ClasspathResourceSelector` now has a `getClasspathResource` method. This method will lazily try to load the resource if not was not already provided when discovering resources in a container. * `selectClasspathResource(Resource)` was added to short circuit the need to resolve resources twice. And to make it possible to use this method as part of the public API, `ReflectionSupport.tryToLoadResource` was also added.
…-container-selector-resolver
...form-engine/src/main/java/org/junit/platform/engine/discovery/ClasspathResourceSelector.java
Outdated
Show resolved
Hide resolved
junit-platform-commons/src/main/java/org/junit/platform/commons/util/ResourceFilter.java
Outdated
Show resolved
Hide resolved
...main/java/org/junit/platform/engine/support/discovery/ResourceContainerSelectorResolver.java
Outdated
Show resolved
Hide resolved
…-container-selector-resolver
junit-platform-commons/src/main/java/org/junit/platform/commons/util/ClasspathScanner.java
Outdated
Show resolved
Hide resolved
Haven't got any concrete examples in mind right now. So that seems reasonable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for updating this PR! I'll discuss it with the team and will get back to you.
junit-platform-commons/src/main/java/org/junit/platform/commons/util/ReflectionUtils.java
Outdated
Show resolved
Hide resolved
junit-platform-engine/src/main/java/org/junit/platform/engine/discovery/DiscoverySelectors.java
Show resolved
Hide resolved
...form-engine/src/main/java/org/junit/platform/engine/discovery/ClasspathResourceSelector.java
Outdated
Show resolved
Hide resolved
documentation/src/docs/asciidoc/release-notes/release-notes-5.12.0-M1.adoc
Outdated
Show resolved
Hide resolved
...main/java/org/junit/platform/engine/support/discovery/ResourceContainerSelectorResolver.java
Outdated
Show resolved
Hide resolved
...main/java/org/junit/platform/engine/support/discovery/ResourceContainerSelectorResolver.java
Outdated
Show resolved
Hide resolved
…discovery/ClasspathResourceSelector.java Co-authored-by: Marc Philipp <[email protected]>
…12.0-M1.adoc Co-authored-by: Marc Philipp <[email protected]>
@mpkorstanje Thanks a lot! Do you have time to try out adopting this in Cucumber from a snapshot? |
Cheers! I've already had a work in progress. But it will need some updates. Shouldn't be too difficult. |
Overview
Resolve resource container selectors
As a follow up for #3630 and #3705 this adds a
addResourceContainerSelectorResolver()
method to
EngineDiscoveryRequestResolver.Builder
analogous toaddClassContainerSelectorResolver()
.Points of note:
As classpath resources can be selected from packages, the package
filter should also be applied. To make this possible the base path of
a resource is rewritten to a package name prior to being filtered.
The
ClasspathResourceSelector
now has agetClasspathResources
method. This method will lazily try to load the resources if not
already provided when discovering resources in a container.
selectClasspathResource(Set<Resource>)
was added to short circuit theneed to resolve resources twice. And to make it possible to use
this method as part of the public API,
ReflectionSupport.tryToLoadResources
was also added.I hereby agree to the terms of the JUnit Contributor License Agreement.
Definition of Done
@API
annotations