@@ -17,8 +17,63 @@ include(UseJava)
1717
1818file (GLOB JAVA_SRC_FILES src/main/java/com/lbugdb/*.java )
1919
20+ # The Java sources import Apache Arrow classes (org.apache.arrow.c.*,
21+ # org.apache.arrow.memory.*, org.apache.arrow.vector.*). When the Java
22+ # sources are compiled through Gradle, these are pulled in from Maven
23+ # Central via the dependencies block in build.gradle. The CMake build path
24+ # (used by `make java` and the per-platform native lib CI job) does not go
25+ # through Gradle, so we need to resolve the same JARs here. Versions are kept
26+ # in sync with build.gradle.
27+ set (LBUG_MAVEN_ARTIFACTS
28+ "org.apache.arrow:arrow-c-data:18.2.0"
29+ "org.apache.arrow:arrow-vector:18.2.0"
30+ "org.apache.arrow:arrow-memory-core:18.2.0"
31+ "org.apache.arrow:arrow-format:18.2.0"
32+ "com.google.flatbuffers:flatbuffers-java:24.3.25"
33+ )
34+
35+ # Download a single Maven artifact JAR into a local cache directory.
36+ # Args:
37+ # out_var - output variable to receive the path to the downloaded JAR
38+ # group_id - Maven group ID (e.g., org.apache.arrow)
39+ # artifact_id - Maven artifact ID (e.g., arrow-c-data)
40+ # version - Maven version (e.g., 18.2.0)
41+ function (lbug_download_maven_jar out_var group_id artifact_id version )
42+ string (REPLACE "." "/" group_path "${group_id} " )
43+ set (jar_name "${artifact_id} -${version} .jar" )
44+ set (url "https://repo1.maven.org/maven2/${group_path} /${artifact_id} /${version} /${jar_name} " )
45+ set (local_path "${CMAKE_CURRENT_BINARY_DIR } /maven_cache/${jar_name} " )
46+ if (NOT EXISTS "${local_path} " )
47+ message (STATUS "Downloading ${group_id} :${artifact_id} :${version} " )
48+ file (MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR } /maven_cache" )
49+ file (DOWNLOAD "${url} " "${local_path} "
50+ STATUS download_status
51+ LOG download_log
52+ TLS_VERIFY ON )
53+ list (GET download_status 0 status_code)
54+ list (GET download_status 1 error_msg)
55+ if (NOT status_code EQUAL 0)
56+ message (FATAL_ERROR
57+ "Failed to download Maven artifact ${group_id} :${artifact_id} :${version} "
58+ "from ${url} : ${error_msg} " )
59+ endif ()
60+ endif ()
61+ set (${out_var} "${local_path} " PARENT_SCOPE )
62+ endfunction ()
63+
64+ set (LBUG_MAVEN_JARS "" )
65+ foreach (artifact_spec IN LISTS LBUG_MAVEN_ARTIFACTS)
66+ string (REPLACE ":" ";" spec_parts "${artifact_spec} " )
67+ list (GET spec_parts 0 spec_group)
68+ list (GET spec_parts 1 spec_artifact)
69+ list (GET spec_parts 2 spec_version)
70+ lbug_download_maven_jar (jar_path "${spec_group} " "${spec_artifact} " "${spec_version} " )
71+ list (APPEND LBUG_MAVEN_JARS "${jar_path} " )
72+ endforeach ()
73+
2074set (CMAKE_JAVA_COMPILE_FLAGS -source 1.8 -target 1.8 -encoding utf-8)
2175add_jar (lbug_java ${JAVA_SRC_FILES}
76+ INCLUDE_JARS ${LBUG_MAVEN_JARS}
2277 OUTPUT_DIR "${PROJECT_SOURCE_DIR } /build"
2378 GENERATE_NATIVE_HEADERS lbug_native_header )
2479get_target_property (_jarFile lbug_java JAR_FILE)
0 commit comments