Skip to content

Commit

Permalink
GH-38501: [Java] Change Java minimum version to 11
Browse files Browse the repository at this point in the history
Channge minimum Java version to build Arrow to 11:
* Change minimum java version and source/target/release compiler
  properties to 11
* Remove maven modules
* Remove jdk11+ profiles and integrate their content into the main
  section
* Let maven-compiler-plugin process `module-info.java` files and address
  several declaration issues
* Exclude non modularized modules from javadoc aggregate tasks
* Replace maven-assembly-plugin usage with maven-shade-plugin to get
  better control on what is included/excluded from the jar
* Exclude module-info.class files from shaded jars as it is not
  representative of the whole content and may actually directly coming
  from a 3rd party dependency.
  • Loading branch information
laurentgo committed Jul 3, 2024
1 parent ba3c232 commit 36bfcf2
Show file tree
Hide file tree
Showing 21 changed files with 150 additions and 990 deletions.
45 changes: 25 additions & 20 deletions java/adapter/jdbc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ under the License.
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<scope>test</scope>
</dependency>

<dependency>
Expand All @@ -93,24 +92,30 @@ under the License.

</dependencies>

<profiles>
<profile>
<id>jdk11+</id>
<activation>
<jdk>[11,]</jdk>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration combine.self="override">
<argLine>--add-reads=org.apache.arrow.adapter.jdbc=com.fasterxml.jackson.dataformat.yaml --add-opens=java.base/java.nio=org.apache.arrow.memory.core,ALL-UNNAMED -Duser.timezone=UTC</argLine>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>analyze</id>
<phase>verify</phase>
<configuration>
<ignoredNonTestScopedDependencies>
<ignoredNonTestScopedDependency>com.fasterxml.jackson.core:jackson-annotations</ignoredNonTestScopedDependency>
</ignoredNonTestScopedDependencies>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration combine.self="override">
<argLine>--add-reads=org.apache.arrow.adapter.jdbc=com.fasterxml.jackson.dataformat.yaml --add-opens=java.base/java.nio=org.apache.arrow.memory.core,ALL-UNNAMED -Duser.timezone=UTC</argLine>
</configuration>
</plugin>
</plugins>
</build>
</project>
1 change: 1 addition & 0 deletions java/adapter/jdbc/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
exports org.apache.arrow.adapter.jdbc;
exports org.apache.arrow.adapter.jdbc.binder;

requires com.fasterxml.jackson.annotation;
requires com.fasterxml.jackson.databind;
requires java.sql;
requires jdk.unsupported;
Expand Down
6 changes: 4 additions & 2 deletions java/bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ under the License.
<properties>
<arrow.vector.classifier></arrow.vector.classifier>
<!-- org.apache:apache overrides -->
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<minimalJavaBuildVersion>11</minimalJavaBuildVersion>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.release>11</maven.compiler.release>
<maven.plugin.tools.version>3.12.0</maven.plugin.tools.version>
<surefire.version>3.2.5</surefire.version>
<version.apache-rat-plugin>0.16.1</version.apache-rat-plugin>
Expand Down
22 changes: 2 additions & 20 deletions java/dataset/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ under the License.
<scope>test</scope>
</dependency>
</dependencies>

<build>
<resources>
<resource>
Expand All @@ -179,6 +180,7 @@ under the License.
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine combine.self="override">--add-reads=org.apache.arrow.dataset=com.fasterxml.jackson.databind --add-opens=java.base/java.nio=org.apache.arrow.dataset,org.apache.arrow.memory.core,ALL-UNNAMED</argLine>
<enableAssertions>false</enableAssertions>
<systemPropertyVariables>
<arrow.test.dataRoot>${project.basedir}/../../testing/data</arrow.test.dataRoot>
Expand All @@ -202,24 +204,4 @@ under the License.
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>jdk11+</id>
<activation>
<jdk>[11,]</jdk>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine combine.self="override">--add-reads=org.apache.arrow.dataset=com.fasterxml.jackson.databind --add-opens=java.base/java.nio=org.apache.arrow.dataset,org.apache.arrow.memory.core,ALL-UNNAMED</argLine>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
97 changes: 38 additions & 59 deletions java/flight/flight-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,13 @@ under the License.
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine combine.self="override">--add-opens=org.apache.arrow.flight.core/org.apache.arrow.flight.perf.impl=protobuf.java --add-opens=java.base/java.nio=org.apache.arrow.memory.core,ALL-UNNAMED</argLine>
<enableAssertions>false</enableAssertions>
<systemPropertyVariables>
<arrow.test.dataRoot>${project.basedir}/../../../testing/data</arrow.test.dataRoot>
Expand All @@ -175,6 +177,13 @@ under the License.
<include>com.google.protobuf:*</include>
</includes>
</artifactSet>
<filters>
<filter>
<excludes>
<exclude>**/module-info.class</exclude>
</excludes>
</filter>
</filters>
<relocations>
<relocation>
<pattern>com.google.protobuf</pattern>
Expand Down Expand Up @@ -203,6 +212,13 @@ under the License.
<include>com.google.guava:*</include>
</includes>
</artifactSet>
<filters>
<filter>
<excludes>
<exclude>**/module-info.class</exclude>
</excludes>
</filter>
</filters>
<relocations>
<relocation>
<pattern>com.google.protobuf</pattern>
Expand All @@ -218,6 +234,28 @@ under the License.
</transformers>
</configuration>
</execution>
<execution>
<id>shade-jar-with-dependencies</id>
<goals>
<goal>shade</goal>
</goals>
<phase>package</phase>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>jar-with-dependencies</shadedClassifierName>
<filters>
<filter>
<excludes>
<exclude>**/module-info.class</exclude>
</excludes>
</filter>
</filters>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"></transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
Expand Down Expand Up @@ -261,65 +299,6 @@ under the License.
</execution>
</executions>
</plugin>
<plugin>
<!-- add generated sources to classpath -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-generated-sources-to-classpath</id>
<goals>
<goal>add-source</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<sources>
<source>${project.build.directory}/generated-sources/protobuf</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<goals>
<goal>single</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>jdk11+</id>
<activation>
<jdk>[11,]</jdk>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine combine.self="override">--add-opens=org.apache.arrow.flight.core/org.apache.arrow.flight.perf.impl=protobuf.java --add-opens=java.base/java.nio=org.apache.arrow.memory.core,ALL-UNNAMED</argLine>
<systemPropertyVariables>
<arrow.test.dataRoot>${project.basedir}/../../../testing/data</arrow.test.dataRoot>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
3 changes: 3 additions & 0 deletions java/flight/flight-core/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,15 @@
requires io.grpc.netty;
requires io.grpc.protobuf;
requires io.grpc.stub;
requires io.netty.buffer;
requires io.netty.common;
requires io.netty.handler;
requires io.netty.transport;
requires jsr305;
requires org.apache.arrow.format;
requires org.apache.arrow.memory.core;
requires org.apache.arrow.vector;
requires protobuf.java;
requires protobuf.java.util;
requires org.slf4j;
}
24 changes: 17 additions & 7 deletions java/flight/flight-integration-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,29 @@ under the License.
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<id>make-assembly</id>
<goals>
<goal>single</goal>
<goal>shade</goal>
</goals>
<phase>package</phase>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>jar-with-dependencies</shadedClassifierName>
<filters>
<filter>
<excludes>
<exclude>**/module-info.class</exclude>
</excludes>
</filter>
</filters>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"></transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
Expand Down
1 change: 1 addition & 0 deletions java/flight/flight-sql-jdbc-driver/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ under the License.
<exclude>META-INF/native/libio_grpc_netty*</exclude>
<exclude>META-INF/native/io_grpc_netty_shaded*</exclude>
<exclude>**/*.proto</exclude>
<exclude>**/module-info.class</exclude>
</excludes>
</filter>
</filters>
Expand Down
20 changes: 0 additions & 20 deletions java/flight/flight-sql/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -120,24 +120,4 @@ under the License.
<optional>true</optional>
</dependency>
</dependencies>

<profiles>
<profile>
<id>jdk11+</id>
<activation>
<jdk>[11,]</jdk>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration combine.self="override">
<argLine>--add-reads=org.apache.arrow.flight.sql=org.slf4j --add-reads=org.apache.arrow.flight.core=ALL-UNNAMED --add-opens=java.base/java.nio=org.apache.arrow.memory.core,ALL-UNNAMED</argLine>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
1 change: 1 addition & 0 deletions java/flight/flight-sql/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@
requires org.apache.arrow.flight.core;
requires org.apache.arrow.memory.core;
requires org.apache.arrow.vector;
requires org.apache.commons.cli;
requires protobuf.java;
}
13 changes: 0 additions & 13 deletions java/flight/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,4 @@ under the License.
<module>flight-sql-jdbc-driver</module>
<module>flight-integration-tests</module>
</modules>

<profiles>
<profile>
<id>pin-mockito-jdk8</id>
<activation>
<jdk>1.8</jdk>
</activation>
<properties>
<mockito.core.version>4.11.0</mockito.core.version>
<mockito.inline.version>5.2.0</mockito.inline.version>
</properties>
</profile>
</profiles>
</project>
Loading

0 comments on commit 36bfcf2

Please sign in to comment.