summaryrefslogtreecommitdiffstats
path: root/Modules/UseJava
diff options
context:
space:
mode:
authorAlexey Karndshev <alexey@quobyte.com>2020-02-21 10:46:40 (GMT)
committerAlexey Karandashev <reflectored@gmail.com>2020-04-06 14:58:10 (GMT)
commit4559eb490a5e2099808db33c35ef19eab19d2d94 (patch)
tree7a0471e2212e1b09dc55abfb69dd3fb8aed5fcf2 /Modules/UseJava
parent25ca8e5ce5019c0fb8648f7408b864add6b19d83 (diff)
downloadCMake-4559eb490a5e2099808db33c35ef19eab19d2d94.zip
CMake-4559eb490a5e2099808db33c35ef19eab19d2d94.tar.gz
CMake-4559eb490a5e2099808db33c35ef19eab19d2d94.tar.bz2
UseJava: clean class files from previous builds
If java_class_filelist exists, remove previous class files before building the new ones. If java_sources content has changed, clean and rebuild the class files of the target. Fixes: #20377
Diffstat (limited to 'Modules/UseJava')
-rw-r--r--Modules/UseJava/ClearClassFiles.cmake17
1 files changed, 17 insertions, 0 deletions
diff --git a/Modules/UseJava/ClearClassFiles.cmake b/Modules/UseJava/ClearClassFiles.cmake
new file mode 100644
index 0000000..f3115c6
--- /dev/null
+++ b/Modules/UseJava/ClearClassFiles.cmake
@@ -0,0 +1,17 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+# This script deletes compiled Java class files.
+
+if(CMAKE_JAVA_CLASS_OUTPUT_PATH)
+ if(EXISTS "${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist")
+ file(STRINGS "${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist" classes)
+ list(TRANSFORM classes PREPEND "${CMAKE_JAVA_CLASS_OUTPUT_PATH}/")
+ if(classes)
+ file(REMOVE ${classes})
+ message(STATUS "Clean class files from previous build")
+ endif()
+ endif()
+else()
+ message(FATAL_ERROR "Can't find CMAKE_JAVA_CLASS_OUTPUT_PATH")
+endif()