Skip to content

Commit

Permalink
HBASE-28382 Support building hbase-connectors with JDK17
Browse files Browse the repository at this point in the history
- Remove EOL'ed gmaven-plugin which is unnecessarilty too complex and does not work with JDK17
- Refactor flags for UT and IT for ease of profile based run
- Bump and replace mockito-all with mockito-bom and update dependencies as needed
- Copy JDK17 flags from HBase and Spark
- Add profile for JDK11 and JDK17 build
  • Loading branch information
NihalJain authored Aug 17, 2024
1 parent 307607c commit 657573e
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 35 deletions.
82 changes: 78 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
<maven.build.timestamp.format>yyyy-MM-dd'T'HH:mm</maven.build.timestamp.format>
<buildDate>${maven.build.timestamp}</buildDate>
<compileSource>1.8</compileSource>
<releaseTarget>8</releaseTarget>
<java.min.version>${compileSource}</java.min.version>
<!-- override on command line to have generated LICENSE files include
diagnostic info for verifying notice requirements -->
Expand All @@ -140,7 +141,7 @@
<exec.maven.version>1.6.0</exec.maven.version>
<audience-annotations.version>0.5.0</audience-annotations.version>
<junit.version>4.13.2</junit.version>
<mockito-all.version>1.8.5</mockito-all.version>
<mockito-all.version>4.11.0</mockito-all.version>
<hbase-thirdparty.version>4.1.4</hbase-thirdparty.version>
<hadoop-two.version>2.10.0</hadoop-two.version>
<hadoop-three.version>3.2.4</hadoop-three.version>
Expand All @@ -152,7 +153,7 @@
<spotless.version>2.27.2</spotless.version>
<maven.checkstyle.version>3.2.1</maven.checkstyle.version>
<hbase.checkstyle.version>2.5.0</hbase.checkstyle.version>
<surefire.version>3.0.0</surefire.version>
<surefire.version>3.1.2</surefire.version>
<enforcer.version>3.0.0</enforcer.version>
<extra.enforcer.version>1.5.1</extra.enforcer.version>
<restrict-imports.enforcer.version>0.14.0</restrict-imports.enforcer.version>
Expand All @@ -173,6 +174,44 @@
<scoverage.version>1.4.11</scoverage.version>
<sbt-compiler.version>1.0.0</sbt-compiler.version>
<jacoco.version>0.8.8</jacoco.version>
<jacocoArgLine/>
<argLine/>
<spark-ut.args>-Xmx1536m -XX:ReservedCodeCacheSize=512m</spark-ut.args>
<spark-ut.argLine>${argLine} ${spark-ut.args}</spark-ut.argLine>
<!-- To Run Tests with a particular Xmx Value use -Dfailsafe.Xmx=XXXg -->
<failsafe.Xmx>4g</failsafe.Xmx>
<spark-it.args>-enableassertions -Xmx${failsafe.Xmx}
-Djava.security.egd=file:/dev/./urandom -XX:+CMSClassUnloadingEnabled
-verbose:gc -XX:+PrintCommandLineFlags -XX:+PrintFlagsFinal -XX:+IgnoreUnrecognizedVMOptions</spark-it.args>
<spark-it.argLine>${argLine} ${spark-it.args}</spark-it.argLine>
<hbase-surefire.argLine>-Djava.security.manager=allow</hbase-surefire.argLine>
<!-- Keep in sync with jvm flags in bin/hbase in main repo; Copied from there! -->
<hbase-surefire.jdk11.flags>-Dorg.apache.hbase.thirdparty.io.netty.tryReflectionSetAccessible=true
--add-modules jdk.unsupported
--add-opens java.base/java.io=ALL-UNNAMED
--add-opens java.base/java.nio=ALL-UNNAMED
--add-opens java.base/sun.nio.ch=ALL-UNNAMED
--add-opens java.base/java.lang=ALL-UNNAMED
--add-opens java.base/jdk.internal.ref=ALL-UNNAMED
--add-opens java.base/java.lang.reflect=ALL-UNNAMED
--add-opens java.base/java.util=ALL-UNNAMED
--add-opens java.base/java.util.concurrent=ALL-UNNAMED
--add-exports java.base/jdk.internal.misc=ALL-UNNAMED
--add-exports java.security.jgss/sun.security.krb5=ALL-UNNAMED
--add-exports java.base/sun.net.dns=ALL-UNNAMED
--add-exports java.base/sun.net.util=ALL-UNNAMED</hbase-surefire.jdk11.flags>
<hbase-surefire.jdk17.flags/>
<!-- Keep in sync with JavaModuleOptions.java from spark codebase;
Copied from there and next removed all duplicate hbase jvm flags and retained remaining ones -->
<spark-surefire.jdk11.flags>--add-opens=java.base/java.lang.invoke=ALL-UNNAMED
--add-opens=java.base/java.net=ALL-UNNAMED
--add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED
--add-opens=java.base/sun.nio.cs=ALL-UNNAMED
--add-opens=java.base/sun.security.action=ALL-UNNAMED
--add-opens=java.base/sun.util.calendar=ALL-UNNAMED
-Djdk.reflect.useDirectMethodHandle=false
-Dio.netty.tryReflectionSetAccessible=true</spark-surefire.jdk11.flags>
<spark-surefire.jdk17.flags/>
</properties>
<dependencyManagement>
<dependencies>
Expand Down Expand Up @@ -257,9 +296,10 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<artifactId>mockito-bom</artifactId>
<version>${mockito-all.version}</version>
<scope>test</scope>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.apache.hbase.thirdparty</groupId>
Expand Down Expand Up @@ -933,5 +973,39 @@
</plugins>
</build>
</profile>
<profile>
<id>build-with-jdk8</id>
<activation>
<jdk>1.8</jdk>
</activation>
<properties>
<maven.compiler.source>${compileSource}</maven.compiler.source>
<maven.compiler.target>${compileSource}</maven.compiler.target>
</properties>
</profile>
<profile>
<id>build-with-jdk11</id>
<activation>
<jdk>[11,)</jdk>
</activation>
<properties>
<maven.compiler.release>${releaseTarget}</maven.compiler.release>
<argLine>${hbase-surefire.jdk11.flags} ${spark-surefire.jdk11.flags}
${hbase-surefire.argLine}
${jacocoArgLine}</argLine>
</properties>
</profile>
<profile>
<id>build-with-jdk17</id>
<activation>
<jdk>[17,)</jdk>
</activation>
<properties>
<argLine>${hbase-surefire.jdk11.flags} ${spark-surefire.jdk11.flags}
${hbase-surefire.jdk17.flags} ${spark-surefire.jdk17.flags}
${hbase-surefire.argLine}
${jacocoArgLine}</argLine>
</properties>
</profile>
</profiles>
</project>
8 changes: 2 additions & 6 deletions spark/hbase-spark-it/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
<!-- Test inclusion patterns used by failsafe configuration -->
<unittest.include>**/Test*.java</unittest.include>
<integrationtest.include>**/IntegrationTest*.java</integrationtest.include>
<!-- To Run Tests with a particular Xmx Value use -Dfailsafe.Xmx=XXXg -->
<failsafe.Xmx>4g</failsafe.Xmx>
<!-- To run a single integration test, use -Dit.test=IntegrationTestXXX -->
</properties>

Expand Down Expand Up @@ -184,7 +182,7 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down Expand Up @@ -258,9 +256,7 @@
<!-- TODO: failsafe does timeout, but verify does not fail the build because of the timeout.
I believe it is a failsafe bug, we may consider using surefire -->
<forkedProcessTimeoutInSeconds>1800</forkedProcessTimeoutInSeconds>
<argLine>-enableassertions -Xmx${failsafe.Xmx}
-Djava.security.egd=file:/dev/./urandom -XX:+CMSClassUnloadingEnabled
-verbose:gc -XX:+PrintCommandLineFlags -XX:+PrintFlagsFinal</argLine>
<argLine>${spark-it.argLine}</argLine>
</configuration>
</plugin>
<plugin>
Expand Down
27 changes: 2 additions & 25 deletions spark/hbase-spark/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -442,27 +442,6 @@
</activation>
<build>
<plugins>
<!--This is ugly but saves having to mess with profiles.
This plugin uses groovy (yuck) just to set a single
variable, target.jvm, dependent on what the value of
scala version is.-->
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<goals>
<goal>execute</goal>
</goals>
<phase>validate</phase>
<configuration>
<source><![CDATA[pom.properties['target.jvm'] =
pom.properties['scala.version'].startsWith('2.10')? '': '-target:jvm-1.8';]]></source>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
Expand All @@ -472,8 +451,6 @@
<scalaVersion>${scala.version}</scalaVersion>
<args>
<arg>-feature</arg>
<!--The target.jvm variable gets set above by the groovy
snippet in the gmaven-plugin.-->
<arg>${target.jvm}</arg>
</args>
<source>${compileSource}</source>
Expand Down Expand Up @@ -515,7 +492,7 @@
</goals>
<phase>test</phase>
<configuration>
<argLine>-Xmx1536m -XX:ReservedCodeCacheSize=512m</argLine>
<argLine>${spark-ut.argLine}</argLine>
<parallel>false</parallel>
</configuration>
</execution>
Expand Down
1 change: 1 addition & 0 deletions spark/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
Please take caution when this version is modified -->
<scala.version>2.12.15</scala.version>
<scala.binary.version>2.12</scala.binary.version>
<target.jvm>-target:jvm-1.8</target.jvm>
</properties>

<dependencyManagement>
Expand Down

0 comments on commit 657573e

Please sign in to comment.