mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-19 02:17:27 +08:00
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
This commit is contained in:

committed by
Alexey Karandashev

parent
25ca8e5ce5
commit
4559eb490a
17
Modules/UseJava/ClearClassFiles.cmake
Normal file
17
Modules/UseJava/ClearClassFiles.cmake
Normal file
@@ -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()
|
Reference in New Issue
Block a user