Skip to content

Commit

Permalink
Move native binaries to a sub-folder based on library name
Browse files Browse the repository at this point in the history
Move native binaries to a sub-folder based on the library name
instead of directly to a folder based on architecture.

This is because JPMS is treating any folder as potentially a
package name and if we have the same folder name appear
across modules it gets treated as a package conflict.
  • Loading branch information
jduo committed Jan 11, 2024
1 parent 3be0464 commit 72747ae
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 8 deletions.
21 changes: 20 additions & 1 deletion java/adapter/orc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,30 @@
<build>
<resources>
<resource>
<directory>${arrow.cpp.build.dir}</directory>
<directory>${arrow.cpp.build.dir}/arrow_orc_jni</directory>
<includes>
<include>**/*arrow_orc_jni.*</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>com.coderplus.maven.plugins</groupId>
<artifactId>copy-rename-maven-plugin</artifactId>
<executions>
<execution>
<id>copy-file</id>
<phase>generate-sources</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<sourceFile>${arrow.cpp.build.dir}</sourceFile>
<destinationFile>${arrow.cpp.build.dir}/arrow_orc_jni</destinationFile>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ static void loadOrcAdapterLibraryFromJar()
synchronized (OrcJniUtils.class) {
if (!isLoaded) {
final String libraryToLoad =
getNormalizedArch() + "/" + System.mapLibraryName(LIBRARY_NAME);
LIBRARY_NAME + "/" + getNormalizedArch() + "/" + System.mapLibraryName(LIBRARY_NAME);
final File libraryFile =
moveFileFromJarToTemp(System.getProperty("java.io.tmpdir"), libraryToLoad, LIBRARY_NAME);
System.load(libraryFile.getAbsolutePath());
Expand Down
21 changes: 20 additions & 1 deletion java/c/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,31 @@
<build>
<resources>
<resource>
<directory>${arrow.c.jni.dist.dir}</directory>
<directory>${arrow.c.jni.dist.dir}/arrow_cdata_jni</directory>
<includes>
<include>**/*arrow_cdata_jni.*</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>com.coderplus.maven.plugins</groupId>
<artifactId>copy-rename-maven-plugin</artifactId>
<executions>
<execution>
<id>copy-file</id>
<phase>generate-sources</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<sourceFile>${arrow.cpp.build.dir}</sourceFile>
<destinationFile>${arrow.cpp.build.dir}/arrow_cdata_jni</destinationFile>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
2 changes: 1 addition & 1 deletion java/c/src/main/java/org/apache/arrow/c/jni/JniLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private synchronized void loadRemaining() {

private void load(String name) {
final String libraryToLoad =
getNormalizedArch() + "/" + System.mapLibraryName(name);
name + "/" + getNormalizedArch() + "/" + System.mapLibraryName(name);
try {
File temp = File.createTempFile("jnilib-", ".tmp", new File(System.getProperty("java.io.tmpdir")));
temp.deleteOnExit();
Expand Down
19 changes: 18 additions & 1 deletion java/dataset/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,31 @@
<build>
<resources>
<resource>
<directory>${arrow.cpp.build.dir}</directory>
<directory>${arrow.cpp.build.dir}/arrow_dataset_jni</directory>
<includes>
<include>**/*arrow_dataset_jni.*</include>
</includes>
</resource>
</resources>

<plugins>
<plugin>
<groupId>com.coderplus.maven.plugins</groupId>
<artifactId>copy-rename-maven-plugin</artifactId>
<executions>
<execution>
<id>copy-file</id>
<phase>generate-sources</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<sourceFile>${arrow.cpp.build.dir}</sourceFile>
<destinationFile>${arrow.cpp.build.dir}/arrow_dataset_jni</destinationFile>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private synchronized void loadRemaining() {

private void load(String name) {
final String libraryToLoad =
getNormalizedArch() + "/" + System.mapLibraryName(name);
name + "/" + getNormalizedArch() + "/" + System.mapLibraryName(name);
try {
File temp = File.createTempFile("jnilib-", ".tmp", new File(System.getProperty("java.io.tmpdir")));
temp.deleteOnExit();
Expand Down
19 changes: 18 additions & 1 deletion java/gandiva/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
<build>
<resources>
<resource>
<directory>${arrow.cpp.build.dir}</directory>
<directory>${arrow.cpp.build.dir}/gandiva_jni</directory>
<includes>
<include>**/*gandiva_jni.*</include>
</includes>
Expand All @@ -129,6 +129,23 @@
</extension>
</extensions>
<plugins>
<plugin>
<groupId>com.coderplus.maven.plugins</groupId>
<artifactId>copy-rename-maven-plugin</artifactId>
<executions>
<execution>
<id>copy-file</id>
<phase>generate-sources</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<sourceFile>${arrow.cpp.build.dir}</sourceFile>
<destinationFile>${arrow.cpp.build.dir}/gandiva_jni</destinationFile>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private static JniLoader setupInstance() throws GandivaException {
private static void loadGandivaLibraryFromJar(final String tmpDir)
throws IOException, GandivaException {
final String libraryToLoad =
getNormalizedArch() + "/" + System.mapLibraryName(LIBRARY_NAME);
LIBRARY_NAME + "/" + getNormalizedArch() + "/" + System.mapLibraryName(LIBRARY_NAME);
final File libraryFile = moveFileFromJarToTemp(tmpDir, libraryToLoad, LIBRARY_NAME);
System.load(libraryFile.getAbsolutePath());
}
Expand Down
5 changes: 5 additions & 0 deletions java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,11 @@
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<groupId>com.coderplus.maven.plugins</groupId>
<artifactId>copy-rename-maven-plugin</artifactId>
<version>1.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
Expand Down

0 comments on commit 72747ae

Please sign in to comment.