Skip to content

Commit 1fb7c5f

Browse files
committed
extra handles for debian maven repo integration.
1 parent cbd02f4 commit 1fb7c5f

File tree

3 files changed

+37
-7
lines changed

3 files changed

+37
-7
lines changed

cmake/rosjava.cmake.em

+21-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# Utilities
33
##############################################################################
44

5+
set(CATKIN_GLOBAL_MAVEN_DESTINATION ${CATKIN_GLOBAL_SHARE_DESTINATION}/maven CACHE PATH "path to which maven artifacts are deployed in your workspace")
6+
57
# Scans down directories till it finds the gradle wrapper.
68
# It sets the following variables
79
# - ${PROJECT_NAME}_gradle_BINARY
@@ -35,22 +37,35 @@ macro(find_gradle_repo_root)
3537
get_filename_component(${PROJECT_NAME}_gradle_ROOT ${${PROJECT_NAME}_gradle_SETTINGS} PATH)
3638
endmacro()
3739

40+
# Sets environment variables that are used by gradle to customise a build.
41+
# This is better than modifying a gradle script - gradle should be able
42+
# to be called alone without cmake intervention.
43+
macro(_rosjava_env)
44+
set(ROSJAVA_ENV $ENV{ROS_MAVEN_DEPLOYMENT_PATH})
45+
if(NOT ROSJAVA_ENV)
46+
set(ROSJAVA_ENV "ROS_MAVEN_DEPLOYMENT_PATH=${CATKIN_DEVEL_PREFIX}/${CATKIN_GLOBAL_MAVEN_DESTINATION}")
47+
endif()
48+
endmacro()
49+
3850
##############################################################################
3951
# RosJava Package
4052
##############################################################################
4153
# Calls the gradle wrapper to compile just the package
4254
# that it is called in with install and installApp targets.
4355
macro(catkin_rosjava_setup)
56+
_rosjava_env()
4457
find_gradle()
4558
if( ${ARGC} EQUAL 0 )
46-
set(gradle_tasks "install;installApp")
59+
# Note : COMMAND is a list of variables, so these need to be a list, not a single string
60+
set(gradle_tasks "install;installApp;uploadArchives")
4761
else()
48-
string(REPLACE ";" " " gradle_tasks "${ARGV}")
62+
set(gradle_tasks ${ARGV})
4963
endif()
5064
add_custom_target(gradle-${PROJECT_NAME}
5165
ALL
52-
COMMAND ${CATKIN_ENV} ${${PROJECT_NAME}_gradle_BINARY} ${gradle_tasks}
66+
COMMAND ${ROSJAVA_ENV} ${CATKIN_ENV} ${${PROJECT_NAME}_gradle_BINARY} ${gradle_tasks}
5367
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
68+
VERBATIM
5469
)
5570
catkin_package_xml()
5671
foreach(depends in ${${PROJECT_NAME}_BUILD_DEPENDS})
@@ -76,6 +91,7 @@ endmacro()
7691
# It checks the build type and determines whether it should run
7792
# assembleDebug or assembleRelease
7893
macro(catkin_android_setup)
94+
_rosjava_env()
7995
find_gradle()
8096
if( ${ARGC} EQUAL 0 )
8197
if(CMAKE_BUILD_TYPE STREQUAL "Release")
@@ -88,8 +104,9 @@ macro(catkin_android_setup)
88104
endif()
89105
add_custom_target(gradle-${PROJECT_NAME}
90106
ALL
91-
COMMAND ${CATKIN_ENV} ${${PROJECT_NAME}_gradle_BINARY} ${gradle_tasks}
107+
COMMAND ${ROSJAVA_ENV} ${CATKIN_ENV} ${${PROJECT_NAME}_gradle_BINARY} ${gradle_tasks}
92108
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
109+
VERBATIM
93110
)
94111
catkin_package_xml()
95112
foreach(depends in ${${PROJECT_NAME}_BUILD_DEPENDS})

env-hooks/15.rosjava.bash.em

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
@[if DEVELSPACE]@
44
export ROS_MAVEN_PATH=`python @(CMAKE_CURRENT_SOURCE_DIR)/generate_ros_maven_path.py`
5+
export ROS_MAVEN_DEPLOYMENT_PATH=`python @(CMAKE_CURRENT_SOURCE_DIR)/generate_ros_maven_path.py --deployment-repository`
56
@[else]@
67
export ROS_MAVEN_PATH=`python @(CMAKE_INSTALL_PREFIX)/share/rosjava_tools/generate_ros_maven_path.py`
78
@[end if]@

generate_ros_maven_path.py

+15-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
#!/usr/bin/env python
22

33
import os
4+
import argparse
45

56
CATKIN_MARKER_FILE = '.catkin'
67

8+
def parse_arguments():
9+
parser = argparse.ArgumentParser(description='Generate environment variables for the rosjava maven environment.')
10+
parser.add_argument('-d', '--deployment-repository', action='store_true', help='Return the current devel workspace maven directory.')
11+
args = parser.parse_args()
12+
return args
13+
714
def get_workspaces(environ):
815
'''
916
Based on CMAKE_PREFIX_PATH return all catkin workspaces.
@@ -13,10 +20,15 @@ def get_workspaces(environ):
1320
value = environ[env_name] if env_name in environ else ''
1421
paths = [path for path in value.split(os.pathsep) if path]
1522
# remove non-workspace paths
16-
workspaces = [path for path in paths if os.path.isfile(os.path.join(path, CATKIN_MARKER_FILE)) or (include_fuerte and path.startswith('/opt/ros/fuerte'))]
23+
workspaces = [path for path in paths if os.path.isfile(os.path.join(path, CATKIN_MARKER_FILE))]
1724
return workspaces
1825

1926
if __name__ == '__main__':
27+
args = parse_arguments()
2028
workspaces = get_workspaces(dict(os.environ))
21-
maven_repository_paths = [os.path.join(path, 'maven') for path in workspaces]
22-
print os.pathsep.join(maven_repository_paths)
29+
if args.deployment_repository:
30+
# assuming one value exists here
31+
print os.path.join(workspaces[0], 'share', 'maven')
32+
else:
33+
maven_repository_paths = [os.path.join(path, 'share', 'maven') for path in workspaces]
34+
print os.pathsep.join(maven_repository_paths)

0 commit comments

Comments
 (0)