@@ -44,6 +44,7 @@ endmacro()
44
44
# Note that we check for the variable existence as well so we don't
45
45
# override a user setting.
46
46
macro (_rosjava_env)
47
+ set (ROS_GRADLE_VERBOSE $ENV{ROS_GRADLE_VERBOSE})
47
48
set (ROS_MAVEN_DEPLOYMENT_REPOSITORY $ENV{ROS_MAVEN_DEPLOYMENT_REPOSITORY})
48
49
set (ROS_MAVEN_REPOSITORY $ENV{ROS_MAVEN_REPOSITORY})
49
50
if (NOT ROS_MAVEN_DEPLOYMENT_REPOSITORY)
@@ -75,13 +76,37 @@ macro(catkin_rosjava_setup)
75
76
else ()
76
77
set (gradle_tasks ${ARGV})
77
78
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
+
78
101
add_custom_target (gradle- ${PROJECT_NAME}
79
102
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
82
104
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
83
105
VERBATIM
84
106
)
107
+ # ##################################
108
+ # Target Management
109
+ # ##################################
85
110
catkin_package_xml ()
86
111
foreach (depends in ${${PROJECT_NAME}_BUILD_DEPENDS})
87
112
if (TARGET gradle- ${depends})
@@ -95,6 +120,7 @@ macro(catkin_rosjava_setup)
95
120
add_custom_target (gradle- clean- ${PROJECT_NAME}
96
121
COMMAND ${CATKIN_ENV} ${${PROJECT_NAME}_gradle_BINARY} clean
97
122
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
123
+ COMMENT " Cleaning gradle project for ${PROJECT_NAME}"
98
124
)
99
125
add_dependencies (gradle- clean gradle- clean- ${PROJECT_NAME})
100
126
endmacro ()
0 commit comments