Skip to content
Snippets Groups Projects
Commit 07ce3754 authored by Leroy Rügemer's avatar Leroy Rügemer
Browse files

add maven settings.xml generation to environment

parent 6e66e0b5
Branches
No related tags found
No related merge requests found
...@@ -9,3 +9,5 @@ SCRIPT=@(CMAKE_INSTALL_PREFIX)/share/rosjava_build_tools/generate_environment_va ...@@ -9,3 +9,5 @@ SCRIPT=@(CMAKE_INSTALL_PREFIX)/share/rosjava_build_tools/generate_environment_va
export ROS_MAVEN_PATH="`python ${SCRIPT} --maven-path`" export ROS_MAVEN_PATH="`python ${SCRIPT} --maven-path`"
export ROS_MAVEN_DEPLOYMENT_REPOSITORY="`python ${SCRIPT} --maven-deployment-repository`" export ROS_MAVEN_DEPLOYMENT_REPOSITORY="`python ${SCRIPT} --maven-deployment-repository`"
export ROS_MAVEN_REPOSITORY="`python ${SCRIPT} --maven-repository`" export ROS_MAVEN_REPOSITORY="`python ${SCRIPT} --maven-repository`"
export ROS_LOCAL_MAVEN_REPOSITORY="`python ${SCRIPT} --local-maven-repository`"
export ROS_MAVEN_SETTING_XML_CONTENT="`python ${SCRIPT} --create-maven-settings`"
...@@ -9,3 +9,5 @@ SCRIPT=@(CMAKE_INSTALL_PREFIX)/share/rosjava_build_tools/generate_environment_va ...@@ -9,3 +9,5 @@ SCRIPT=@(CMAKE_INSTALL_PREFIX)/share/rosjava_build_tools/generate_environment_va
export ROS_MAVEN_PATH="`python ${SCRIPT} --maven-path`" export ROS_MAVEN_PATH="`python ${SCRIPT} --maven-path`"
export ROS_MAVEN_DEPLOYMENT_REPOSITORY="`python ${SCRIPT} --maven-deployment-repository`" export ROS_MAVEN_DEPLOYMENT_REPOSITORY="`python ${SCRIPT} --maven-deployment-repository`"
export ROS_MAVEN_REPOSITORY="`python ${SCRIPT} --maven-repository`" export ROS_MAVEN_REPOSITORY="`python ${SCRIPT} --maven-repository`"
export ROS_LOCAL_MAVEN_REPOSITORY="`python ${SCRIPT} --local-maven-repository`"
export ROS_MAVEN_SETTING_XML_CONTENT="`python ${SCRIPT} --create-maven-settings`"
\ No newline at end of file
...@@ -12,9 +12,65 @@ def parse_arguments(): ...@@ -12,9 +12,65 @@ def parse_arguments():
cmd_group.add_argument('-r', '--maven-repository', action='store_true', help='The url to the external ros maven repository.') cmd_group.add_argument('-r', '--maven-repository', action='store_true', help='The url to the external ros maven repository.')
cmd_group.add_argument('-m', '--maven-path', action='store_true', help='Generate maven path across all chained workspcaes.') cmd_group.add_argument('-m', '--maven-path', action='store_true', help='Generate maven path across all chained workspcaes.')
cmd_group.add_argument('-g', '--gradle-user-home', action='store_true', help='Generate the local gradle user home in the current devel workspace (share/gradle).') cmd_group.add_argument('-g', '--gradle-user-home', action='store_true', help='Generate the local gradle user home in the current devel workspace (share/gradle).')
cmd_group.add_argument('-l', '--local-maven-repository', action='store_true', help='Generate the local maven cache in the current devel workspace (share/maven).')
cmd_group.add_argument("-s", '--create-maven-settings', action='store_true', help='Generate maven settings.xml for the current devel workspace.')
args = parser.parse_args() args = parser.parse_args()
return args return args
MAVEN_HEADER="""
<settings xmlns='http://maven.apache.org/SETTINGS/1.0.0/'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xsi:schemaLocation='http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd'>
<profiles>
<profile>
<id>catkin</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
"""
MAVEN_FOOTER="""
</repositories>
</profile>
</profiles>
</settings>
"""
def get_repository_xml(id, path):
if path.startswith("/"):
path = "file://" + path
return """
<repository>
<id>{id}</id>
<name>{id}</name>
<url>{url}</url>
<layout>default</layout>
<releases>
<updatePolicy>always</updatePolicy>
<enabled>true</enabled>
</releases>
<snapshots>
<updatePolicy>always</updatePolicy>
<enabled>true</enabled>
</snapshots>
</repository>
""".format(
url=path,
id=id,
)
def get_repositories_xml():
maven_paths = generate_maven_path()
settings = ""
for id, repo, in enumerate(maven_paths.split(":")):
settings += get_repository_xml(id,repo)
return settings
def get_workspaces(environ): def get_workspaces(environ):
''' '''
Based on CMAKE_PREFIX_PATH return all catkin workspaces. Based on CMAKE_PREFIX_PATH return all catkin workspaces.
...@@ -37,6 +93,19 @@ def get_environment_variable(environ, key): ...@@ -37,6 +93,19 @@ def get_environment_variable(environ, key):
var = None var = None
return var return var
def generate_maven_path():
new_maven_paths = [os.path.join(path, 'share', 'repository') for path in workspaces] #TODO: make configurable!
maven_paths = get_environment_variable(environment_variables, 'ROS_MAVEN_PATH')
if maven_paths is None:
maven_paths = new_maven_paths
else:
maven_paths = maven_paths.split(os.pathsep)
common_paths = [p for p in maven_paths if p in new_maven_paths]
if common_paths:
maven_paths = new_maven_paths
return os.pathsep.join(maven_paths)
if __name__ == '__main__': if __name__ == '__main__':
args = parse_arguments() args = parse_arguments()
environment_variables = dict(os.environ) environment_variables = dict(os.environ)
...@@ -55,16 +124,7 @@ if __name__ == '__main__': ...@@ -55,16 +124,7 @@ if __name__ == '__main__':
repo = 'https://mvn.cit-ec.de/nexus/content/repositories/releases/' repo = 'https://mvn.cit-ec.de/nexus/content/repositories/releases/'
print(repo) print(repo)
elif args.maven_path: elif args.maven_path:
new_maven_paths = [os.path.join(path, 'share', 'repository') for path in workspaces] #TODO: make configurable! print(generate_maven_path())
maven_paths = get_environment_variable(environment_variables, 'ROS_MAVEN_PATH')
if maven_paths is None:
maven_paths = new_maven_paths
else:
maven_paths = maven_paths.split(os.pathsep)
common_paths = [p for p in maven_paths if p in new_maven_paths]
if common_paths:
maven_paths = new_maven_paths
print(os.pathsep.join(maven_paths))
elif args.gradle_user_home: elif args.gradle_user_home:
home = get_environment_variable(environment_variables, 'GRADLE_USER_HOME') home = get_environment_variable(environment_variables, 'GRADLE_USER_HOME')
if home is None: if home is None:
...@@ -73,5 +133,15 @@ if __name__ == '__main__': ...@@ -73,5 +133,15 @@ if __name__ == '__main__':
if home in [os.path.join(w, 'share', 'gradle') for w in workspaces]: if home in [os.path.join(w, 'share', 'gradle') for w in workspaces]:
home = os.path.join(workspaces[0], 'share', 'gradle') home = os.path.join(workspaces[0], 'share', 'gradle')
print(home) print(home)
elif args.local_maven_repository:
home = get_environment_variable(environment_variables, 'MAVEN_USER_LOCAL_REPOSITORY') #TODO research key
if home is None:
home = os.path.join(workspaces[0], 'share', 'maven')
else:
if home in [os.path.join(w, 'share', 'maven') for w in workspaces]:
home = os.path.join(workspaces[0], 'share', 'maven')
print(home)
elif args.create_maven_settings:
print(MAVEN_HEADER + get_repositories_xml() + MAVEN_FOOTER)
else: else:
print("Nothing to see here - please provide one of the valid command switches.") print("Nothing to see here - please provide one of the valid command switches.")
<package> <package>
<name>rosjava_build_tools</name> <name>rosjava_build_tools</name>
<version>0.3.5</version> <version>0.3.6</version>
<description> <description>
Simple tools and catkin modules for rosjava development. Simple tools and catkin modules for rosjava development.
</description> </description>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment