Skip to content
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

GH-38915: [Java] Upgrade Arrow Java project to JPMS Java Platform Module System #38876

Closed
wants to merge 35 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
a97a661
Fix CData related test failures
jduo Nov 23, 2023
b605164
Standardize use of maven-shade-plugin
jduo Nov 23, 2023
7abc773
Update maven-shade-plugin to 3.5.1
jduo Nov 23, 2023
25be610
Update CycloneDX plugin to 2.7.10
jduo Nov 23, 2023
0695e46
Update grpc-java to 1.59
jduo Nov 23, 2023
0d118ec
Update maven-depndency-plugin to 3.6.1
jduo Nov 23, 2023
607a9c1
Exclude module-info.java files from the build
jduo Nov 23, 2023
a9dba8a
Refactor memory modules for JPMS support
jduo Nov 24, 2023
a8bf813
Downgrade maven-dependency-plugin to 3.1.2
jduo Nov 24, 2023
da16115
Downgrade maven-shade-plugin to 3.2.4 for arrow-vector only
jduo Nov 24, 2023
0a21d54
Patch Netty when the profile is JDK9 only
jduo Nov 24, 2023
02a0ee2
Ignore TestBaseAllocator#testRootAllocator_getEmpty
jduo Nov 24, 2023
b0e9e7b
Downgrade the maven-shade-plugin to 3.2.4 in flight-core
jduo Nov 24, 2023
4301efd
Add and integrate the module-info compiler plugin
jduo Nov 24, 2023
cd8b19e
Fix JDK8 compile issue with module-info-compiler and attempt to fix a…
jduo Nov 24, 2023
2ffc604
Fix JDK8 issue with use of Path.of
jduo Nov 24, 2023
ba26997
Skip the maven-dependency-plugin analyze check due to false positive
jduo Nov 25, 2023
5bc2501
Fix non-inherited version
jduo Nov 26, 2023
6813629
Do not use dependency analyze when compiling plugins
jduo Nov 26, 2023
0598506
Exclude module-info.java files from checkstyle
jduo Nov 27, 2023
e2b33af
Add skip parameter and logging to module info compiler plugin
jduo Nov 27, 2023
b98bb38
Update maven-compiler-plugin to 3.11.0 for useModulePath flag
jduo Nov 27, 2023
ce34a33
Remove Netty patching
jduo Nov 28, 2023
3d59fbf
Add module-info.java files for memory, vector, and format
jduo Nov 28, 2023
03c1e6c
Update the surefire command line to properly allow reflection for net…
jduo Nov 28, 2023
4f3a3a1
Allow reflection to be used from memory-unsafe and memory-netty modul…
jduo Nov 28, 2023
533a50b
Explicitly depend on immutables in memory-unsafe
jduo Nov 28, 2023
bfd81e2
Restructure Netty tests for modules
jduo Nov 28, 2023
0b1c787
Update jackson to 2.16.0
jduo Nov 28, 2023
6db0e89
Move arrow-vector tests to use a different package
jduo Nov 28, 2023
1b6b3ba
Explicitly have arrow-vector depend on immutables
jduo Nov 28, 2023
01c594b
Export packages for arrow-vector module
jduo Nov 28, 2023
fd32b2d
Fix a missed reference to moved arrow-vector test classes
jduo Nov 28, 2023
0bb6db1
Edit TestArrowBuf#testEnabledHistoricalLog to have more info
jduo Nov 28, 2023
48c494e
Enable java.lang.reflect on memory-core module for tests
jduo Nov 28, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions java/algorithm/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<artifactId>arrow-vector</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.arrow</groupId>
Expand Down
5 changes: 5 additions & 0 deletions java/c/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@
<artifactId>arrow-memory-unsafe</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.arrow</groupId>
<artifactId>arrow-format</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import org.apache.arrow.dataset.file.DatasetFileWriter;
import org.apache.arrow.dataset.file.FileFormat;
import org.apache.arrow.memory.BufferAllocator;
import org.apache.arrow.util.ArrowTestDataUtil;
import org.apache.arrow.vector.BigIntVector;
import org.apache.arrow.vector.BitVector;
import org.apache.arrow.vector.DateMilliVector;
Expand Down Expand Up @@ -76,6 +75,7 @@
import org.apache.arrow.vector.types.pojo.Field;
import org.apache.arrow.vector.types.pojo.FieldType;
import org.apache.arrow.vector.types.pojo.Schema;
import org.apache.arrow.vector.util.ArrowTestDataUtil;
import org.apache.arrow.vector.util.ByteArrayReadableSeekableByteChannel;
import org.apache.arrow.vector.util.Text;
import org.junit.ClassRule;
Expand Down
12 changes: 7 additions & 5 deletions java/flight/flight-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@
<groupId>io.grpc</groupId>
<artifactId>grpc-core</artifactId>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-context</artifactId>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-protobuf</artifactId>
Expand Down Expand Up @@ -149,7 +145,13 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.1</version>
<!--
Downgrade maven-shade-plugin specifically for this module.
Using a newer version up to at least 3.5.1 will cause
issues in the arrow-tools tests looking up FlatBuffer
dependencies.
-->
<version>3.2.4</version>
<executions>
<execution>
<id>shade-main</id>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import java.util.List;
import java.util.Random;

import org.apache.arrow.util.ArrowTestDataUtil;
import org.apache.arrow.vector.util.ArrowTestDataUtil;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.function.Executable;

Expand Down
11 changes: 6 additions & 5 deletions java/flight/flight-grpc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,13 @@
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-core</artifactId>
<artifactId>grpc-stub</artifactId>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-inprocess</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
</dependency>
<dependency>
<groupId>org.apache.arrow</groupId>
<artifactId>arrow-memory-core</artifactId>
Expand Down
1 change: 0 additions & 1 deletion java/flight/flight-sql-jdbc-driver/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.4.1</version>
<executions>
<execution>
<phase>package</phase>
Expand Down
2 changes: 2 additions & 0 deletions java/flight/flight-sql/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
<dependency>
<groupId>org.apache.arrow</groupId>
<artifactId>arrow-jdbc</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
Expand All @@ -70,6 +71,7 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
Expand Down
21 changes: 21 additions & 0 deletions java/format/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

module org.apache.arrow.format {
exports org.apache.arrow.flatbuf;
requires transitive flatbuffers.java;
}
130 changes: 130 additions & 0 deletions java/maven/module-info-compiler-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor
license agreements. See the NOTICE file distributed with this work for additional
information regarding copyright ownership. The ASF licenses this file to
You under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of
the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
by applicable law or agreed to in writing, software distributed under the
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
OF ANY KIND, either express or implied. See the License for the specific
language governing permissions and limitations under the License. -->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.arrow.maven.plugins</groupId>
<artifactId>arrow-maven-plugins</artifactId>
<version>15.0.0-SNAPSHOT</version>
</parent>
<artifactId>module-info-compiler-maven-plugin</artifactId>
<packaging>maven-plugin</packaging>

<name>Module Info Compiler Maven Plugin</name>

<url>https://arrow.apache.org</url>

<prerequisites>
<maven>${maven.version}</maven>
</prerequisites>

<properties>
<maven.version>3.3.9</maven.version>
</properties>

<dependencies>
<dependency>
<groupId>org.glavo</groupId>
<artifactId>module-info-compiler</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>${maven.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>${maven.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
<version>${maven.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
<version>${maven.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.6.0</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<plugin>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.6.0</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<plugin>
<artifactId>maven-invoker-plugin</artifactId>
<version>3.1.0</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
</configuration>
<executions>
<execution>
<id>mojo-descriptor</id>
<goals>
<goal>descriptor</goal>
</goals>
</execution>
<execution>
<id>help-goal</id>
<goals>
<goal>helpmojo</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>


</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.arrow.maven.plugins;

import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.Reader;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.glavo.mic.ModuleInfoCompiler;

/**
* Compiles the first module-info.java file in the project purely syntactically.
*/
@Mojo(name = "module-info-compile", defaultPhase = LifecyclePhase.COMPILE)
public class ModuleInfoCompilerPlugin extends AbstractMojo {
/**
* Source directories.
*/
@Parameter(defaultValue = "${project.compileSourceRoots}", property = "compileSourceRoots",
required = true)
private final List<String> compileSourceRoots = new ArrayList<>();

@Parameter(defaultValue = "false", property = "skip", required = false)
private boolean skip = false;

@Parameter(defaultValue = "${project}", readonly = true, required = true)
private MavenProject project;

@Override
public void execute() throws MojoExecutionException {
if (skip) {
getLog().info("Skipping module-info-compiler-maven-plugin");
return;
}

Optional<File> moduleInfoFile = findFirstModuleInfo(compileSourceRoots);
if (moduleInfoFile.isPresent()) {
// The compiled module-info.class file goes into target/classes/module-info/main
Path outputDir = Paths.get(project.getBuild().getOutputDirectory());

outputDir.toFile().mkdirs();
Path targetPath = outputDir.resolve("module-info.class");

// Invoke the compiler,
ModuleInfoCompiler compiler = new ModuleInfoCompiler();
try (Reader reader = new InputStreamReader(Files.newInputStream(moduleInfoFile.get().toPath()),
StandardCharsets.UTF_8);
OutputStream output = Files.newOutputStream(targetPath)) {
compiler.compile(reader, output);
getLog().info("Successfully wrote module-info.class file.");
} catch (IOException ex) {
throw new MojoExecutionException("Error compiling module-info.java", ex);
}
} else {
getLog().info("No module-info.java file found. module-info.class file was not generated.");
}
}

/**
* Finds the first module-info.java file in the set of source directories.
*/
private Optional<File> findFirstModuleInfo(List<String> sourceDirectories) {
if (sourceDirectories == null) {
return Optional.empty();
}

return sourceDirectories.stream().map(Paths::get)
.map(sourcePath ->
sourcePath.toFile().listFiles(file ->
file.getName().equals("module-info.java")))
.filter(matchingFiles -> matchingFiles != null && matchingFiles.length != 0)
.map(matchingFiles -> matchingFiles[0])
.findAny();
}
}
Loading