Skip to content

Commit dfeccdb

Browse files
committed
javah!
1 parent f403b13 commit dfeccdb

File tree

3 files changed

+42
-9
lines changed

3 files changed

+42
-9
lines changed

java/driver/jni/CMakeLists.txt

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,23 @@
1717

1818
find_package(AdbcDriverManager)
1919

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

28-
add_library(adbc_driver_jni SHARED src/main/cpp/jni_wrapper.cc)
29-
target_link_libraries(adbc_driver_jni adbc_driver_jni_headers JNI::JNI
30+
add_library(adbc_driver_jni SHARED
31+
src/main/cpp/jni_wrapper.cc
32+
${CMAKE_CURRENT_SOURCE_DIR}/target/headers/org_apache_arrow_adbc_driver_jni_impl_NativeAdbc.h
33+
)
34+
target_include_directories(adbc_driver_jni
35+
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/target/headers)
36+
target_link_libraries(adbc_driver_jni JNI::JNI
3037
AdbcDriverManager::adbc_driver_manager_static)
3138

3239
set(ADBC_DRIVER_JNI_C_LIBDIR "adbc_driver_jni/${ADBC_ARCH_DIR}")

java/driver/jni/pom.xml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,25 @@
9292
</plugin>
9393
</plugins>
9494
</build>
95+
96+
<profiles>
97+
<profile>
98+
<!-- Invoked by CMake to generate headers. -->
99+
<!-- You must first build the project (without JNI enabled). -->
100+
<id>javah</id>
101+
<build>
102+
<plugins>
103+
<plugin>
104+
<artifactId>maven-compiler-plugin</artifactId>
105+
<configuration>
106+
<compilerArgs>
107+
<arg>-h</arg>
108+
<arg>${project.basedir}/target/headers</arg>
109+
</compilerArgs>
110+
</configuration>
111+
</plugin>
112+
</plugins>
113+
</build>
114+
</profile>
115+
</profiles>
95116
</project>

java/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,11 @@
179179
<artifactId>spotless-maven-plugin</artifactId>
180180
<version>2.44.2</version>
181181
</plugin>
182+
<plugin>
183+
<groupId>org.codehaus.mojo.natives</groupId>
184+
<artifactId>maven-native-javah</artifactId>
185+
<version>1.0-M1</version>
186+
</plugin>
182187
</plugins>
183188
</pluginManagement>
184189

0 commit comments

Comments
 (0)