From 2fd39f0d86b5fabda6f35c0d6e5bf19d707dd977 Mon Sep 17 00:00:00 2001 From: Vicente Adolfo Bolea Sanchez <vicente.bolea@kitware.com> Date: Wed, 8 May 2024 22:01:36 -0400 Subject: [PATCH] java: update java modules to latest vtk modules - MACOSX_DEPLOYMENT_TARGET>=10 uses dynlib files (as opposed to jnilib files). --- Accelerators/Vtkm/Core/vtk.module | 1 + CMake/vtkModuleWrapJava.cmake | 30 +- CMakeLists.txt | 17 +- .../docs/build_instructions/build_settings.md | 4 + Filters/Temporal/vtk.module | 1 + IO/Cesium3DTiles/vtk.module | 1 + Rendering/VR/vtk.module | 1 + Utilities/Java/CMakeLists.txt | 19 +- Utilities/Java/vtkJavaAwt.h | 22 +- Utilities/Java/vtkJavaUtil.cxx | 3 +- Utilities/Java/vtkJavaUtil.h | 37 +- Wrapping/Java/CMakeLists.txt | 45 ++- Wrapping/Java/JavaInstall.cmake.in | 28 +- Wrapping/Java/Maven/README.txt.in | 2 +- Wrapping/Java/Maven/pom.xml.in | 325 +++++++++++------- Wrapping/Java/vtk/vtkSettings.java.in | 2 +- Wrapping/Tools/vtkWrapJava.c | 10 + 17 files changed, 351 insertions(+), 197 deletions(-) diff --git a/Accelerators/Vtkm/Core/vtk.module b/Accelerators/Vtkm/Core/vtk.module index b3e57b76974..da45e4e365e 100644 --- a/Accelerators/Vtkm/Core/vtk.module +++ b/Accelerators/Vtkm/Core/vtk.module @@ -25,3 +25,4 @@ TEST_DEPENDS VTK::ImagingCore VTK::CommonDataModel VTK::TestingCore + VTK::TestingRendering diff --git a/CMake/vtkModuleWrapJava.cmake b/CMake/vtkModuleWrapJava.cmake index 6ffec6c96f0..a4bd339fdeb 100644 --- a/CMake/vtkModuleWrapJava.cmake +++ b/CMake/vtkModuleWrapJava.cmake @@ -275,7 +275,32 @@ function (_vtk_module_wrap_java_library name) _vtk_module_get_module_property("${_vtk_java_module}" PROPERTY "depends" VARIABLE _vtk_java_module_depends) + _vtk_module_get_module_property("${_vtk_java_module}" + PROPERTY "private_depends" + VARIABLE _vtk_java_module_private_depends) + _vtk_module_get_module_property("${_vtk_java_module}" + PROPERTY "optional_depends" + VARIABLE _vtk_java_module_optional_depends) + _vtk_module_get_module_property("${_vtk_java_module}" + PROPERTY "implements" + VARIABLE _vtk_java_module_implements) + + list(APPEND _vtk_java_module_depends + ${_vtk_java_module_private_depends} + ${_vtk_java_module_implements}) + + foreach (_vtk_java_optional_depend IN LISTS _vtk_java_module_optional_depends) + if (TARGET "${_vtk_java_optional_depend}") + list(APPEND _vtk_java_module_depends "${_vtk_java_optional_depend}") + endif () + endforeach () + foreach (_vtk_java_module_depend IN LISTS _vtk_java_module_depends) + # Remove self dependency, this is needed for self-implementing modules + if (_vtk_java_module_depend STREQUAL _vtk_java_module) + continue() + endif() + _vtk_module_get_module_property("${_vtk_java_module_depend}" PROPERTY "exclude_wrap" VARIABLE _vtk_java_module_depend_exclude_wrap) @@ -331,11 +356,6 @@ function (_vtk_module_wrap_java_library name) PROPERTY PREFIX "") endif () - if (APPLE) - set_property(TARGET "${_vtk_java_target}" - PROPERTY - SUFFIX ".jnilib") - endif () set_property(TARGET "${_vtk_java_target}" PROPERTY "_vtk_module_java_files" "${_vtk_java_library_java_sources}") diff --git a/CMakeLists.txt b/CMakeLists.txt index 1b317e421e6..e9663f0d61e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -551,9 +551,22 @@ if (VTK_CUSTOM_LIBRARY_SUFFIX STREQUAL "<DEFAULT>") endif () endif () + +set(VTK_CUSTOM_LIBRARY_VERSION "<DEFAULT>" + CACHE STRING "Custom library version (defaults to the version number)") +if (VTK_CUSTOM_LIBRARY_VERSION STREQUAL "<DEFAULT>") + if (VTK_VERSIONED_INSTALL) + set(VTK_CUSTOM_LIBRARY_VERSION "${VTK_MAJOR_VERSION}.${VTK_MINOR_VERSION}") + else () + set(VTK_CUSTOM_LIBRARY_VERSION "") + endif () +endif () + +set(VTK_CUSTOM_LIBRARY_SOVERSION "1" CACHE STRING "Custom library soversion (defaults to 1)") + set(vtk_library_version_info - VERSION "${VTK_MAJOR_VERSION}.${VTK_MINOR_VERSION}" - SOVERSION "1") + VERSION "${VTK_CUSTOM_LIBRARY_VERSION}" + SOVERSION "${VTK_CUSTOM_LIBRARY_SOVERSION}") if (VTK_WHEEL_BUILD) set(vtk_library_version_info) endif () diff --git a/Documentation/docs/build_instructions/build_settings.md b/Documentation/docs/build_instructions/build_settings.md index eec7ec4613f..499044e948b 100644 --- a/Documentation/docs/build_instructions/build_settings.md +++ b/Documentation/docs/build_instructions/build_settings.md @@ -133,6 +133,10 @@ More advanced options: The custom suffix for libraries built by VTK. Defaults to either an empty string or `X.Y` where `X` and `Y` are VTK's major and minor version components, respectively. + * `VTK_CUSTOM_LIBRARY_VERSION` (default depends on `VTK_VERSIONED_INSTALL`): + The custom version for libraries built by VTK. Defaults to either an empty + string or `X.Y` where `X` and `Y` are VTK's major and minor version if + VTK_VERSIONED_INSTALL is ON. * `VTK_INSTALL_SDK` (default `ON`): If set, VTK will install its headers, CMake API, etc. into its install tree for use. * `VTK_FORBID_DOWNLOADS` (default `OFF`): If set, VTK will error on any diff --git a/Filters/Temporal/vtk.module b/Filters/Temporal/vtk.module index 6613c6fbe37..80eba9d8f0a 100644 --- a/Filters/Temporal/vtk.module +++ b/Filters/Temporal/vtk.module @@ -15,6 +15,7 @@ DEPENDS PRIVATE_DEPENDS VTK::CommonCore VTK::CommonDataModel + VTK::CommonExecutionModel TEST_DEPENDS VTK::CommonExecutionModel VTK::FiltersGeneral diff --git a/IO/Cesium3DTiles/vtk.module b/IO/Cesium3DTiles/vtk.module index 51ec936a364..0140f8e375b 100644 --- a/IO/Cesium3DTiles/vtk.module +++ b/IO/Cesium3DTiles/vtk.module @@ -12,6 +12,7 @@ DEPENDS VTK::IOCore PRIVATE_DEPENDS VTK::CommonCore + VTK::CommonExecutionModel VTK::CommonTransforms VTK::CommonSystem VTK::IOImage diff --git a/Rendering/VR/vtk.module b/Rendering/VR/vtk.module index aa9581969e1..52f64e5d552 100644 --- a/Rendering/VR/vtk.module +++ b/Rendering/VR/vtk.module @@ -12,6 +12,7 @@ DEPENDS VTK::IOXMLParser VTK::InteractionStyle VTK::InteractionWidgets + VTK::RenderingCore VTK::RenderingOpenGL2 VTK::RenderingVolumeOpenGL2 VTK::RenderingVRModels diff --git a/Utilities/Java/CMakeLists.txt b/Utilities/Java/CMakeLists.txt index 65ee761ac18..ac859fd8462 100644 --- a/Utilities/Java/CMakeLists.txt +++ b/Utilities/Java/CMakeLists.txt @@ -9,15 +9,22 @@ set(headers vtk_module_add_module(VTK::Java CLASSES ${classes} - HEADERS ${headers}) -vtk_module_include(VTK::Java SYSTEM - PUBLIC - ${JNI_INCLUDE_DIRS}) + HEADERS ${headers} +) + +foreach(jni_include_dir IN LISTS JNI_INCLUDE_DIRS) + # We cannot pass a list to vtk_module_include inside a BUILD_INTERFACE + vtk_module_include(VTK::Java SYSTEM PUBLIC + "$<BUILD_INTERFACE:${jni_include_dir}>" + ) +endforeach() + vtk_module_link(VTK::Java PUBLIC - ${JNI_LIBRARIES}) + ${JNI_LIBRARIES} +) - if (NOT VTK_ABI_NAMESPACE_NAME STREQUAL "<DEFAULT>" AND NOT DEFINED ENV{CI}) +if (NOT VTK_ABI_NAMESPACE_NAME STREQUAL "<DEFAULT>" AND NOT DEFINED ENV{CI}) message(WARNING "Utilties::Java ABI does not not support the VTK_ABI_NAMESPACE_NAME " "and the symbols will not be mangled.") endif () diff --git a/Utilities/Java/vtkJavaAwt.h b/Utilities/Java/vtkJavaAwt.h index 48610e97792..e35e95873b1 100644 --- a/Utilities/Java/vtkJavaAwt.h +++ b/Utilities/Java/vtkJavaAwt.h @@ -56,6 +56,9 @@ extern "C" JNIEXPORT jint JNICALL Java_vtk_vtkPanel_RenderCreate( vtkRenderWindow* temp0; temp0 = (vtkRenderWindow*)(vtkJavaGetPointerFromObject(env, id0)); + // Avoid non-used var warnings + (void)temp0; + /* Get the AWT */ awt.version = JAWT_VERSION_1_3; if (JAWT_GetAWT(env, &awt) == JNI_FALSE) @@ -106,13 +109,7 @@ extern "C" JNIEXPORT jint JNICALL Java_vtk_vtkPanel_RenderCreate( temp0->SetDisplayId((void*)dsi_win->hdc); // also set parent id to avoid border sizes being added temp0->SetParentId((void*)dsi_win->hdc); -// use mac code -#elif defined(__APPLE__) - JAWT_DrawingSurfaceInfo* dsi_mac; - dsi_mac = (JAWT_DrawingSurfaceInfo*)dsi->platformInfo; - // temp0->SetWindowId(dsi_mac->cocoaViewRef); // Wrong but allow compilation -// otherwise use X11 code -#else +#elif !defined(__APPLE__) JAWT_X11DrawingSurfaceInfo* dsi_x11; dsi_x11 = (JAWT_X11DrawingSurfaceInfo*)dsi->platformInfo; temp0->SetDisplayId((void*)dsi_x11->display); @@ -157,6 +154,9 @@ extern "C" JNIEXPORT jint JNICALL Java_vtk_rendering_awt_vtkInternalAwtComponent vtkRenderWindow* temp0; temp0 = (vtkRenderWindow*)(vtkJavaGetPointerFromObject(env, id0)); + // Avoid non-used var warnings + (void)temp0; + /* Get the AWT */ awt.version = JAWT_VERSION_1_3; if (JAWT_GetAWT(env, &awt) == JNI_FALSE) @@ -207,13 +207,7 @@ extern "C" JNIEXPORT jint JNICALL Java_vtk_rendering_awt_vtkInternalAwtComponent temp0->SetDisplayId((void*)dsi_win->hdc); // also set parent id to avoid border sizes being added temp0->SetParentId((void*)dsi_win->hdc); -// use mac code -#elif defined(__APPLE__) - JAWT_DrawingSurfaceInfo* dsi_mac; - dsi_mac = (JAWT_DrawingSurfaceInfo*)dsi->platformInfo; - // temp0->SetWindowId(dsi_mac->cocoaViewRef); // Wrong but allow compilation -// otherwise use X11 code -#else +#elif !defined(__APPLE__) JAWT_X11DrawingSurfaceInfo* dsi_x11; dsi_x11 = (JAWT_X11DrawingSurfaceInfo*)dsi->platformInfo; temp0->SetDisplayId((void*)dsi_x11->display); diff --git a/Utilities/Java/vtkJavaUtil.cxx b/Utilities/Java/vtkJavaUtil.cxx index 3a5e574a059..500d931533c 100644 --- a/Utilities/Java/vtkJavaUtil.cxx +++ b/Utilities/Java/vtkJavaUtil.cxx @@ -163,7 +163,8 @@ JNIEXPORT jbyteArray vtkJavaStringToUTF8(JNIEnv* env, const std::string& text) JNIEXPORT jbyteArray vtkJavaCharsToUTF8(JNIEnv* env, const char* chars, size_t length) { - return vtkJavaMakeJArrayOfByte(env, reinterpret_cast<const jbyte*>(chars), length); + return vtkJavaMakeJArrayOfByte( + env, reinterpret_cast<const jbyte*>(chars), static_cast<int>(length)); } //**jcp this is the callback interface stub for Java. no user parms are passed diff --git a/Utilities/Java/vtkJavaUtil.h b/Utilities/Java/vtkJavaUtil.h index f9a390c86ab..957f7712f6e 100644 --- a/Utilities/Java/vtkJavaUtil.h +++ b/Utilities/Java/vtkJavaUtil.h @@ -11,23 +11,20 @@ #include <string> -extern VTKJAVA_EXPORT void* vtkJavaGetPointerFromObject(JNIEnv* env, jobject obj); -extern VTKJAVA_EXPORT char* vtkJavaUTF8ToChars(JNIEnv* env, jbyteArray bytes, jint length); -extern VTKJAVA_EXPORT std::string vtkJavaUTF8ToString(JNIEnv* env, jbyteArray bytes, jint length); -extern VTKJAVA_EXPORT jbyteArray vtkJavaCharsToUTF8(JNIEnv* env, const char* chars, size_t length); -extern VTKJAVA_EXPORT jbyteArray vtkJavaStringToUTF8(JNIEnv* env, const std::string& text); +extern JNIEXPORT void* vtkJavaGetPointerFromObject(JNIEnv* env, jobject obj); +extern JNIEXPORT char* vtkJavaUTF8ToChars(JNIEnv* env, jbyteArray bytes, jint length); +extern JNIEXPORT std::string vtkJavaUTF8ToString(JNIEnv* env, jbyteArray bytes, jint length); +extern JNIEXPORT jbyteArray vtkJavaCharsToUTF8(JNIEnv* env, const char* chars, size_t length); +extern JNIEXPORT jbyteArray vtkJavaStringToUTF8(JNIEnv* env, const std::string& text); -extern VTKJAVA_EXPORT jbooleanArray vtkJavaMakeJArrayOfBoolean( +extern JNIEXPORT jbooleanArray vtkJavaMakeJArrayOfBoolean( JNIEnv* env, const jboolean* ptr, int size); -extern VTKJAVA_EXPORT jdoubleArray vtkJavaMakeJArrayOfDouble( - JNIEnv* env, const jdouble* ptr, int size); -extern VTKJAVA_EXPORT jfloatArray vtkJavaMakeJArrayOfFloat( - JNIEnv* env, const jfloat* ptr, int size); -extern VTKJAVA_EXPORT jbyteArray vtkJavaMakeJArrayOfByte(JNIEnv* env, const jbyte* ptr, int size); -extern VTKJAVA_EXPORT jshortArray vtkJavaMakeJArrayOfShort( - JNIEnv* env, const jshort* ptr, int size); -extern VTKJAVA_EXPORT jintArray vtkJavaMakeJArrayOfInt(JNIEnv* env, const jint* ptr, int size); -extern VTKJAVA_EXPORT jlongArray vtkJavaMakeJArrayOfLong(JNIEnv* env, const jlong* ptr, int size); +extern JNIEXPORT jdoubleArray vtkJavaMakeJArrayOfDouble(JNIEnv* env, const jdouble* ptr, int size); +extern JNIEXPORT jfloatArray vtkJavaMakeJArrayOfFloat(JNIEnv* env, const jfloat* ptr, int size); +extern JNIEXPORT jbyteArray vtkJavaMakeJArrayOfByte(JNIEnv* env, const jbyte* ptr, int size); +extern JNIEXPORT jshortArray vtkJavaMakeJArrayOfShort(JNIEnv* env, const jshort* ptr, int size); +extern JNIEXPORT jintArray vtkJavaMakeJArrayOfInt(JNIEnv* env, const jint* ptr, int size); +extern JNIEXPORT jlongArray vtkJavaMakeJArrayOfLong(JNIEnv* env, const jlong* ptr, int size); // this is the void pointer parameter passed to the vtk callback routines on // behalf of the Java interface for callbacks. @@ -38,10 +35,10 @@ struct vtkJavaVoidFuncArg jmethodID mid; }; -extern VTKJAVA_EXPORT void vtkJavaVoidFunc(void*); -extern VTKJAVA_EXPORT void vtkJavaVoidFuncArgDelete(void*); +extern JNIEXPORT void vtkJavaVoidFunc(void*); +extern JNIEXPORT void vtkJavaVoidFuncArgDelete(void*); -class VTKJAVA_EXPORT vtkJavaCommand : public vtkCommand +class JNIEXPORT vtkJavaCommand : public vtkCommand { public: static vtkJavaCommand* New() { return new vtkJavaCommand; } @@ -50,7 +47,7 @@ public: void SetMethodID(jmethodID id) { this->mid = id; } void AssignJavaVM(JNIEnv* env) { env->GetJavaVM(&(this->vm)); } - void Execute(vtkObject*, unsigned long, void*); + void Execute(vtkObject*, unsigned long, void*) override; JavaVM* vm; jobject uobj; @@ -58,7 +55,7 @@ public: protected: vtkJavaCommand(); - ~vtkJavaCommand(); + ~vtkJavaCommand() override; }; #endif diff --git a/Wrapping/Java/CMakeLists.txt b/Wrapping/Java/CMakeLists.txt index ef69aee566e..62b39ce3326 100644 --- a/Wrapping/Java/CMakeLists.txt +++ b/Wrapping/Java/CMakeLists.txt @@ -1,8 +1,10 @@ -set(VTK_INSTALL_JAVA_DIR "${CMAKE_INSTALL_LIBDIR}/java" CACHE PATH "") -mark_as_advanced(VTK_INSTALL_JAVA_DIR) -set(CMAKE_INSTALL_JNILIBDIR "${VTK_INSTALL_JAVA_DIR}/vtk-${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}" - CACHE PATH "JNI libraries (LIBDIR/java/vtk-${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}") +set(CMAKE_INSTALL_JNILIBDIR "" + CACHE STRING "JNI libraries (LIBDIR/java/vtk-${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}") mark_as_advanced(CMAKE_INSTALL_JNILIBDIR) +if (NOT CMAKE_INSTALL_JNILIBDIR) + set(CMAKE_INSTALL_JNILIBDIR + "${CMAKE_INSTALL_LIBDIR}/java/vtk-${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}") +endif () if (IS_ABSOLUTE "${CMAKE_INSTALL_JNILIBDIR}") message(FATAL_ERROR "The `CMAKE_INSTALL_JNILIBDIR` must not be an absolute path.") @@ -286,7 +288,6 @@ if (NOT VTK_ABI_NAMESPACE_NAME STREQUAL "<DEFAULT>" AND NOT DEFINED ENV{CI}) message(WARNING "Wrappings::Java ABI does not not support the VTK_ABI_NAMESPACE_NAME " "and the symbols will not be mangled.") endif () -return () # Add the option to package VTK for custom Java packaging option(VTK_JAVA_INSTALL "Use the Java rules to build the native libraries." OFF) @@ -298,13 +299,12 @@ if (VTK_JAVA_INSTALL) set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION "bin") include(InstallRequiredSystemLibraries) endif () - if (APPLE) - set(CMAKE_INSTALL_NAME_DIR @loader_path CACHE STRING "" FORCE) - mark_as_advanced(CMAKE_INSTALL_NAME_DIR) + set(CMAKE_INSTALL_NAME_DIR @loader_path) endif () if (NOT MAVEN_LOCAL_NATIVE_NAME) - set(MAVEN_LOCAL_NATIVE_NAME "${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}" CACHE STRING "") + # We ignore CMAKE_SYSTEM_PROCESSOR since classifier field in maven only accept charaters strings (no numbers) + set(MAVEN_LOCAL_NATIVE_NAME "${CMAKE_SYSTEM_NAME}" CACHE STRING "") endif () if (NOT MAVEN_NATIVE_ARTIFACTS) set(MAVEN_NATIVE_ARTIFACTS "${MAVEN_LOCAL_NATIVE_NAME}" CACHE STRING "") @@ -315,17 +315,30 @@ if (VTK_JAVA_INSTALL) if (NOT MAVEN_VTK_GROUP_ID) set(MAVEN_VTK_GROUP_ID "org.vtk" CACHE STRING "") endif () + if (NOT MAVEN_VTK_ARTIFACT_SUFFIX) + set(MAVEN_VTK_ARTIFACT_SUFFIX "" CACHE STRING "") + endif () + if (NOT MAVEN_VTK_SNAPSHOT) + set(MAVEN_VTK_SNAPSHOT "" CACHE STRING "") + endif () + mark_as_advanced( VTK_JAVA_INSTALL MAVEN_LOCAL_REPOSITORY MAVEN_NATIVE_ARTIFACTS MAVEN_LOCAL_NATIVE_NAME + MAVEN_VTK_ARTIFACT_SUFFIX + MAVEN_VTK_SNAPSHOT MAVEN_VTK_GROUP_ID) set(MAVEN_DEPENDENCY_XML) endif () if (VTK_JAVA_JOGL_COMPONENT OR VTK_JAVA_SWT_COMPONENT) - set(MAVEN_REPO "$ENV{HOME}/.m2/repository") + if (WIN32) + set(MAVEN_REPO "$ENV{HOMEPATH}/.m2/repository") + else () + set(MAVEN_REPO "$ENV{HOME}/.m2/repository") + endif () find_file(JOGL_LIB jogl-all-${JOGL_VERSION}.jar PATHS ${MAVEN_REPO}/org/jogamp/jogl/jogl-all/${JOGL_VERSION} ) find_file(JOGL_GLUE gluegen-rt-${JOGL_VERSION}.jar PATHS ${MAVEN_REPO}/org/jogamp/gluegen/gluegen-rt/${JOGL_VERSION}) mark_as_advanced(JOGL_LIB JOGL_GLUE) @@ -386,16 +399,16 @@ endif() if(VTK_JAVA_INSTALL) set(MAVEN_NATIVE_ARTIFACT_XML) foreach(native_name ${MAVEN_NATIVE_ARTIFACTS}) - set(MAVEN_NATIVE_ARTIFACT_XML "${MAVEN_NATIVE_ARTIFACT_XML}\n <artifact><file>vtk-${VTK_MAJOR_VERSION}.${VTK_MINOR_VERSION}-java${VTK_JAVA_TARGET_VERSION}-natives-${native_name}.jar</file><classifier>java${VTK_JAVA_TARGET_VERSION}-natives-${native_name}</classifier><type>jar</type></artifact>") + string(APPEND MAVEN_NATIVE_ARTIFACT_XML "${MAVEN_NATIVE_ARTIFACT_XML}\n <artifact><file>vtk${MAVEN_VTK_ARTIFACT_SUFFIX}-${VTK_MAJOR_VERSION}.${VTK_MINOR_VERSION}-natives-${native_name}.jar</file><classifier>natives-${native_name}</classifier><type>jar</type></artifact>") endforeach() if(VTK_JAVA_JOGL_COMPONENT) - set(MAVEN_DEPENDENCY_XML "${MAVEN_DEPENDENCY_XML}\n <dependency><groupId>org.jogamp.jogl</groupId><artifactId>jogl-all-main</artifactId><version>${JOGL_VERSION}</version></dependency>\n <dependency><groupId>org.jogamp.gluegen</groupId><artifactId>gluegen-rt-main</artifactId><version>${JOGL_VERSION}</version></dependency>") + string(APPEND MAVEN_DEPENDENCY_XML "${MAVEN_DEPENDENCY_XML}\n <dependency><groupId>org.jogamp.jogl</groupId><artifactId>jogl-all-main</artifactId><version>${JOGL_VERSION}</version></dependency>\n <dependency><groupId>org.jogamp.gluegen</groupId><artifactId>gluegen-rt-main</artifactId><version>${JOGL_VERSION}</version></dependency>") endif() configure_file(JavaInstall.cmake.in - ${VTK_BINARY_DIR}/JavaInstall.cmake @ONLY) + ${CMAKE_CURRENT_BINARY_DIR}/JavaInstall.cmake @ONLY) configure_file(Maven/pom.xml.in - ${VTK_BINARY_DIR}/pom.xml @ONLY) + ${CMAKE_CURRENT_BINARY_DIR}/pom.xml @ONLY) configure_file(Maven/README.txt.in - ${VTK_BINARY_DIR}/MAVEN-README.txt @ONLY) - install(SCRIPT ${VTK_BINARY_DIR}/JavaInstall.cmake) + ${CMAKE_CURRENT_BINARY_DIR}/MAVEN-README.txt @ONLY) + install(SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/JavaInstall.cmake) endif() diff --git a/Wrapping/Java/JavaInstall.cmake.in b/Wrapping/Java/JavaInstall.cmake.in index 4c7666d2c0c..c7fc7e6a829 100644 --- a/Wrapping/Java/JavaInstall.cmake.in +++ b/Wrapping/Java/JavaInstall.cmake.in @@ -5,36 +5,50 @@ message("Package VTK for Java - ${NATIVE_NAME}") set(install_prefix_dir "${CMAKE_INSTALL_PREFIX}") -if ($ENV{DESTDIR}) - set(install_prefix_dir "$ENV{DESTDIR}/${cmake_install_prefix}") +if (DEFINED ENV{DESTDIR} AND UNIX) + string(PREPEND cmake_install_prefix "$ENV{DESTDIR}") endif() +# Only for windows but no harm to do it always +file (INSTALL "${install_prefix_dir}/bin/" + DESTINATION "${install_prefix_dir}/${NATIVE_NAME}" + FILES_MATCHING + PATTERN *.dll + PATTERN *.cmake + PATTERN *.txt + PATTERN *.in + PATTERN *Test* EXCLUDE + PATTERN *test* EXCLUDE +) + # Create the natives directory -file (COPY "${install_prefix_dir}/@VTK_INSTALL_JAVA_DIR@/" +file (INSTALL + "${install_prefix_dir}/@CMAKE_INSTALL_JNILIBDIR@/" DESTINATION "${install_prefix_dir}/${NATIVE_NAME}" FILES_MATCHING PATTERN *.dll PATTERN *.so PATTERN *.dylib - PATTERN *.jnilib PATTERN *.cmake PATTERN *.in PATTERN *.txt + PATTERN *Test* EXCLUDE + PATTERN *test* EXCLUDE ) # Rename vtk.jar with version number file(RENAME - "${install_prefix_dir}/@VTK_INSTALL_JAVA_DIR@/vtk.jar" + "${install_prefix_dir}/@CMAKE_INSTALL_JARDIR@/vtk.jar" "${install_prefix_dir}/vtk-@VTK_MAJOR_VERSION@.@VTK_MINOR_VERSION@.jar" ) # Create the jar file execute_process( - COMMAND "@JAVA_ARCHIVE@" -cf "${install_prefix_dir}/vtk-@VTK_MAJOR_VERSION@.@VTK_MINOR_VERSION@-java@VTK_JAVA_TARGET_VERSION@-${NATIVE_NAME}.jar" -C "${install_prefix_dir}/${NATIVE_NAME}" . + COMMAND "@JAVA_ARCHIVE@" -cf "${install_prefix_dir}/vtk@MAVEN_VTK_ARTIFACT_SUFFIX@-@VTK_MAJOR_VERSION@.@VTK_MINOR_VERSION@-${NATIVE_NAME}.jar" -C "${install_prefix_dir}/${NATIVE_NAME}" . ) # Copy maven files -file(COPY pom.xml MAVEN-README.txt DESTINATION "${install_prefix_dir}") +file(INSTALL pom.xml MAVEN-README.txt DESTINATION "${install_prefix_dir}") file(RENAME "${install_prefix_dir}/MAVEN-README.txt" "${install_prefix_dir}/README.txt" diff --git a/Wrapping/Java/Maven/README.txt.in b/Wrapping/Java/Maven/README.txt.in index c22e0267a6e..79c69a8aeaa 100644 --- a/Wrapping/Java/Maven/README.txt.in +++ b/Wrapping/Java/Maven/README.txt.in @@ -25,7 +25,7 @@ file. In order to generate a custom pom.xml the user can configure those properties within CMake otherwise decent automatically value will be set. - MAVEN_VTK_GROUP_ID:STRING=kitware.community + MAVEN_VTK_GROUP_ID:STRING=vtk.org MAVEN_LOCAL_NATIVE_NAME:STRING=Win32 diff --git a/Wrapping/Java/Maven/pom.xml.in b/Wrapping/Java/Maven/pom.xml.in index d8a2bb47212..d197003608e 100644 --- a/Wrapping/Java/Maven/pom.xml.in +++ b/Wrapping/Java/Maven/pom.xml.in @@ -1,126 +1,203 @@ -<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> - - <properties> - <vtk.snapshots.repo>file://@MAVEN_LOCAL_REPOSITORY@/snapshots</vtk.snapshots.repo> - <vtk.releases.repo>file://@MAVEN_LOCAL_REPOSITORY@/releases</vtk.releases.repo> - </properties> - - <groupId>@MAVEN_VTK_GROUP_ID@</groupId> - <artifactId>vtk</artifactId> - <version>@VTK_MAJOR_VERSION@.@VTK_MINOR_VERSION@-SNAPSHOT</version> - <packaging>pom</packaging> - - <name>Maven VTK Wrapper</name> - <description>Builds VTK and Mavenize it</description> - - <organization> - <name>Kitware Inc.</name> - <url>http://www.kitware.com</url> - </organization> - - <issueManagement> - <system>GitLab</system> - <url>https://gitlab.kitware.com/vtk/vtk/-/issues</url> - </issueManagement> - - <licenses> - <license> - <name>BSD-3-Clause license</name> - <url>http://en.wikipedia.org/wiki/BSD_licenses</url> - <comments> - VTK is an open-source toolkit licensed under the BSD license. - - Copyright (c) 1993-2008 Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - Neither name of Ken Martin, Will Schroeder, or Bill Lorensen nor the names of any contributors may be used to endorse or promote products derived from this software without specific prior written permission. - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - </comments> - <distribution>repo</distribution> - </license> - </licenses> - - <dependencies>@MAVEN_DEPENDENCY_XML@ +<?xml version="1.0"?> +<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> + <properties> + <vtk.snapshots.repo.id>vtk-snapshots-repo</vtk.snapshots.repo.id> + <vtk.snapshots.repo>file://@MAVEN_LOCAL_REPOSITORY@/snapshots</vtk.snapshots.repo> + <vtk.releases.repo>file://@MAVEN_LOCAL_REPOSITORY@/releases</vtk.releases.repo> + </properties> + <groupId>@MAVEN_VTK_GROUP_ID@</groupId> + <artifactId>vtk@MAVEN_VTK_ARTIFACT_SUFFIX@</artifactId> + <version>@VTK_MAJOR_VERSION@.@VTK_MINOR_VERSION@@MAVEN_VTK_SNAPSHOT@</version> + <packaging>pom</packaging> + <name>VTK</name> + <description>VTK java package</description> + <url>https://gitlab.kitware.com/vtk/vtk</url> + <organization> + <name>Kitware Inc.</name> + <url>https://www.kitware.com</url> + </organization> + <developers> + <developer> + <name>Vicente Bolea</name> + <email>vicente.bolea@kitware.com</email> + <organization>Kitware</organization> + <organizationUrl>https://www.kitware.com</organizationUrl> + </developer> + </developers> + <scm> + <connection>scm:git:git@gitlab.kitware.com:vtk/vtk.git</connection> + <developerConnection>scm:git:git@gitlab.kitware.com:vtk/vtk.git</developerConnection> + <url>https://gitlab.kitware.com/vtk/vtk</url> + </scm> + <issueManagement> + <system>GitLab</system> + <url>https://gitlab.kitware.com/vtk/vtk/-/issues</url> + </issueManagement> + <licenses> + <license> + <name>BSD-3-Clause license</name> + <url>http://en.wikipedia.org/wiki/BSD_licenses</url> + <comments> + VTK is an open-source toolkit licensed under the BSD license. + + Copyright (c) 1993-2008 Ken Martin, Will Schroeder, Bill Lorensen + All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + Neither name of Ken Martin, Will Schroeder, or Bill Lorensen nor the names of any contributors may be used to endorse or promote products derived from this software without specific prior written permission. + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + </comments> + <distribution>repo</distribution> + </license> + </licenses> + <dependencies>@MAVEN_DEPENDENCY_XML@ </dependencies> - - <distributionManagement> - <!-- Warning: Generating release artifacts is only meant to be used after - a compilation of VTK across all the targeted platforms while overriding - the following CMake properties: - - # Customize the Group ID - -DMAVEN_VTK_GROUP_ID:STRING=kitware.community - - # This will be generated by CMake automatically but can be override - -DMAVEN_LOCAL_NATIVE_NAME:STRING=Win32 - - # List of all the MAVEN_LOCAL_NATIVE_NAME on each computer - -DMAVEN_NATIVE_ARTIFACTS:STRING=Win32;Win64;Linux32;Linux64;OSX - - # Path where the local repo should be stored at least at the end - # when Maven will be called - -DMAVEN_LOCAL_REPOSITORY:STRING=${user.home}/vtk-maven-repos - - Each platform will generate an OS specific install directory but - the generated pom.xml will remain the same on each computer which - will ease the merge of those directory for a one step maven deploy. - --> - <repository> - <id>vtk-releases-repo</id> - <name>VTK Release Artifact Repository</name> - <url>${vtk.releases.repo}</url> - </repository> - <snapshotRepository> - <id>vtk-snapshots-repo</id> - <name>VTK Snapshot Artifact Repository</name> - <url>${vtk.snapshots.repo}</url> - </snapshotRepository> - </distributionManagement> - - <pluginRepositories> - <pluginRepository> - <id>sonatype-public-repository</id> - <url>https://oss.sonatype.org/content/groups/public</url> - <snapshots> - <enabled>true</enabled> - </snapshots> - <releases> - <enabled>true</enabled> - </releases> - </pluginRepository> - </pluginRepositories> - - <build> - <plugins> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>build-helper-maven-plugin</artifactId> - <version>1.8</version> - <executions> - <execution> - <id>attach-vtk-artifacts</id> - <phase>package</phase> - <goals> - <goal>attach-artifact</goal> - </goals> - <configuration> - <artifacts> - <artifact> - <file>vtk-@VTK_MAJOR_VERSION@.@VTK_MINOR_VERSION@.jar</file> - <type>jar</type> - </artifact>@MAVEN_NATIVE_ARTIFACT_XML@ - </artifacts> - </configuration> - </execution> - </executions> - </plugin> - </plugins> - </build> - + <distributionManagement> + <!-- Warning: Generating release artifacts is only meant to be used after + a compilation of VTK across all the targeted platforms while overriding + the following CMake properties: + + # Customize the Group ID + -DMAVEN_VTK_GROUP_ID:STRING=org.vtk + + # This will be generated by CMake automatically but can be override + -DMAVEN_LOCAL_NATIVE_NAME:STRING=Win32 + + # List of all the MAVEN_LOCAL_NATIVE_NAME on each computer + -DMAVEN_NATIVE_ARTIFACTS:STRING=Win32;Win64;Linux32;Linux64;OSX + + # Path where the local repo should be stored at least at the end + # when Maven will be called + -DMAVEN_LOCAL_REPOSITORY:STRING=${user.home}/vtk-maven-repos + + Each platform will generate an OS specific install directory but + the generated pom.xml will remain the same on each computer which + will ease the merge of those directory for a one step maven deploy. + --> + <repository> + <id>vtk-releases-repo</id> + <name>VTK Release Artifact Repository</name> + <url>${vtk.releases.repo}</url> + </repository> + <snapshotRepository> + <id>${vtk.snapshots.repo.id}</id> + <name>VTK Snapshot Artifact Repository</name> + <url>${vtk.snapshots.repo}</url> + </snapshotRepository> + </distributionManagement> + <pluginRepositories> + <pluginRepository> + <id>sonatype-public-repository</id> + <url>https://oss.sonatype.org/content/groups/public</url> + <snapshots> + <enabled>false</enabled> + </snapshots> + <releases> + <enabled>true</enabled> + </releases> + </pluginRepository> + </pluginRepositories> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-enforcer-plugin</artifactId> + <version>3.4.1</version> + <executions> + <execution> + <id>enforce-maven</id> + <goals> + <goal>enforce</goal> + </goals> + <configuration> + <rules> + <requireMavenVersion> + <version>3.2.5</version> + </requireMavenVersion> + </rules> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <version>3.4.0</version> + <executions> + <execution> + <id>attach-vtk-artifacts</id> + <phase>package</phase> + <goals> + <goal>attach-artifact</goal> + </goals> + <configuration> + <artifacts> + <artifact> + <file>vtk-@VTK_MAJOR_VERSION@.@VTK_MINOR_VERSION@.jar</file> + <type>jar</type> + </artifact> + @MAVEN_NATIVE_ARTIFACT_XML@ + </artifacts> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-source-plugin</artifactId> + <version>3.3.1</version> + <executions> + <execution> + <id>attach-sources</id> + <goals> + <goal>jar-no-fork</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-javadoc-plugin</artifactId> + <version>3.6.3</version> + <executions> + <execution> + <id>attach-javadocs</id> + <goals> + <goal>jar</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-gpg-plugin</artifactId> + <version>3.2.4</version> + <executions> + <execution> + <id>sign-artifacts</id> + <phase>verify</phase> + <goals> + <goal>sign</goal> + </goals> + </execution> + </executions> + </plugin> +<!-- + <plugin> + <groupId>org.sonatype.central</groupId> + <artifactId>central-publishing-maven-plugin</artifactId> + <version>0.4.0</version> + <extensions>true</extensions> + <configuration> + <publishingServerId>central</publishingServerId> + <tokenAuth>true</tokenAuth> + </configuration> + </plugin> +--> + </plugins> + </build> </project> diff --git a/Wrapping/Java/vtk/vtkSettings.java.in b/Wrapping/Java/vtk/vtkSettings.java.in index 3d06c09d3d1..fe86203fea9 100644 --- a/Wrapping/Java/vtk/vtkSettings.java.in +++ b/Wrapping/Java/vtk/vtkSettings.java.in @@ -6,7 +6,7 @@ import java.util.StringTokenizer; public class vtkSettings { private static String GetVTKBuildLibDir() { return "@CMAKE_LIBRARY_OUTPUT_DIRECTORY@"; } - private static String GetVTKInstallLibDir() { return "@CMAKE_INSTALL_PREFIX@/@VTK_INSTALL_LIB_DIR@"; } + private static String GetVTKInstallLibDir() { return "@CMAKE_INSTALL_PREFIX@/@VTK_INSTALL_LIBDIR@"; } private static String[] Split(String str, String sep) { diff --git a/Wrapping/Tools/vtkWrapJava.c b/Wrapping/Tools/vtkWrapJava.c index e69f506c0c6..3a0d4b51fd4 100644 --- a/Wrapping/Tools/vtkWrapJava.c +++ b/Wrapping/Tools/vtkWrapJava.c @@ -1402,6 +1402,7 @@ int VTK_PARSE_MAIN(int argc, char* argv[]) /* Block inclusion of full streams. */ fprintf(fp, "#define VTK_STREAMS_FWD_ONLY\n"); } + fprintf(fp, "#include \"vtkABI.h\"\n"); fprintf(fp, "#include \"vtkSystemIncludes.h\"\n"); fprintf(fp, "#include \"%s.h\"\n", data->Name); fprintf(fp, "#include \"vtkJavaUtil.h\"\n\n"); @@ -1410,6 +1411,11 @@ int VTK_PARSE_MAIN(int argc, char* argv[]) for (i = 0; i < data->NumberOfSuperClasses; i++) { + if (!isClassWrapped(data->SuperClasses[i])) + { + continue; + } + char* safe_name = vtkWrap_SafeSuperclassName(data->SuperClasses[i]); const char* safe_superclass = safe_name ? safe_name : data->SuperClasses[i]; @@ -1434,6 +1440,10 @@ int VTK_PARSE_MAIN(int argc, char* argv[]) /* check our superclasses */ for (i = 0; i < data->NumberOfSuperClasses; i++) { + if (!isClassWrapped(data->SuperClasses[i])) + { + continue; + } char* safe_name = vtkWrap_SafeSuperclassName(data->SuperClasses[i]); const char* safe_superclass = safe_name ? safe_name : data->SuperClasses[i]; -- GitLab