Skip to content

Commit

Permalink
HV-2001 Add module-info generation via moditect
Browse files Browse the repository at this point in the history
  • Loading branch information
marko-bekhta committed Jul 8, 2024
1 parent cad8434 commit 20c7d91
Show file tree
Hide file tree
Showing 47 changed files with 1,356 additions and 41 deletions.
31 changes: 29 additions & 2 deletions annotation-processor/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<!-- This is a publicly distributed module that should be published: -->
<deploy.skip>false</deploy.skip>
<hibernate-validator-parent.path>..</hibernate-validator-parent.path>
<automatic.module.name>org.hibernate.validator.annotationprocessor</automatic.module.name>
<java.module.name>org.hibernate.validator.annotationprocessor</java.module.name>
</properties>

<dependencies>
Expand Down Expand Up @@ -115,7 +115,6 @@
<configuration>
<archive>
<manifestEntries>
<Automatic-Module-Name>${automatic.module.name}</Automatic-Module-Name>
<Multi-Release>true</Multi-Release>
</manifestEntries>
</archive>
Expand All @@ -142,6 +141,34 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.moditect</groupId>
<artifactId>moditect-maven-plugin</artifactId>
<executions>
<execution>
<id>add-module-infos</id>
<phase>package</phase>
<goals>
<goal>add-module-info</goal>
</goals>
<configuration>
<module>
<moduleInfo>
<name>${java.module.name}</name>
<exports>
!org.hibernate.validator.ap.internal;
!org.hibernate.validator.ap.internal.*;
*;
</exports>
</moduleInfo>
</module>
<jdepsExtraArgs>
--multi-release=${maven.compiler.release}
</jdepsExtraArgs>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
33 changes: 31 additions & 2 deletions cdi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<properties>
<!-- This is a publicly distributed module that should be published: -->
<deploy.skip>false</deploy.skip>
<java.module.name>${hibernate-validator-cdi.module-name}</java.module.name>

<hibernate-validator-parent.path>..</hibernate-validator-parent.path>
</properties>
Expand Down Expand Up @@ -184,7 +185,6 @@
<manifestEntries>
<Specification-Title>Jakarta Bean Validation</Specification-Title>
<Specification-Version>2.0</Specification-Version>
<Automatic-Module-Name>${hibernate-validator-cdi.module-name}</Automatic-Module-Name>
</manifestEntries>
</archive>
</configuration>
Expand All @@ -196,7 +196,7 @@
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
<Bundle-SymbolicName>${hibernate-validator-cdi.module-name}</Bundle-SymbolicName>
<Bundle-SymbolicName>${java.module.name}</Bundle-SymbolicName>
<Fragment-Host>${hibernate-validator.module-name}</Fragment-Host>
<Import-Package>
jakarta.validation.*;version="[3.0,4.0)",
Expand Down Expand Up @@ -234,6 +234,35 @@
<skip>false</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.moditect</groupId>
<artifactId>moditect-maven-plugin</artifactId>
<executions>
<execution>
<id>add-module-infos</id>
<phase>package</phase>
<goals>
<goal>add-module-info</goal>
</goals>
<configuration>
<module>
<moduleInfo>
<name>${java.module.name}</name>
<exports>
!org.hibernate.validator.*.internal;
!org.hibernate.validator.*.internal.*;
*;
</exports>
<opens>
<!-- Interceptor has to provide reflection access -->
org.hibernate.validator.cdi.interceptor.spi;
</opens>
</moduleInfo>
</module>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -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;
import org.hibernate.validator.cdi.interceptor.spi.ValidationInterceptor;
import org.hibernate.validator.cdi.internal.util.GetterPropertySelectionStrategyHelper;
import org.hibernate.validator.internal.util.Contracts;
import org.hibernate.validator.internal.util.ExecutableHelper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
* License: Apache License, Version 2.0
* See the license.txt file in the root directory or <http://www.apache.org/licenses/LICENSE-2.0>.
*/
package org.hibernate.validator.cdi.internal.interceptor;
package org.hibernate.validator.cdi.interceptor.spi;

import java.io.Serializable;
import java.lang.reflect.Member;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Set;

import org.hibernate.validator.cdi.interceptor.spi.internal.MethodValidated;

import jakarta.annotation.Priority;
import jakarta.inject.Inject;
import jakarta.interceptor.AroundConstruct;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* License: Apache License, Version 2.0
* See the license.txt file in the root directory or <http://www.apache.org/licenses/LICENSE-2.0>.
*/
package org.hibernate.validator.cdi.internal.interceptor;
package org.hibernate.validator.cdi.interceptor.spi.internal;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* License: Apache License, Version 2.0
* See the license.txt file in the root directory or <http://www.apache.org/licenses/LICENSE-2.0>.
*/
package org.hibernate.validator.cdi.internal.interceptor;
package org.hibernate.validator.cdi.interceptor.spi.internal;

import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* License: Apache License, Version 2.0
* See the license.txt file in the root directory or <http://www.apache.org/licenses/LICENSE-2.0>.
*/
package org.hibernate.validator.cdi.internal.interceptor;
package org.hibernate.validator.cdi.interceptor.spi.internal;

import java.lang.reflect.Constructor;
import jakarta.enterprise.inject.spi.AnnotatedConstructor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* License: Apache License, Version 2.0
* See the license.txt file in the root directory or <http://www.apache.org/licenses/LICENSE-2.0>.
*/
package org.hibernate.validator.cdi.internal.interceptor;
package org.hibernate.validator.cdi.interceptor.spi.internal;

import java.lang.reflect.Method;
import jakarta.enterprise.inject.spi.AnnotatedMethod;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* License: Apache License, Version 2.0
* See the license.txt file in the root directory or <http://www.apache.org/licenses/LICENSE-2.0>.
*/
package org.hibernate.validator.cdi.internal.interceptor;
package org.hibernate.validator.cdi.interceptor.spi.internal;

import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
/**
* <p>Classes for enabling Bean Validation method validation via a CDI interceptor.
*/
package org.hibernate.validator.cdi.internal.interceptor;
package org.hibernate.validator.cdi.interceptor.spi.internal;
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

import org.hibernate.validator.HibernateValidatorConfiguration;
import org.hibernate.validator.cdi.spi.BeanNames;
import org.hibernate.validator.cdi.spi.InjectingConstraintValidatorFactory;
import org.hibernate.validator.internal.engine.valueextraction.ValueExtractorDescriptor;
import org.hibernate.validator.internal.util.CollectionHelper;
import org.hibernate.validator.internal.util.classhierarchy.ClassHierarchyHelper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* License: Apache License, Version 2.0
* See the license.txt file in the root directory or <http://www.apache.org/licenses/LICENSE-2.0>.
*/
package org.hibernate.validator.cdi.internal;
package org.hibernate.validator.cdi.spi;

import java.util.Collections;
import java.util.IdentityHashMap;
Expand All @@ -14,6 +14,7 @@
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorFactory;

import org.hibernate.validator.cdi.internal.DestructibleBeanInstance;
import org.hibernate.validator.internal.util.Contracts;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import jakarta.validation.ConstraintValidatorContext;
import jakarta.validation.constraints.Min;

import org.hibernate.validator.cdi.internal.InjectingConstraintValidatorFactory;
import org.hibernate.validator.cdi.spi.InjectingConstraintValidatorFactory;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

Expand Down
2 changes: 1 addition & 1 deletion documentation/src/main/asciidoc/ch11.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ constructors.

[NOTE]
====
The interceptor `org.hibernate.validator.cdi.internal.interceptor.ValidationInterceptor` is
The interceptor `org.hibernate.validator.cdi.interceptor.spi.ValidationInterceptor` is
registered by `org.hibernate.validator.cdi.internal.ValidationExtension`. This happens implicitly
within a Jakarta EE runtime environment or explicitly by adding the _hibernate-validator-cdi_
artifact - see <<section-getting-started-cdi>>
Expand Down
51 changes: 48 additions & 3 deletions engine/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

<hibernate-validator-parent.path>..</hibernate-validator-parent.path>
<surefire.jvm.args.additional>-Duser.language=en -Duser.country=US</surefire.jvm.args.additional>
<java.module.name>${hibernate-validator.module-name}</java.module.name>
</properties>

<distributionManagement>
Expand Down Expand Up @@ -59,11 +60,11 @@
<groupId>org.glassfish.expressly</groupId>
<artifactId>expressly</artifactId>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging-annotations</artifactId>
<scope>provided</scope>
</dependency>

<!--
Expand Down Expand Up @@ -245,7 +246,6 @@
<manifestEntries>
<Specification-Title>Jakarta Bean Validation</Specification-Title>
<Specification-Version>3.0</Specification-Version>
<Automatic-Module-Name>${hibernate-validator.module-name}</Automatic-Module-Name>
</manifestEntries>
</archive>
</configuration>
Expand All @@ -257,7 +257,7 @@
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
<Bundle-SymbolicName>${hibernate-validator.module-name}</Bundle-SymbolicName>
<Bundle-SymbolicName>${java.module.name}</Bundle-SymbolicName>
<Import-Package>
jakarta.persistence.*;version="[3.0.0,4.0.0)";resolution:=optional,
jakarta.validation.*;version="[3.0.0,4.0.0)",
Expand Down Expand Up @@ -322,6 +322,51 @@
<skip>false</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.moditect</groupId>
<artifactId>moditect-maven-plugin</artifactId>
<executions>
<execution>
<id>add-module-infos</id>
<phase>package</phase>
<goals>
<goal>add-module-info</goal>
</goals>
<configuration>
<module>
<moduleInfo>
<name>${java.module.name}</name>
<requires>
<!-- jboss annotations are getting pulled even though they are for compilation only -->
!jboss.logging.annotations;
*;
</requires>
<exports>
org.hibernate.validator.*.logging to org.jboss.logging, org.hibernate.validator.cdi;
org.hibernate.validator.internal to org.hibernate.validator.cdi;
org.hibernate.validator.internal.* to org.hibernate.validator.cdi;
org.hibernate.validator.*.internal.* to org.hibernate.validator.cdi;
*;
</exports>
<opens>
<!-- We open constraints for reflection as these can be instantiated by a CDI container -->
org.hibernate.validator.internal.constraintvalidators.bv;
org.hibernate.validator.internal.constraintvalidators.bv.*;
org.hibernate.validator.internal.constraintvalidators.hv;
org.hibernate.validator.internal.constraintvalidators.hv.*;
<!-- As both Validator and ValidatorFactory have to be accessible by CDI ... -->
org.hibernate.validator.internal.engine;
</opens>
<uses>
jakarta.validation.valueextraction.ValueExtractor;
jakarta.validation.ConstraintValidator
</uses>
</moduleInfo>
</module>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Loading

0 comments on commit 20c7d91

Please sign in to comment.