Skip to content

Commit

Permalink
HSEARCH-4691 Backport HSEARCH-4484 Align byte-buddy dependency on Hib…
Browse files Browse the repository at this point in the history
…ernate ORM even in Spring tests

Spring uses an older version of byte-buddy that won't work with recent
versions of Mockito, so we have to explicitly manage that dependency.
But we don't want to diverge from the version used by Hibernate ORM,
hence the limited dependency management (only for spring-related ITs)
and hacks to get maven-enforcer-plugin to check for dependency
alignment.
  • Loading branch information
yrodiere committed Sep 1, 2022
1 parent e5af297 commit 1f8e971
Show file tree
Hide file tree
Showing 14 changed files with 99 additions and 26 deletions.
5 changes: 3 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ updates:
# font-size has the wrong type (string instead of number).
# See b8f044eea92d6f2dd3421779f54b8923e00a26b7
- dependency-name: org.asciidoctor:asciidoctorj-pdf
# We strictly align this dependency on the version used in Hibernate ORM.
- dependency-name: org.jboss:jandex
# We strictly align these dependencies on the version used in Hibernate ORM.
- dependency-name: org.jboss:jandex
- dependency-name: net.bytebuddy:*
11 changes: 11 additions & 0 deletions integrationtest/mapper/orm-spring/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@
<type>pom</type>
<scope>import</scope>
</dependency>
<!-- The Spring BOM uses a version of bytebuddy that's too old for Mockito to work correctly -->
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<version>${version.net.bytebuddy}</version>
</dependency>
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy-agent</artifactId>
<version>${version.net.bytebuddy}</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down
11 changes: 11 additions & 0 deletions integrationtest/showcase/library/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,17 @@
<type>pom</type>
<scope>import</scope>
</dependency>
<!-- The Spring BOM uses a version of bytebuddy that's too old for Mockito to work correctly -->
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<version>${version.net.bytebuddy}</version>
</dependency>
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy-agent</artifactId>
<version>${version.net.bytebuddy}</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down
13 changes: 13 additions & 0 deletions jakarta/mapper/orm/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jboss</groupId>
<artifactId>jandex</artifactId>
<!-- DO NOT REMOVE and DO NOT MANAGE this dependency. See the version property declaration. -->
<version>${version.org.jboss.jandex}</version>
</dependency>
<dependency>
<groupId>jakarta.persistence</groupId>
<artifactId>jakarta.persistence-api</artifactId>
Expand Down Expand Up @@ -86,6 +92,13 @@
<artifactId>hibernate-search-util-internal-test-orm-jakarta</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<!-- DO NOT REMOVE and DO NOT MANAGE this dependency. See the version property declaration. -->
<version>${version.net.bytebuddy}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
7 changes: 0 additions & 7 deletions jakarta/util/internal/test/orm/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,6 @@
<dependency>
<groupId>org.hibernate.search</groupId>
<artifactId>hibernate-search-util-internal-test-common</artifactId>
<exclusions>
<!-- Bytebuddy is already imported by Hibernate ORM with a different version -->
<exclusion>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

Expand Down
7 changes: 7 additions & 0 deletions mapper/orm/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@
<artifactId>hibernate-search-util-internal-test-orm</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<!-- DO NOT REMOVE and DO NOT MANAGE this dependency. See the version property declaration. -->
<version>${version.net.bytebuddy}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
7 changes: 7 additions & 0 deletions orm6/mapper/orm/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@
<artifactId>hibernate-search-util-internal-test-orm-orm6</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<!-- DO NOT REMOVE and DO NOT MANAGE this dependency. See the version property declaration. -->
<version>${version.net.bytebuddy}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
8 changes: 7 additions & 1 deletion orm6/parents/integrationtest/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
<!-- Prevent these modules from artificially affecting Sonar metrics -->
<sonar.skip>true</sonar.skip>

<version.net.bytebuddy>${version.net.bytebuddy.orm6}</version.net.bytebuddy>

<!-- To be set by child modules -->
<transform.original.pathFromRoot></transform.original.pathFromRoot>
<transform.original.path>${rootProject.directory}/${transform.original.pathFromRoot}</transform.original.path>
Expand Down Expand Up @@ -85,13 +87,17 @@
<artifactId>hibernate-search-util-internal-test-common</artifactId>
<version>${project.version}</version>
<exclusions>
<!-- Trust the ORM 6 dependency to bring in the correct version of Jandex
<!-- Trust the ORM 6 dependency to bring in the correct version of Jandex and Bytebuddy
(which, unfortunately, might be different from the version used in ORM 5.x
on which our utils are aligned) -->
<exclusion>
<groupId>org.jboss</groupId>
<artifactId>jandex</artifactId>
</exclusion>
<exclusion>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
</exclusion>
</exclusions>
</dependency>

Expand Down
8 changes: 7 additions & 1 deletion orm6/parents/internal/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
<!-- Prevent these modules from artificially affecting Sonar metrics -->
<sonar.skip>true</sonar.skip>

<version.net.bytebuddy>${version.net.bytebuddy.orm6}</version.net.bytebuddy>

<!-- To be set by child modules -->
<transform.original.pathFromRoot></transform.original.pathFromRoot>
<transform.original.path>${rootProject.directory}/${transform.original.pathFromRoot}</transform.original.path>
Expand Down Expand Up @@ -85,13 +87,17 @@
<artifactId>hibernate-search-util-internal-test-common</artifactId>
<version>${project.version}</version>
<exclusions>
<!-- Trust the ORM 6 dependency to bring in the correct version of Jandex
<!-- Trust the ORM 6 dependency to bring in the correct version of Jandex and Bytebuddy
(which, unfortunately, might be different from the version used in ORM 5.x
on which our utils are aligned) -->
<exclusion>
<groupId>org.jboss</groupId>
<artifactId>jandex</artifactId>
</exclusion>
<exclusion>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
</exclusion>
</exclusions>
</dependency>

Expand Down
8 changes: 7 additions & 1 deletion orm6/parents/public/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
<!-- Prevent these modules from artificially affecting Sonar metrics -->
<sonar.skip>true</sonar.skip>

<version.net.bytebuddy>${version.net.bytebuddy.orm6}</version.net.bytebuddy>

<!-- To be set by child modules -->
<transform.original.pathFromRoot></transform.original.pathFromRoot>
<transform.original.path>${rootProject.directory}/${transform.original.pathFromRoot}</transform.original.path>
Expand Down Expand Up @@ -75,13 +77,17 @@
<artifactId>hibernate-search-util-internal-test-common</artifactId>
<version>${project.version}</version>
<exclusions>
<!-- Trust the ORM 6 dependency to bring in the correct version of Jandex
<!-- Trust the ORM 6 dependency to bring in the correct version of Jandex and Bytebuddy
(which, unfortunately, might be different from the version used in ORM 5.x
on which our utils are aligned) -->
<exclusion>
<groupId>org.jboss</groupId>
<artifactId>jandex</artifactId>
</exclusion>
<exclusion>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
Expand Down
7 changes: 0 additions & 7 deletions orm6/util/internal/test/orm/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,6 @@
<dependency>
<groupId>org.hibernate.search</groupId>
<artifactId>hibernate-search-util-internal-test-common</artifactId>
<exclusions>
<!-- Bytebuddy is already imported by Hibernate ORM with a different version -->
<exclusion>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

Expand Down
9 changes: 9 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -266,13 +266,22 @@
-->
<version.org.jboss.jandex>2.4.2.Final</version.org.jboss.jandex>
<version.javax.persistence>2.2</version.javax.persistence>
<!-- This version must be kept in sync with the version of the dependency in Hibernate ORM.
DO NOT USE DEPENDENCY MANAGEMENT IN THE ROOT POM FOR THIS DEPENDENCY!
If we do not use dependency management for this dependency, we get a build failure
when the versions start diverging, thanks to the maven-enforcer-plugin
and to an artificial dependency in the mapper-orm artifact
(which is only necessary for the maven-enforcer-plugin checks to work).
-->
<version.net.bytebuddy>1.12.9</version.net.bytebuddy>

<!-- >>> ORM 6 / Jakarta Persistence -->
<version.org.hibernate.orm>6.0.2.Final</version.org.hibernate.orm>
<javadoc.org.hibernate.orm.url>https://docs.jboss.org/hibernate/orm/${parsed-version.org.hibernate.orm.majorVersion}.${parsed-version.org.hibernate.orm.minorVersion}/javadocs/</javadoc.org.hibernate.orm.url>
<documentation.org.hibernate.orm.url>https://docs.jboss.org/hibernate/orm/${parsed-version.org.hibernate.orm.majorVersion}.${parsed-version.org.hibernate.orm.minorVersion}/userguide/html_single/Hibernate_User_Guide.html</documentation.org.hibernate.orm.url>
<version.org.hibernate.commons.annotations.orm6>6.0.1.Final</version.org.hibernate.commons.annotations.orm6>
<version.jakarta.persistence>3.1.0</version.jakarta.persistence>
<version.net.bytebuddy.orm6>1.12.9</version.net.bytebuddy.orm6>

<!-- >>> JSR 352 -->
<version.javax.batch>1.0.1</version.javax.batch>
Expand Down
17 changes: 17 additions & 0 deletions util/internal/test/common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<exclusions>
<!-- We import Bytebuddy ourselves, with a version aligned on Hibernate ORM's dependency. See below. -->
<exclusion>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
</exclusion>
<exclusion>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy-agent</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jboss.logging</groupId>
Expand All @@ -59,6 +70,12 @@
<!-- DO NOT MANAGE this dependency. See the version property declaration. -->
<version>${version.org.jboss.jandex}</version>
</dependency>
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<!-- DO NOT MANAGE this dependency. See the version property declaration. -->
<version>${version.net.bytebuddy}</version>
</dependency>

<!-- Work around Surefire clearing the interrupt status when forwarding stdout/stderr -->
<dependency>
Expand Down
7 changes: 0 additions & 7 deletions util/internal/test/orm/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,6 @@
<dependency>
<groupId>org.hibernate.search</groupId>
<artifactId>hibernate-search-util-internal-test-common</artifactId>
<exclusions>
<!-- Bytebuddy is already imported by Hibernate ORM with a different version -->
<exclusion>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

Expand Down

0 comments on commit 1f8e971

Please sign in to comment.