@@ -44,6 +44,7 @@ endmacro()
4444# Note that we check for the variable existence as well so we don't
4545# override a user setting.
4646macro (_rosjava_env)
47+ set (ROS_GRADLE_VERBOSE $ENV{ROS_GRADLE_VERBOSE})
4748 set (ROS_MAVEN_DEPLOYMENT_REPOSITORY $ENV{ROS_MAVEN_DEPLOYMENT_REPOSITORY})
4849 set (ROS_MAVEN_REPOSITORY $ENV{ROS_MAVEN_REPOSITORY})
4950 if (NOT ROS_MAVEN_DEPLOYMENT_REPOSITORY)
@@ -75,13 +76,37 @@ macro(catkin_rosjava_setup)
7576 else ()
7677 set (gradle_tasks ${ARGV})
7778 endif ()
79+ if (ROS_GRADLE_VERBOSE)
80+ set (gradle_options " " )
81+ else ()
82+ set (gradle_options " -q" )
83+ endif ()
84+ # ##################################
85+ # Execution
86+ # ##################################
87+ # This is an interesting option, it uses cmake to check for changes in files and
88+ # avoids gradle's own slow check. It could get annoying though.
89+ file (GLOB_RECURSE BUILD_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} FOLLOW_SYMLINKS * .java * .gradle * .properties CMakeLists .txt * .cmake * .xml )
90+ # Can't actually key off the subproject build dirs since we don't know them from here so we
91+ # use touch a file to link the command to the target. Actual triggers come from the file dependency changes.
92+ add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ built
93+ DEPENDS ${BUILD_FILES}
94+ # COMMAND ${ROSJAVA_ENV} ${CATKIN_ENV} "env" "|" "grep" "ROS"
95+ COMMAND ${ROSJAVA_ENV} ${CATKIN_ENV} ${${PROJECT_NAME}_gradle_BINARY} ${gradle_options} ${gradle_tasks}
96+ COMMAND touch ${CMAKE_CURRENT_BINARY_DIR}/ built
97+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
98+ COMMENT " Running gradle tasks for ${PROJECT_NAME}"
99+ )
100+
78101 add_custom_target (gradle- ${PROJECT_NAME}
79102 ALL
80- COMMAND ${ROSJAVA_ENV} ${CATKIN_ENV} " env" " |" " grep" " ROS"
81- COMMAND ${ROSJAVA_ENV} ${CATKIN_ENV} ${${PROJECT_NAME}_gradle_BINARY} ${gradle_tasks}
103+ DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/ built
82104 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
83105 VERBATIM
84106 )
107+ # ##################################
108+ # Target Management
109+ # ##################################
85110 catkin_package_xml ()
86111 foreach (depends in ${${PROJECT_NAME}_BUILD_DEPENDS})
87112 if (TARGET gradle- ${depends})
@@ -95,6 +120,7 @@ macro(catkin_rosjava_setup)
95120 add_custom_target (gradle- clean- ${PROJECT_NAME}
96121 COMMAND ${CATKIN_ENV} ${${PROJECT_NAME}_gradle_BINARY} clean
97122 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
123+ COMMENT " Cleaning gradle project for ${PROJECT_NAME}"
98124 )
99125 add_dependencies (gradle- clean gradle- clean- ${PROJECT_NAME})
100126endmacro ()
0 commit comments