summaryrefslogtreecommitdiff
path: root/Modules
diff options
context:
space:
mode:
authorMatthew Woehlke <matthew.woehlke@kitware.com>2016-06-08 13:48:30 -0400
committerBrad King <brad.king@kitware.com>2016-06-09 09:12:15 -0400
commit0bd91ad4058c006bb67b48801e1877e8a893ef4d (patch)
treef7a9286c6ca43a3f37e59c3cc1669d3b24b65e03 /Modules
parent89df91b938f22e14f647244093b08d49ddb41385 (diff)
downloadcmake-0bd91ad4058c006bb67b48801e1877e8a893ef4d.tar.gz
UseJava: Fix race condition creating java class list
Modify logic to unconditionally create an empty class list response file to instead only create the empty file if no classes are being compiled. Otherwise, the response file is created via a custom command that generates the correct list. This fixes a race condition on certain systems (e.g. HFS on OS X) where the dependency for creating the "correct" list can have the "same" (due to limited precision of the filesystem) timestamp as the empty file created at configure time, resulting in an empty class list being incorrectly used to invoke `jar` (resulting in `jar` being unhappy that it was not given any input files). Although one would have some hope that this doesn't affect "real" projects, it definitely does affect the JavaExportImport unit test, causing the same to fail randomly when run on an HFS partition.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/UseJava.cmake10
1 files changed, 5 insertions, 5 deletions
diff --git a/Modules/UseJava.cmake b/Modules/UseJava.cmake
index 6644bd4ccb..cf9c2d723a 100644
--- a/Modules/UseJava.cmake
+++ b/Modules/UseJava.cmake
@@ -609,11 +609,6 @@ function(add_jar _TARGET_NAME)
endif ()
endforeach()
- # create an empty java_class_filelist
- if (NOT EXISTS ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist)
- file(WRITE ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist "")
- endif()
-
if (_JAVA_COMPILE_FILES OR _JAVA_COMPILE_FILELISTS)
set (_JAVA_SOURCES_FILELISTS)
@@ -653,6 +648,11 @@ function(add_jar _TARGET_NAME)
DEPENDS ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_compiled_${_TARGET_NAME}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
+ else ()
+ # create an empty java_class_filelist
+ if (NOT EXISTS ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist)
+ file(WRITE ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist "")
+ endif()
endif ()
# create the jar file