@@ -26,17 +26,46 @@ def get_workspaces(environ):
26
26
workspaces = [path for path in paths if os .path .isfile (os .path .join (path , CATKIN_MARKER_FILE ))]
27
27
return workspaces
28
28
29
+ def get_environment_variable (environ , key ):
30
+ var = None
31
+ try :
32
+ var = environ [key ]
33
+ except KeyError :
34
+ pass
35
+ if var == '' :
36
+ var = None
37
+ return var
38
+
29
39
if __name__ == '__main__' :
30
40
args = parse_arguments ()
31
- workspaces = get_workspaces (dict (os .environ ))
41
+ environment_variables = dict (os .environ )
42
+ workspaces = get_workspaces (environment_variables )
32
43
if args .maven_deployment_repository :
33
- # assuming one value exists here
34
- print os .path .join (workspaces [0 ], 'share' , 'maven' )
44
+ repo = get_environment_variable (environment_variables , 'ROS_MAVEN_DEPLOYMENT_REPOSITORY' )
45
+ if repo is None :
46
+ repo = os .path .join (workspaces [0 ], 'share' , 'maven' )
47
+ else :
48
+ if repo in [os .path .join (w , 'share' , 'maven' ) for w in workspaces ]:
49
+ repo = os .path .join (workspaces [0 ], 'share' , 'maven' )
50
+ print repo
35
51
elif args .maven_path :
36
- maven_repository_paths = [os .path .join (path , 'share' , 'maven' ) for path in workspaces ]
37
- print os .pathsep .join (maven_repository_paths )
52
+ new_maven_paths = [os .path .join (path , 'share' , 'maven' ) for path in workspaces ]
53
+ maven_paths = get_environment_variable (environment_variables , 'ROS_MAVEN_PATH' )
54
+ if maven_paths is None :
55
+ maven_paths = new_maven_paths
56
+ else :
57
+ maven_paths = maven_paths .split (os .pathsep )
58
+ common_paths = [p for p in maven_paths if p in new_maven_paths ]
59
+ if common_paths :
60
+ maven_paths = new_maven_paths
61
+ print os .pathsep .join (maven_paths )
38
62
elif args .gradle_user_home :
39
- # assuming one value exists here
40
- print os .path .join (workspaces [0 ], 'share' , 'gradle' )
63
+ home = get_environment_variable (environment_variables , 'GRADLE_USER_HOME' )
64
+ if home is None :
65
+ home = os .path .join (workspaces [0 ], 'share' , 'gradle' )
66
+ else :
67
+ if home in [os .path .join (w , 'share' , 'gradle' ) for w in workspaces ]:
68
+ home = os .path .join (workspaces [0 ], 'share' , 'gradle' )
69
+ print home
41
70
else :
42
71
print "Nothing to see here - please provide one of the valid command switches."
0 commit comments