Skip to content

Commit

Permalink
javah!
Browse files Browse the repository at this point in the history
  • Loading branch information
lidavidm committed Mar 6, 2025
1 parent f403b13 commit dfeccdb
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 9 deletions.
25 changes: 16 additions & 9 deletions java/driver/jni/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,23 @@

find_package(AdbcDriverManager)

add_jar(adbc_driver_jni_jar
SOURCES src/main/java/org/apache/arrow/adbc/driver/jni/impl/NativeAdbc.java
src/main/java/org/apache/arrow/adbc/driver/jni/impl/NativeAdbcException.java
src/main/java/org/apache/arrow/adbc/driver/jni/impl/NativeHandle.java
src/main/java/org/apache/arrow/adbc/driver/jni/impl/NativeQueryResult.java
GENERATE_NATIVE_HEADERS
adbc_driver_jni_headers)
add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/target/headers/org_apache_arrow_adbc_driver_jni_impl_NativeAdbc.h
COMMENT "Generate JNI headers"
# Force Maven to actually re-run the command
COMMAND rm -rf ${CMAKE_CURRENT_SOURCE_DIR}/target/headers
${CMAKE_CURRENT_SOURCE_DIR}/target/maven-status
COMMAND mvn --file ${CMAKE_CURRENT_SOURCE_DIR}/../.. -Pjni,javah
compile --also-make --projects :adbc-driver-jni
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/main/java/org/apache/arrow/adbc/driver/jni/impl/NativeAdbc.java
)

add_library(adbc_driver_jni SHARED src/main/cpp/jni_wrapper.cc)
target_link_libraries(adbc_driver_jni adbc_driver_jni_headers JNI::JNI
add_library(adbc_driver_jni SHARED
src/main/cpp/jni_wrapper.cc
${CMAKE_CURRENT_SOURCE_DIR}/target/headers/org_apache_arrow_adbc_driver_jni_impl_NativeAdbc.h
)
target_include_directories(adbc_driver_jni
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/target/headers)
target_link_libraries(adbc_driver_jni JNI::JNI
AdbcDriverManager::adbc_driver_manager_static)

set(ADBC_DRIVER_JNI_C_LIBDIR "adbc_driver_jni/${ADBC_ARCH_DIR}")
Expand Down
21 changes: 21 additions & 0 deletions java/driver/jni/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,25 @@
</plugin>
</plugins>
</build>

<profiles>
<profile>
<!-- Invoked by CMake to generate headers. -->
<!-- You must first build the project (without JNI enabled). -->
<id>javah</id>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerArgs>
<arg>-h</arg>
<arg>${project.basedir}/target/headers</arg>
</compilerArgs>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
5 changes: 5 additions & 0 deletions java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,11 @@
<artifactId>spotless-maven-plugin</artifactId>
<version>2.44.2</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo.natives</groupId>
<artifactId>maven-native-javah</artifactId>
<version>1.0-M1</version>
</plugin>
</plugins>
</pluginManagement>

Expand Down

0 comments on commit dfeccdb

Please sign in to comment.