-
Notifications
You must be signed in to change notification settings - Fork 570
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
HV-2001 Generate module-info for published artifacts #1370
base: main
Are you sure you want to change the base?
HV-2001 Generate module-info for published artifacts #1370
Conversation
Thanks for your pull request! This pull request appears to follow the contribution rules. › This message was automatically generated. |
fece933
to
90d35bb
Compare
90d35bb
to
20c7d91
Compare
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.
Hey, thanks. My comments below.
Going back to the CDI stuff... I wonder whether we should move the classes around, maybe to some SPI packages for the things that are potentially instantiated through the CDI?
Maybe, though I'd love to know what those things are and how the CDI container manages to guess the names of the relevant classes. Are those hardcoded somewhere, or... ?
@@ -51,8 +51,8 @@ | |||
import org.hibernate.validator.cdi.internal.ValidationProviderHelper; | |||
import org.hibernate.validator.cdi.internal.ValidatorBean; | |||
import org.hibernate.validator.cdi.internal.ValidatorFactoryBean; | |||
import org.hibernate.validator.cdi.internal.interceptor.ValidationEnabledAnnotatedType; | |||
import org.hibernate.validator.cdi.internal.interceptor.ValidationInterceptor; | |||
import org.hibernate.validator.cdi.interceptor.spi.internal.ValidationEnabledAnnotatedType; |
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.
.spi.internal
, really? 🤔
Are you trying to confuse automatic tooling? :)
cdi/src/main/java/org/hibernate/validator/cdi/interceptor/spi/ValidationInterceptor.java
Show resolved
Hide resolved
20f5e32
to
ce7ab19
Compare
ce7ab19
to
26e83c4
Compare
since the module is using the jboss logger ...
cca4384
to
b7e775b
Compare
cdi/src/main/java/org/hibernate/validator/cdi/spi/InjectingConstraintValidatorFactory.java
Outdated
Show resolved
Hide resolved
...java/org/hibernate/validator/constraintvalidation/spi/DefaultConstraintValidatorFactory.java
Show resolved
Hide resolved
cdi/src/main/java/org/hibernate/validator/cdi/internal/ValidatorFactoryBean.java
Outdated
Show resolved
Hide resolved
0b342ce
to
ed9b051
Compare
cdi/src/main/java/org/hibernate/validator/cdi/spi/InjectingConstraintValidatorFactory.java
Outdated
Show resolved
Hide resolved
be0c40c
to
04835f8
Compare
@yrodiere can you think of anything else we can/should do here? Or should we try merging this and then formatting/sorting in and attempting to do a release after that? 🙈 😃 |
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. Added a few comments, but feel free to merge when you think it's ready.
.stream() | ||
// We do not include impl class of a validator if it comes from Hibernate Validator. | ||
// In this case we only want to share the interfaces: | ||
.filter( c -> !( validationProviderHelper.isHibernateValidator() && c.equals( validationProviderHelper.getValidatorBeanClass() ) ) ) |
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.
This seems... fragile?
If we add some abstract class above ValidatorImpl
, it will probably no longer work.
And with ValidatorProviderHelper.forDefaultProvider
, it will definitely not work -- though I admit I have no idea what's the purpose of that thing.
Shouldn't you adjust how ValidationProviderHelper
is built instead? E.g. forHibernateValidator
would pass HibernateValidatorFactory.class
/HibernateValidator.class
to the constructor, while forDefaultProvider
would do that if ValidatorFactory
implements HibernateValidatorFactory
, and default to some other behavior if not (maybe ValidatorFactory.class
/Validator.class
?).
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.
hmm, if we pass just the interface, then we might lose some interfaces:
ValidatorImpl implements Validator, ExecutableValidator
On the other hand, the ValidatorFactoryImpl
extends AutoCloseable
, and since we are taking the class hierarchy, we add AutoCloseable
to the types, so that means we allow something like ...
@Inject
@HibernateValidator
AutoClosable validatorFactory;
is possible? 🤔 😃
Maybe... if it is an HV factory/validator, we filter out any internal classes/interfaces by looking at the package, and otherwise, we keep everything. There's this test that checks if someone can inject their own custom factory/validator, and in that case, the implementation classes are injected, that's why I think if it is not "ours", we just keep it all and leave it to the user to deal with.
Lines 51 to 73 in e5a569e
@Inject | |
ValidatorFactory defaultValidatorFactory; | |
@Inject | |
Validator defaultValidator; | |
@Inject | |
MyValidatorFactory myValidatorFactory; | |
@Inject | |
MyValidator myValidator; | |
@Inject | |
@HibernateValidator | |
ValidatorFactory hibernateValidatorFactory; | |
@Inject | |
@HibernateValidator | |
Validator hibernateValidator; | |
@Inject | |
@HibernateValidator | |
HibernateValidatorFactory hibernateValidatorSpecificFactory; |
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.
if it is an HV factory/validator, we filter out any internal classes/interfaces by looking at the package
Okay, but perhaps hardcode that list (with a test to check it stays up to date).
otherwise, we keep everything. There's this test that checks if someone can inject their own custom factory/validator, and in that case, the implementation classes are injected, that's why I think if it is not "ours", we just keep it all and leave it to the user to deal with.
Makes sense.
public void testSomeRandomClasses() { | ||
assertThat( isBuiltInConstraintValidator( Random.class ) ).isFalse(); |
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.
Being literal here, eh? 😁
…iate built-in constraint validators
…an types if they come from HV itself
3a70a63
to
f7a6fa9
Compare
https://hibernate.atlassian.net/browse/HV-2001
This is the first iteration to generate module-info for published artifacts. It is based on #1364 as it has some useful cleanups that make module-info generation cleaner (hence, opening only as a draft for now).
Only the last commit in this PR is really relevant to module-info.
I added specific plugin configurations to each module as it seems that each of them has specific needs and there's not much in common...
test utils module
This one seems pretty straightforward. I've dropped the dependency on testng, as it was there just for a few assert calls that we can replace with the assertj ones. The constraint assert that this util jar offers is based on assertj, so it makes sense to keep assertj 😃.
There is a simple test (
test-utils
).engine (actual validator)
The plugin couldn't pick up which services are loaded via
ServiceLoader
so I've listed those explicitly.all seems to work fine and look ok until we get to CDI stuff... CDI needs reflection access to
ValidatorImpl
,ValidatorFactoryImpl
and all constraint validator implementations... so that means we have to open the packages that contain those classes .... but open to CDI impl, which is ... ? so I just have them opened to all (at least for now).Going back to the CDI stuff... I wonder whether we should move the classes around, maybe to some SPI packages for the things that are potentially instantiated through the CDI?
There are tests for the case with EL (
simple
) and without EL dependency (no-el
).CDI
see the comments to the engine section just above. Another problem is that Weld is using the previous version of JBoss Logging. This leads to the test failure since Weld cannot access the logger correctly in the module test.
I've moved some classes around as CDI needed reflection access to some of the classes in this module and they lived in an internal package.
The test is currently disabled (
cdi
), but I've tested it locally using the previous version of the logging jar.Annotaion processor
This one seems pretty straightforward as it doesn't really have any dependencies, and the AP is added as provided to the module info by the plugin automatically.
With that, I'm not sure what would be a good way to test it, just run a compile task and pass the AP through the
annotationProcessorPaths
?By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on licensing, please check here.