From 417bbf1cf9e89806497ff3cdd858fac41c2cda33 Mon Sep 17 00:00:00 2001 From: Esteve Fernandez Date: Tue, 25 Oct 2016 11:06:12 +0200 Subject: [PATCH 01/27] Updated license --- CONTRIBUTING.md | 13 +++++++++++++ LICENSE | 18 ++++-------------- 2 files changed, 17 insertions(+), 14 deletions(-) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..6f63de9 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,13 @@ +Any contribution that you make to this repository will +be under the Apache 2 License, as dictated by that +[license](http://www.apache.org/licenses/LICENSE-2.0.html): + +~~~ +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. +~~~ diff --git a/LICENSE b/LICENSE index 8dada3e..5de4dc8 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,7 @@ + Apache License Version 2.0, January 2004 - http://www.apache.org/licenses/ + https://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION @@ -175,24 +176,13 @@ END OF TERMS AND CONDITIONS - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} + Copyright 2016 Esteve Fernandez Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, From 55d964d4c6ae5f611250fb66bc0bee9fd5193e94 Mon Sep 17 00:00:00 2001 From: Esteve Fernandez Date: Wed, 22 Mar 2017 14:20:55 +0100 Subject: [PATCH 02/27] Update copyright --- LICENSE | 2 +- NOTICE | 5 +++++ .../ament_build_type_gradle/__init__.py | 11 +++++++++-- 3 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 NOTICE diff --git a/LICENSE b/LICENSE index 5de4dc8..8d89d4e 100644 --- a/LICENSE +++ b/LICENSE @@ -176,7 +176,7 @@ END OF TERMS AND CONDITIONS - Copyright 2016 Esteve Fernandez + Copyright 2016-2017 Esteve Fernandez Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/NOTICE b/NOTICE new file mode 100644 index 0000000..16d2754 --- /dev/null +++ b/NOTICE @@ -0,0 +1,5 @@ +ros2_java +Copyright 2016-2017 Esteve Fernandez (esteve@apache.org) + +This product includes software developed by +Esteve Fernandez (esteve@apache.org) diff --git a/ament_build_type_gradle/ament_build_type_gradle/__init__.py b/ament_build_type_gradle/ament_build_type_gradle/__init__.py index 6e38265..99292a2 100644 --- a/ament_build_type_gradle/ament_build_type_gradle/__init__.py +++ b/ament_build_type_gradle/ament_build_type_gradle/__init__.py @@ -1,5 +1,4 @@ -# Copyright 2014 Open Source Robotics Foundation, Inc. -# Copyright 2016 Esteve Fernandez +# Copyright 2016-2017 Esteve Fernandez # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,6 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. +# Based on +# https://github.com/ament/ament_tools/blob/master/ament_tools/build_types/ament_python.py +# Copyright 2014 Open Source Robotics Foundation, Inc. + """Implements the BuildType support for gradle based ament packages.""" import os @@ -77,6 +80,7 @@ def on_build(self, context): cmd = [GRADLE_EXECUTABLE] cmd += cmd_args cmd += ['assemble'] + cmd += ['--stacktrace'] yield BuildAction(cmd, cwd=context.source_space) @@ -92,6 +96,7 @@ def on_test(self, context): cmd = [GRADLE_EXECUTABLE] cmd += cmd_args cmd += ['test'] + cmd += ['--stacktrace'] yield BuildAction(cmd, cwd=context.source_space) @@ -108,6 +113,7 @@ def on_install(self, context): cmd = [GRADLE_EXECUTABLE] cmd += cmd_args cmd += ['assemble'] + cmd += ['--stacktrace'] yield BuildAction(cmd, cwd=context.source_space) @@ -124,5 +130,6 @@ def on_uninstall(self, context): cmd = [GRADLE_EXECUTABLE] cmd += cmd_args cmd += ['clean'] + cmd += ['--stacktrace'] yield BuildAction(cmd, cwd=context.source_space) From 0dbde142c2b2430294f77f2a7a738b9d98f87557 Mon Sep 17 00:00:00 2001 From: Esteve Fernandez Date: Thu, 23 Mar 2017 16:58:36 +0100 Subject: [PATCH 03/27] Added yapf configuration file. Reformat Python code --- .style.yapf | 3 +++ .../ament_build_type_gradle/__init__.py | 8 +++----- ament_build_type_gradle/setup.py | 7 ++----- 3 files changed, 8 insertions(+), 10 deletions(-) create mode 100644 .style.yapf diff --git a/.style.yapf b/.style.yapf new file mode 100644 index 0000000..728e3f0 --- /dev/null +++ b/.style.yapf @@ -0,0 +1,3 @@ +[style] +based_on_style = pep8 +column_limit = 100 diff --git a/ament_build_type_gradle/ament_build_type_gradle/__init__.py b/ament_build_type_gradle/ament_build_type_gradle/__init__.py index 99292a2..f991908 100644 --- a/ament_build_type_gradle/ament_build_type_gradle/__init__.py +++ b/ament_build_type_gradle/ament_build_type_gradle/__init__.py @@ -15,7 +15,6 @@ # Based on # https://github.com/ament/ament_tools/blob/master/ament_tools/build_types/ament_python.py # Copyright 2014 Open Source Robotics Foundation, Inc. - """Implements the BuildType support for gradle based ament packages.""" import os @@ -28,6 +27,7 @@ IS_WINDOWS = os.name == 'nt' + def get_gradle_executable(): gradle_script = 'gradle.bat' if IS_WINDOWS else 'gradle' if 'GRADLE_HOME' in os.environ: @@ -51,16 +51,14 @@ def prepare_arguments(self, parser): nargs='*', default=[], help="Arbitrary arguments which are passed to 'ament_gradle' Gradle projects. " - "Argument collection can be terminated with '--'.") + "Argument collection can be terminated with '--'.") def argument_preprocessor(self, args): # The ament CMake pass-through flag collects dashed options. # This requires special handling or argparse will complain about # unrecognized options. args, gradle_args = extract_argument_group(args, '--ament-gradle-args') - extras = { - 'ament_gradle_args': gradle_args, - } + extras = {'ament_gradle_args': gradle_args, } return args, extras def extend_context(self, options): diff --git a/ament_build_type_gradle/setup.py b/ament_build_type_gradle/setup.py index 400ec37..d2cf356 100644 --- a/ament_build_type_gradle/setup.py +++ b/ament_build_type_gradle/setup.py @@ -21,8 +21,5 @@ license='Apache License, Version 2.0', test_suite='test', entry_points={ - 'ament.build_types': [ - 'ament_gradle = ament_build_type_gradle:AmentGradleBuildType', - ], - } -) + 'ament.build_types': ['ament_gradle = ament_build_type_gradle:AmentGradleBuildType', ], + }) From 9cc13a7538959ee7ab0a315c649a3ac66a3980ec Mon Sep 17 00:00:00 2001 From: Esteve Fernandez Date: Thu, 23 Mar 2017 16:57:20 +0100 Subject: [PATCH 04/27] Consolidate classpath templates into ament_build_type_gradle --- .../ament_build_type_gradle/__init__.py | 71 ++++++++++++++++++- .../environment_hook/classpath.bat.in | 4 ++ .../template/environment_hook/classpath.sh.in | 8 +++ .../ament_build_type_gradle/templates.py | 19 +++++ ament_build_type_gradle/setup.py | 35 ++++++++- 5 files changed, 134 insertions(+), 3 deletions(-) create mode 100644 ament_build_type_gradle/ament_build_type_gradle/template/environment_hook/classpath.bat.in create mode 100644 ament_build_type_gradle/ament_build_type_gradle/template/environment_hook/classpath.sh.in create mode 100644 ament_build_type_gradle/ament_build_type_gradle/templates.py diff --git a/ament_build_type_gradle/ament_build_type_gradle/__init__.py b/ament_build_type_gradle/ament_build_type_gradle/__init__.py index f991908..2bec1d0 100644 --- a/ament_build_type_gradle/ament_build_type_gradle/__init__.py +++ b/ament_build_type_gradle/ament_build_type_gradle/__init__.py @@ -20,10 +20,16 @@ import os import shutil -from ament_tools.helper import extract_argument_group +from ament_build_type_gradle.templates import get_environment_hook_template_path + +from ament_package.templates import configure_file +from ament_package.templates import get_package_level_template_names +from ament_tools.helper import extract_argument_group from ament_tools.build_type import BuildAction from ament_tools.build_type import BuildType +from ament_tools.build_types.common import expand_package_level_setup_files +from ament_tools.helper import deploy_file IS_WINDOWS = os.name == 'nt' @@ -67,6 +73,36 @@ def extend_context(self, options): return ce def on_build(self, context): + # expand environment hook for CLASSPATH + ext = '.sh.in' if not IS_WINDOWS else '.bat.in' + template_path = get_environment_hook_template_path('classpath' + ext) + + # If using the Gradle Ament Plugin, JAR files are installed into + # $AMENT_CURRENT_PREFIX/share/$PROJECT_NAME/java/$PROJECT_NAME.jar + classpath = os.path.join('$AMENT_CURRENT_PREFIX', 'share', + context.package_manifest.name, 'java', + context.package_manifest.name + ".jar") + + content = configure_file(template_path, + {'_AMENT_EXPORT_JARS_CLASSPATH': classpath, }) + + environment_hooks_path = os.path.join( + 'share', context.package_manifest.name, 'environment') + classpath_environment_hook = os.path.join( + environment_hooks_path, os.path.basename(template_path)[:-3]) + + destination_path = os.path.join(context.build_space, + classpath_environment_hook) + destination_dir = os.path.dirname(destination_path) + if not os.path.exists(destination_dir): + os.makedirs(destination_dir) + with open(destination_path, 'w') as h: + h.write(content) + + # expand package-level setup files + expand_package_level_setup_files(context, [classpath_environment_hook], + environment_hooks_path) + cmd_args = [ '-Pament.build_space=' + context.build_space, '-Pament.install_space=' + context.install_space, @@ -99,6 +135,39 @@ def on_test(self, context): yield BuildAction(cmd, cwd=context.source_space) def on_install(self, context): + # deploy package manifest + deploy_file( + context, + context.source_space, + 'package.xml', + dst_subfolder=os.path.join('share', context.package_manifest.name)) + + # create marker file + marker_file = os.path.join(context.install_space, 'share', + 'ament_index', 'resource_index', 'packages', + context.package_manifest.name) + if not os.path.exists(marker_file): + marker_dir = os.path.dirname(marker_file) + if not os.path.exists(marker_dir): + os.makedirs(marker_dir) + with open(marker_file, 'w'): # "touching" the file + pass + + ext = '.sh' if not IS_WINDOWS else '.bat' + + # deploy CLASSPATH environment hook + destination_file = 'classpath' + ('.sh' if not IS_WINDOWS else '.bat') + deploy_file(context, context.build_space, + os.path.join('share', context.package_manifest.name, + 'environment', destination_file)) + + # deploy package-level setup files + for name in get_package_level_template_names(): + assert name.endswith('.in') + deploy_file(context, context.build_space, + os.path.join('share', context.package_manifest.name, + name[:-3])) + cmd_args = [ '-Pament.build_space=' + context.build_space, '-Pament.install_space=' + context.install_space, diff --git a/ament_build_type_gradle/ament_build_type_gradle/template/environment_hook/classpath.bat.in b/ament_build_type_gradle/ament_build_type_gradle/template/environment_hook/classpath.bat.in new file mode 100644 index 0000000..bd2506b --- /dev/null +++ b/ament_build_type_gradle/ament_build_type_gradle/template/environment_hook/classpath.bat.in @@ -0,0 +1,4 @@ +ament_prepend_unique_value CLASSPATH "." +REM https://ss64.com/nt/for.html +FOR %%jarfile IN (@_AMENT_EXPORT_JARS_CLASSPATH@) DO ( + ament_prepend_unique_value CLASSPATH "%%jarfile") diff --git a/ament_build_type_gradle/ament_build_type_gradle/template/environment_hook/classpath.sh.in b/ament_build_type_gradle/ament_build_type_gradle/template/environment_hook/classpath.sh.in new file mode 100644 index 0000000..91f22a6 --- /dev/null +++ b/ament_build_type_gradle/ament_build_type_gradle/template/environment_hook/classpath.sh.in @@ -0,0 +1,8 @@ +ament_prepend_unique_value CLASSPATH "." +IFS=";" +jars="@_AMENT_EXPORT_JARS_CLASSPATH@" + +for jar in $jars +do + ament_prepend_unique_value CLASSPATH "$jar" +done diff --git a/ament_build_type_gradle/ament_build_type_gradle/templates.py b/ament_build_type_gradle/ament_build_type_gradle/templates.py new file mode 100644 index 0000000..8140b03 --- /dev/null +++ b/ament_build_type_gradle/ament_build_type_gradle/templates.py @@ -0,0 +1,19 @@ +# Copyright 2016-2017 Esteve Fernandez +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from ament_index_python import get_resource + + +def get_environment_hook_template_path(name): + return get_resource('templates', 'ament_build_type_gradle_classpath')[0] \ No newline at end of file diff --git a/ament_build_type_gradle/setup.py b/ament_build_type_gradle/setup.py index d2cf356..af4bb72 100644 --- a/ament_build_type_gradle/setup.py +++ b/ament_build_type_gradle/setup.py @@ -1,5 +1,30 @@ +import os + from setuptools import find_packages from setuptools import setup +from setuptools.command.build_py import build_py +from distutils.command.install_data import install_data + +IS_WINDOWS = os.name == 'nt' + + +class ament_index_generator(install_data): + def run(self): + super().run() + target_dir = os.path.join(self.install_dir, 'share', 'ament_index', + 'resource_index', 'templates') + template_filename = 'classpath' + ('.sh.in' + if not IS_WINDOWS else '.bat.in') + template_path = os.path.join(self.install_dir, 'share', + 'ament_build_type_gradle', 'template', + 'environment_hook', template_filename) + + self.mkpath(target_dir) + with open( + os.path.join(target_dir, 'ament_build_type_gradle_classpath'), + 'w') as f: + f.write(template_path) + setup( name='ament_build_type_gradle', @@ -21,5 +46,11 @@ license='Apache License, Version 2.0', test_suite='test', entry_points={ - 'ament.build_types': ['ament_gradle = ament_build_type_gradle:AmentGradleBuildType', ], - }) + 'ament.build_types': + ['ament_gradle = ament_build_type_gradle:AmentGradleBuildType', ], + }, + data_files=[('share/ament_build_type_gradle/template/environment_hook', [ + 'ament_build_type_gradle/template/environment_hook/classpath.sh.in', + 'ament_build_type_gradle/template/environment_hook/classpath.bat.in', + ])], + cmdclass={'install_data': ament_index_generator}) From 05c3238c52421c5f292f9440e4482b2fd1e0250f Mon Sep 17 00:00:00 2001 From: Esteve Fernandez Date: Sat, 25 Mar 2017 13:29:13 +0100 Subject: [PATCH 05/27] Fix for symlinked installs --- ament_build_type_gradle/setup.py | 79 ++++++++++++++++++++++++-------- 1 file changed, 61 insertions(+), 18 deletions(-) diff --git a/ament_build_type_gradle/setup.py b/ament_build_type_gradle/setup.py index af4bb72..066334b 100644 --- a/ament_build_type_gradle/setup.py +++ b/ament_build_type_gradle/setup.py @@ -2,29 +2,70 @@ from setuptools import find_packages from setuptools import setup -from setuptools.command.build_py import build_py -from distutils.command.install_data import install_data +from setuptools.command.install import install +from setuptools.command.develop import develop IS_WINDOWS = os.name == 'nt' +# Customize both the install (non-symlinked) and develop (symlinked) commands so that we can +# install an entry in the ament index for the path to the CLASSPATH templates -class ament_index_generator(install_data): + +class ament_gradle_install(install): + def run(self): + super().run() + install_dir = self.prefix + install_index_dir = os.path.join(install_dir, 'share', 'ament_index', + 'resource_index', 'templates') + install_index_path = os.path.join(install_index_dir, + 'ament_build_type_gradle_classpath') + + install_lib_dir = self.get_finalized_command('install_lib').install_dir + + template_dir = os.path.join(install_lib_dir, 'ament_build_type_gradle', + 'template', 'environment_hook') + template_filename = 'classpath' + ('.sh.in' + if not IS_WINDOWS else '.bat.in') + template_path = os.path.join(template_dir, template_filename) + + self.mkpath(install_index_dir) + with open(install_index_path, 'w') as f: + f.write(template_path) + + +class ament_gradle_develop(develop): def run(self): super().run() - target_dir = os.path.join(self.install_dir, 'share', 'ament_index', - 'resource_index', 'templates') + build_dir = os.path.abspath(self.setup_path) + src_dir = os.path.dirname( + os.path.realpath(os.path.join(build_dir, 'setup.py'))) + install_dir = self.prefix + + template_dir = os.path.join(src_dir, 'ament_build_type_gradle', + 'template', 'environment_hook') template_filename = 'classpath' + ('.sh.in' if not IS_WINDOWS else '.bat.in') - template_path = os.path.join(self.install_dir, 'share', - 'ament_build_type_gradle', 'template', - 'environment_hook', template_filename) - - self.mkpath(target_dir) - with open( - os.path.join(target_dir, 'ament_build_type_gradle_classpath'), - 'w') as f: + template_path = os.path.join(template_dir, template_filename) + + build_index_dir = os.path.join(build_dir, 'share', 'ament_index', + 'resource_index', 'templates') + build_index_path = os.path.join(build_index_dir, + 'ament_build_type_gradle_classpath') + self.mkpath(build_index_dir) + with open(build_index_path, 'w') as f: f.write(template_path) + install_index_dir = os.path.join(install_dir, 'share', 'ament_index', + 'resource_index', 'templates') + install_index_path = os.path.join(install_index_dir, + 'ament_build_type_gradle_classpath') + self.mkpath(install_index_dir) + + if os.path.exists(install_index_path): + os.remove(install_index_path) + if not os.path.exists(install_index_path): + os.symlink(build_index_path, install_index_path) + setup( name='ament_build_type_gradle', @@ -49,8 +90,10 @@ def run(self): 'ament.build_types': ['ament_gradle = ament_build_type_gradle:AmentGradleBuildType', ], }, - data_files=[('share/ament_build_type_gradle/template/environment_hook', [ - 'ament_build_type_gradle/template/environment_hook/classpath.sh.in', - 'ament_build_type_gradle/template/environment_hook/classpath.bat.in', - ])], - cmdclass={'install_data': ament_index_generator}) + package_data={ + 'ament_build_type_gradle': ['template/environment_hook/*.in'] + }, + cmdclass={ + 'develop': ament_gradle_develop, + 'install': ament_gradle_install, + }, ) From 8d2efbca2fc4dc1a9a8d1d5d1cac8fc147ab3615 Mon Sep 17 00:00:00 2001 From: Esteve Fernandez Date: Tue, 2 May 2017 11:41:14 +0200 Subject: [PATCH 06/27] Clean up IFS. Use shwordsplit for zsh --- .../template/environment_hook/classpath.sh.in | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/ament_build_type_gradle/ament_build_type_gradle/template/environment_hook/classpath.sh.in b/ament_build_type_gradle/ament_build_type_gradle/template/environment_hook/classpath.sh.in index 91f22a6..fc8ace3 100644 --- a/ament_build_type_gradle/ament_build_type_gradle/template/environment_hook/classpath.sh.in +++ b/ament_build_type_gradle/ament_build_type_gradle/template/environment_hook/classpath.sh.in @@ -1,4 +1,12 @@ +if [ -n "$ZSH_VERSION" ]; then + if [[ $options[shwordsplit] = off ]]; then + _AMENT_JAVA_SH_WORD_SPLIT=1 + setopt shwordsplit + fi +fi + ament_prepend_unique_value CLASSPATH "." +_AMENT_JAVA_IFS=$IFS IFS=";" jars="@_AMENT_EXPORT_JARS_CLASSPATH@" @@ -6,3 +14,14 @@ for jar in $jars do ament_prepend_unique_value CLASSPATH "$jar" done + +IFS=$_AMENT_JAVA_IFS + +unset jar +unset jars +unset AMENT_JAVA_IFS + +if [ -n "$_AMENT_JAVA_SH_WORD_SPLIT" ]; then + unsetopt shwordsplit + unset _AMENT_JAVA_SH_WORD_SPLIT +fi From ec2447867ff6a19823e40c3834f8150cb2512697 Mon Sep 17 00:00:00 2001 From: Esteve Fernandez Date: Fri, 23 Jun 2017 18:06:53 +0200 Subject: [PATCH 07/27] Hold ament_tools version --- ament_java.repos | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ament_java.repos b/ament_java.repos index 3c8ca96..7a5752a 100644 --- a/ament_java.repos +++ b/ament_java.repos @@ -17,7 +17,7 @@ repositories: version: master ament/ament_tools: type: git - url: https://github.com/ament/ament_tools.git + url: https://github.com/esteve/ament_tools.git version: master ament/gmock_vendor: type: git From 0940d7daf3eba132d517c53ffcff1c7a8cb428fb Mon Sep 17 00:00:00 2001 From: Esteve Fernandez Date: Thu, 6 Jul 2017 09:28:43 +0200 Subject: [PATCH 08/27] Pass package name to the Gradle projects --- ament_build_type_gradle/ament_build_type_gradle/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ament_build_type_gradle/ament_build_type_gradle/__init__.py b/ament_build_type_gradle/ament_build_type_gradle/__init__.py index 2bec1d0..f198242 100644 --- a/ament_build_type_gradle/ament_build_type_gradle/__init__.py +++ b/ament_build_type_gradle/ament_build_type_gradle/__init__.py @@ -108,6 +108,7 @@ def on_build(self, context): '-Pament.install_space=' + context.install_space, '-Pament.dependencies=' + ':'.join(context.build_dependencies), '-Pament.build_tests=' + str(context.build_tests), + '-Pament.package_name=' + context.package_manifest.name, ] cmd_args += context.ament_gradle_args @@ -124,6 +125,7 @@ def on_test(self, context): '-Pament.install_space=' + context.install_space, '-Pament.dependencies=' + ':'.join(context.build_dependencies), '-Pament.build_tests=' + str(context.build_tests), + '-Pament.package_name=' + context.package_manifest.name, ] cmd_args += context.ament_gradle_args @@ -173,6 +175,7 @@ def on_install(self, context): '-Pament.install_space=' + context.install_space, '-Pament.dependencies=' + ':'.join(context.build_dependencies), '-Pament.build_tests=' + str(context.build_tests), + '-Pament.package_name=' + context.package_manifest.name, ] cmd_args += context.ament_gradle_args @@ -190,6 +193,7 @@ def on_uninstall(self, context): '-Pament.install_space=' + context.install_space, '-Pament.dependencies=' + ':'.join(context.build_dependencies), '-Pament.build_tests=' + str(context.build_tests), + '-Pament.package_name=' + context.package_manifest.name, ] cmd_args += context.ament_gradle_args From 83b7ee4d07c3c28ef54a196c51954d5137e84bca Mon Sep 17 00:00:00 2001 From: Esteve Fernandez Date: Sat, 1 Jul 2017 20:32:31 +0200 Subject: [PATCH 09/27] Provide more information about the current package to the Gradle plugin --- .../ament_build_type_gradle/__init__.py | 66 ++++++++++--------- 1 file changed, 35 insertions(+), 31 deletions(-) diff --git a/ament_build_type_gradle/ament_build_type_gradle/__init__.py b/ament_build_type_gradle/ament_build_type_gradle/__init__.py index f198242..36dbfea 100644 --- a/ament_build_type_gradle/ament_build_type_gradle/__init__.py +++ b/ament_build_type_gradle/ament_build_type_gradle/__init__.py @@ -30,6 +30,8 @@ from ament_tools.build_type import BuildType from ament_tools.build_types.common import expand_package_level_setup_files from ament_tools.helper import deploy_file +from ament_tools.topological_order import topological_order_packages +from ament_tools.verbs.build_pkg import cli IS_WINDOWS = os.name == 'nt' @@ -67,9 +69,37 @@ def argument_preprocessor(self, args): extras = {'ament_gradle_args': gradle_args, } return args, extras + def ament_gradle_recursive_dependencies(self, context): + for export in context.package_manifest.exports: + if export.tagname == 'ament_gradle_recursive_dependencies': + return True + return False + + def get_ament_args(self, context): + cmd_args = [ + '-Pament.build_space=' + context.build_space, + '-Pament.install_space=' + context.install_space, + '-Pament.dependencies=' + ':'.join(context.build_dependencies), + '-Pament.build_tests=' + str(context.build_tests), + '-Pament.package_manifest.name=' + context.package_manifest.name, + '-Pament.exec_dependency_paths_in_workspace=' + + ':'.join(context.exec_dependency_paths_in_workspace), + '-Pament.gradle_recursive_dependencies=' + str( + self.ament_gradle_recursive_dependencies(context)), + '-Pament.gradle_isolated=' + str(context.ament_gradle_isolated), + ] + return cmd_args + def extend_context(self, options): ce = super(AmentGradleBuildType, self).extend_context(options) - ce.add('ament_gradle_args', options.ament_gradle_args) + ament_gradle_args = list(options.ament_gradle_args) + if not any([ + arg.startswith('-Pament.android_variant=') + for arg in ament_gradle_args + ]): + ament_gradle_args.append('-Pament.android_variant=release') + ce.add('ament_gradle_args', ament_gradle_args) + ce.add('ament_gradle_isolated', options.isolated) return ce def on_build(self, context): @@ -103,13 +133,7 @@ def on_build(self, context): expand_package_level_setup_files(context, [classpath_environment_hook], environment_hooks_path) - cmd_args = [ - '-Pament.build_space=' + context.build_space, - '-Pament.install_space=' + context.install_space, - '-Pament.dependencies=' + ':'.join(context.build_dependencies), - '-Pament.build_tests=' + str(context.build_tests), - '-Pament.package_name=' + context.package_manifest.name, - ] + cmd_args = self.get_ament_args(context) cmd_args += context.ament_gradle_args cmd = [GRADLE_EXECUTABLE] @@ -120,13 +144,7 @@ def on_build(self, context): yield BuildAction(cmd, cwd=context.source_space) def on_test(self, context): - cmd_args = [ - '-Pament.build_space=' + context.build_space, - '-Pament.install_space=' + context.install_space, - '-Pament.dependencies=' + ':'.join(context.build_dependencies), - '-Pament.build_tests=' + str(context.build_tests), - '-Pament.package_name=' + context.package_manifest.name, - ] + cmd_args = self.get_ament_args(context) cmd_args += context.ament_gradle_args cmd = [GRADLE_EXECUTABLE] @@ -170,14 +188,7 @@ def on_install(self, context): os.path.join('share', context.package_manifest.name, name[:-3])) - cmd_args = [ - '-Pament.build_space=' + context.build_space, - '-Pament.install_space=' + context.install_space, - '-Pament.dependencies=' + ':'.join(context.build_dependencies), - '-Pament.build_tests=' + str(context.build_tests), - '-Pament.package_name=' + context.package_manifest.name, - ] - + cmd_args = self.get_ament_args(context) cmd_args += context.ament_gradle_args cmd = [GRADLE_EXECUTABLE] @@ -188,14 +199,7 @@ def on_install(self, context): yield BuildAction(cmd, cwd=context.source_space) def on_uninstall(self, context): - cmd_args = [ - '-Pament.build_space=' + context.build_space, - '-Pament.install_space=' + context.install_space, - '-Pament.dependencies=' + ':'.join(context.build_dependencies), - '-Pament.build_tests=' + str(context.build_tests), - '-Pament.package_name=' + context.package_manifest.name, - ] - + cmd_args = self.get_ament_args(context) cmd_args += context.ament_gradle_args cmd = [GRADLE_EXECUTABLE] From 284afec48e52405ce1f34ae7efb695e53a37299c Mon Sep 17 00:00:00 2001 From: Esteve Fernandez Date: Mon, 10 Jul 2017 21:10:08 +0200 Subject: [PATCH 10/27] Look for the Gradle wrapper as well as the Gradle script. Raise an exception if neither can be found --- .../ament_build_type_gradle/__init__.py | 128 ++++++++---------- 1 file changed, 56 insertions(+), 72 deletions(-) diff --git a/ament_build_type_gradle/ament_build_type_gradle/__init__.py b/ament_build_type_gradle/ament_build_type_gradle/__init__.py index 36dbfea..f283839 100644 --- a/ament_build_type_gradle/ament_build_type_gradle/__init__.py +++ b/ament_build_type_gradle/ament_build_type_gradle/__init__.py @@ -30,25 +30,12 @@ from ament_tools.build_type import BuildType from ament_tools.build_types.common import expand_package_level_setup_files from ament_tools.helper import deploy_file -from ament_tools.topological_order import topological_order_packages from ament_tools.verbs.build_pkg import cli +from ament_tools.verbs import VerbExecutionError IS_WINDOWS = os.name == 'nt' -def get_gradle_executable(): - gradle_script = 'gradle.bat' if IS_WINDOWS else 'gradle' - if 'GRADLE_HOME' in os.environ: - gradle_home = os.environ['GRADLE_HOME'] - gradle_path = os.path.join(gradle_home, 'bin', gradle_script) - if os.path.isfile(gradle_path): - return gradle_path - return shutil.which(gradle_script) - - -GRADLE_EXECUTABLE = get_gradle_executable() - - class AmentGradleBuildType(BuildType): build_type = 'ament_gradle' description = "ament package built with Gradle" @@ -90,13 +77,44 @@ def get_ament_args(self, context): ] return cmd_args + def get_gradle_wrapper(self, context): + gradlew_script = 'gradlew.bat' if IS_WINDOWS else 'gradlew' + gradlew_path = os.path.join(context.source_space, gradlew_script) + if os.path.isfile(gradlew_path): + return gradle_path + + def get_gradle_executable(self, context): + gradlew_path = self.get_gradle_wrapper(context) + if gradlew_path: + return gradlew_path + + gradle_script = 'gradle.bat' if IS_WINDOWS else 'gradle' + if 'GRADLE_HOME' in os.environ: + gradle_home = os.environ['GRADLE_HOME'] + gradle_path = os.path.join(gradle_home, 'bin', gradle_script) + if os.path.isfile(gradle_path): + return gradle_path + gradle_path = shutil.which(gradle_script) + if gradle_path: + return gradle_path + raise VerbExecutionError("Could not find 'gradle' executable") + + def prepare_cmd(self, context, gradle_task=None): + cmd_args = self.get_ament_args(context) + cmd_args += context.ament_gradle_args + + cmd = [self.get_gradle_executable(context)] + cmd += cmd_args + if gradle_task: + cmd += [gradle_task] + cmd += ['--stacktrace'] + + return cmd + def extend_context(self, options): ce = super(AmentGradleBuildType, self).extend_context(options) ament_gradle_args = list(options.ament_gradle_args) - if not any([ - arg.startswith('-Pament.android_variant=') - for arg in ament_gradle_args - ]): + if not any([arg.startswith('-Pament.android_variant=') for arg in ament_gradle_args]): ament_gradle_args.append('-Pament.android_variant=release') ce.add('ament_gradle_args', ament_gradle_args) ce.add('ament_gradle_isolated', options.isolated) @@ -109,20 +127,16 @@ def on_build(self, context): # If using the Gradle Ament Plugin, JAR files are installed into # $AMENT_CURRENT_PREFIX/share/$PROJECT_NAME/java/$PROJECT_NAME.jar - classpath = os.path.join('$AMENT_CURRENT_PREFIX', 'share', - context.package_manifest.name, 'java', - context.package_manifest.name + ".jar") + classpath = os.path.join('$AMENT_CURRENT_PREFIX', 'share', context.package_manifest.name, + 'java', context.package_manifest.name + ".jar") - content = configure_file(template_path, - {'_AMENT_EXPORT_JARS_CLASSPATH': classpath, }) + content = configure_file(template_path, {'_AMENT_EXPORT_JARS_CLASSPATH': classpath, }) - environment_hooks_path = os.path.join( - 'share', context.package_manifest.name, 'environment') - classpath_environment_hook = os.path.join( - environment_hooks_path, os.path.basename(template_path)[:-3]) + environment_hooks_path = os.path.join('share', context.package_manifest.name, 'environment') + classpath_environment_hook = os.path.join(environment_hooks_path, + os.path.basename(template_path)[:-3]) - destination_path = os.path.join(context.build_space, - classpath_environment_hook) + destination_path = os.path.join(context.build_space, classpath_environment_hook) destination_dir = os.path.dirname(destination_path) if not os.path.exists(destination_dir): os.makedirs(destination_dir) @@ -133,26 +147,12 @@ def on_build(self, context): expand_package_level_setup_files(context, [classpath_environment_hook], environment_hooks_path) - cmd_args = self.get_ament_args(context) - cmd_args += context.ament_gradle_args - - cmd = [GRADLE_EXECUTABLE] - cmd += cmd_args - cmd += ['assemble'] - cmd += ['--stacktrace'] - - yield BuildAction(cmd, cwd=context.source_space) + yield BuildAction( + self.prepare_cmd( + context, gradle_task='assemble'), cwd=context.source_space) def on_test(self, context): - cmd_args = self.get_ament_args(context) - cmd_args += context.ament_gradle_args - - cmd = [GRADLE_EXECUTABLE] - cmd += cmd_args - cmd += ['test'] - cmd += ['--stacktrace'] - - yield BuildAction(cmd, cwd=context.source_space) + yield BuildAction(self.prepare_cmd(context, gradle_task='test'), cwd=context.source_space) def on_install(self, context): # deploy package manifest @@ -163,9 +163,8 @@ def on_install(self, context): dst_subfolder=os.path.join('share', context.package_manifest.name)) # create marker file - marker_file = os.path.join(context.install_space, 'share', - 'ament_index', 'resource_index', 'packages', - context.package_manifest.name) + marker_file = os.path.join(context.install_space, 'share', 'ament_index', 'resource_index', + 'packages', context.package_manifest.name) if not os.path.exists(marker_file): marker_dir = os.path.dirname(marker_file) if not os.path.exists(marker_dir): @@ -178,33 +177,18 @@ def on_install(self, context): # deploy CLASSPATH environment hook destination_file = 'classpath' + ('.sh' if not IS_WINDOWS else '.bat') deploy_file(context, context.build_space, - os.path.join('share', context.package_manifest.name, - 'environment', destination_file)) + os.path.join('share', context.package_manifest.name, 'environment', + destination_file)) # deploy package-level setup files for name in get_package_level_template_names(): assert name.endswith('.in') deploy_file(context, context.build_space, - os.path.join('share', context.package_manifest.name, - name[:-3])) - - cmd_args = self.get_ament_args(context) - cmd_args += context.ament_gradle_args + os.path.join('share', context.package_manifest.name, name[:-3])) - cmd = [GRADLE_EXECUTABLE] - cmd += cmd_args - cmd += ['assemble'] - cmd += ['--stacktrace'] - - yield BuildAction(cmd, cwd=context.source_space) + yield BuildAction( + self.prepare_cmd( + context, gradle_task='assemble'), cwd=context.source_space) def on_uninstall(self, context): - cmd_args = self.get_ament_args(context) - cmd_args += context.ament_gradle_args - - cmd = [GRADLE_EXECUTABLE] - cmd += cmd_args - cmd += ['clean'] - cmd += ['--stacktrace'] - - yield BuildAction(cmd, cwd=context.source_space) + yield BuildAction(self.prepare_cmd(context, gradle_task='clean'), cwd=context.source_space) From 4ad1b66dfd597187112c82831e46c9b0bc367ae7 Mon Sep 17 00:00:00 2001 From: Esteve Fernandez Date: Tue, 11 Jul 2017 18:52:10 +0200 Subject: [PATCH 11/27] Use ament_java_resources to store CLASSPATH templates --- .../ament_build_type_gradle/__init__.py | 12 ++-- .../ament_build_type_gradle/templates.py | 9 ++- ament_build_type_gradle/package.xml | 3 + ament_build_type_gradle/setup.py | 68 +------------------ ament_java.repos | 2 +- ament_java_resources/CMakeLists.txt | 17 +++++ .../classpath.bat.template | 0 .../classpath.sh.template | 0 ament_java_resources/package.xml | 22 ++++++ 9 files changed, 58 insertions(+), 75 deletions(-) create mode 100644 ament_java_resources/CMakeLists.txt rename ament_build_type_gradle/ament_build_type_gradle/template/environment_hook/classpath.bat.in => ament_java_resources/classpath.bat.template (100%) rename ament_build_type_gradle/ament_build_type_gradle/template/environment_hook/classpath.sh.in => ament_java_resources/classpath.sh.template (100%) create mode 100644 ament_java_resources/package.xml diff --git a/ament_build_type_gradle/ament_build_type_gradle/__init__.py b/ament_build_type_gradle/ament_build_type_gradle/__init__.py index f283839..d53cbf5 100644 --- a/ament_build_type_gradle/ament_build_type_gradle/__init__.py +++ b/ament_build_type_gradle/ament_build_type_gradle/__init__.py @@ -22,7 +22,7 @@ from ament_build_type_gradle.templates import get_environment_hook_template_path -from ament_package.templates import configure_file +from ament_package.templates import configure_string from ament_package.templates import get_package_level_template_names from ament_tools.helper import extract_argument_group @@ -121,20 +121,22 @@ def extend_context(self, options): return ce def on_build(self, context): + ext = '.sh' if not IS_WINDOWS else '.bat' + classpath_filename = 'classpath' + ext + # expand environment hook for CLASSPATH - ext = '.sh.in' if not IS_WINDOWS else '.bat.in' - template_path = get_environment_hook_template_path('classpath' + ext) + template = get_environment_hook_template_path() # If using the Gradle Ament Plugin, JAR files are installed into # $AMENT_CURRENT_PREFIX/share/$PROJECT_NAME/java/$PROJECT_NAME.jar classpath = os.path.join('$AMENT_CURRENT_PREFIX', 'share', context.package_manifest.name, 'java', context.package_manifest.name + ".jar") - content = configure_file(template_path, {'_AMENT_EXPORT_JARS_CLASSPATH': classpath, }) + content = configure_string(template, {'_AMENT_EXPORT_JARS_CLASSPATH': classpath, }) environment_hooks_path = os.path.join('share', context.package_manifest.name, 'environment') classpath_environment_hook = os.path.join(environment_hooks_path, - os.path.basename(template_path)[:-3]) + os.path.basename(classpath_filename)) destination_path = os.path.join(context.build_space, classpath_environment_hook) destination_dir = os.path.dirname(destination_path) diff --git a/ament_build_type_gradle/ament_build_type_gradle/templates.py b/ament_build_type_gradle/ament_build_type_gradle/templates.py index 8140b03..0ad191e 100644 --- a/ament_build_type_gradle/ament_build_type_gradle/templates.py +++ b/ament_build_type_gradle/ament_build_type_gradle/templates.py @@ -12,8 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. +import os + from ament_index_python import get_resource +IS_WINDOWS = os.name == 'nt' + -def get_environment_hook_template_path(name): - return get_resource('templates', 'ament_build_type_gradle_classpath')[0] \ No newline at end of file +def get_environment_hook_template_path(): + ext = 'sh' if not IS_WINDOWS else 'bat' + return get_resource('templates', 'ament_build_type_gradle_classpath_' + ext)[0] \ No newline at end of file diff --git a/ament_build_type_gradle/package.xml b/ament_build_type_gradle/package.xml index 0926d42..c6fd0bd 100644 --- a/ament_build_type_gradle/package.xml +++ b/ament_build_type_gradle/package.xml @@ -10,6 +10,9 @@ ament_tools + ament_java_resources + ament_java_resources + ament_copyright ament_pep257 ament_pep8 diff --git a/ament_build_type_gradle/setup.py b/ament_build_type_gradle/setup.py index 066334b..a89eb3b 100644 --- a/ament_build_type_gradle/setup.py +++ b/ament_build_type_gradle/setup.py @@ -2,69 +2,6 @@ from setuptools import find_packages from setuptools import setup -from setuptools.command.install import install -from setuptools.command.develop import develop - -IS_WINDOWS = os.name == 'nt' - -# Customize both the install (non-symlinked) and develop (symlinked) commands so that we can -# install an entry in the ament index for the path to the CLASSPATH templates - - -class ament_gradle_install(install): - def run(self): - super().run() - install_dir = self.prefix - install_index_dir = os.path.join(install_dir, 'share', 'ament_index', - 'resource_index', 'templates') - install_index_path = os.path.join(install_index_dir, - 'ament_build_type_gradle_classpath') - - install_lib_dir = self.get_finalized_command('install_lib').install_dir - - template_dir = os.path.join(install_lib_dir, 'ament_build_type_gradle', - 'template', 'environment_hook') - template_filename = 'classpath' + ('.sh.in' - if not IS_WINDOWS else '.bat.in') - template_path = os.path.join(template_dir, template_filename) - - self.mkpath(install_index_dir) - with open(install_index_path, 'w') as f: - f.write(template_path) - - -class ament_gradle_develop(develop): - def run(self): - super().run() - build_dir = os.path.abspath(self.setup_path) - src_dir = os.path.dirname( - os.path.realpath(os.path.join(build_dir, 'setup.py'))) - install_dir = self.prefix - - template_dir = os.path.join(src_dir, 'ament_build_type_gradle', - 'template', 'environment_hook') - template_filename = 'classpath' + ('.sh.in' - if not IS_WINDOWS else '.bat.in') - template_path = os.path.join(template_dir, template_filename) - - build_index_dir = os.path.join(build_dir, 'share', 'ament_index', - 'resource_index', 'templates') - build_index_path = os.path.join(build_index_dir, - 'ament_build_type_gradle_classpath') - self.mkpath(build_index_dir) - with open(build_index_path, 'w') as f: - f.write(template_path) - - install_index_dir = os.path.join(install_dir, 'share', 'ament_index', - 'resource_index', 'templates') - install_index_path = os.path.join(install_index_dir, - 'ament_build_type_gradle_classpath') - self.mkpath(install_index_dir) - - if os.path.exists(install_index_path): - os.remove(install_index_path) - if not os.path.exists(install_index_path): - os.symlink(build_index_path, install_index_path) setup( @@ -93,7 +30,4 @@ def run(self): package_data={ 'ament_build_type_gradle': ['template/environment_hook/*.in'] }, - cmdclass={ - 'develop': ament_gradle_develop, - 'install': ament_gradle_install, - }, ) + ) diff --git a/ament_java.repos b/ament_java.repos index 7a5752a..3c8ca96 100644 --- a/ament_java.repos +++ b/ament_java.repos @@ -17,7 +17,7 @@ repositories: version: master ament/ament_tools: type: git - url: https://github.com/esteve/ament_tools.git + url: https://github.com/ament/ament_tools.git version: master ament/gmock_vendor: type: git diff --git a/ament_java_resources/CMakeLists.txt b/ament_java_resources/CMakeLists.txt new file mode 100644 index 0000000..509715e --- /dev/null +++ b/ament_java_resources/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.5) + +project(ament_java_resources NONE) + +find_package(ament_cmake REQUIRED) + +ament_index_register_resource( + "templates" + CONTENT_FILE "classpath.sh.template" + PACKAGE_NAME "ament_build_type_gradle_classpath_sh") + +ament_index_register_resource( + "templates" + CONTENT_FILE "classpath.bat.template" + PACKAGE_NAME "ament_build_type_gradle_classpath_bat") + +ament_package() diff --git a/ament_build_type_gradle/ament_build_type_gradle/template/environment_hook/classpath.bat.in b/ament_java_resources/classpath.bat.template similarity index 100% rename from ament_build_type_gradle/ament_build_type_gradle/template/environment_hook/classpath.bat.in rename to ament_java_resources/classpath.bat.template diff --git a/ament_build_type_gradle/ament_build_type_gradle/template/environment_hook/classpath.sh.in b/ament_java_resources/classpath.sh.template similarity index 100% rename from ament_build_type_gradle/ament_build_type_gradle/template/environment_hook/classpath.sh.in rename to ament_java_resources/classpath.sh.template diff --git a/ament_java_resources/package.xml b/ament_java_resources/package.xml new file mode 100644 index 0000000..9c86291 --- /dev/null +++ b/ament_java_resources/package.xml @@ -0,0 +1,22 @@ + + + + ament_java_resources + 0.0.0 + + Register ament_java resources in the Ament index. + + Esteve Fernandez + Apache License 2.0 + + ament_cmake + + ament_cmake + + ament_lint_auto + ament_lint_common + + + ament_cmake + + From 05fe177d860ffaeb8afd7148b662185898833ef7 Mon Sep 17 00:00:00 2001 From: Esteve Fernandez Date: Sun, 1 Oct 2017 19:41:32 +0200 Subject: [PATCH 12/27] Add the JNI directory to the library path environment variable --- .../ament_build_type_gradle/templates.py | 2 +- ament_java_resources/CMakeLists.txt | 10 ++++++++++ ament_java_resources/jni_library_path.bat.template | 1 + ament_java_resources/jni_library_path.sh.template | 14 ++++++++++++++ 4 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 ament_java_resources/jni_library_path.bat.template create mode 100644 ament_java_resources/jni_library_path.sh.template diff --git a/ament_build_type_gradle/ament_build_type_gradle/templates.py b/ament_build_type_gradle/ament_build_type_gradle/templates.py index 0ad191e..0d12fae 100644 --- a/ament_build_type_gradle/ament_build_type_gradle/templates.py +++ b/ament_build_type_gradle/ament_build_type_gradle/templates.py @@ -21,4 +21,4 @@ def get_environment_hook_template_path(): ext = 'sh' if not IS_WINDOWS else 'bat' - return get_resource('templates', 'ament_build_type_gradle_classpath_' + ext)[0] \ No newline at end of file + return get_resource('templates', 'ament_build_type_gradle_classpath_' + ext)[0] diff --git a/ament_java_resources/CMakeLists.txt b/ament_java_resources/CMakeLists.txt index 509715e..a0bbf00 100644 --- a/ament_java_resources/CMakeLists.txt +++ b/ament_java_resources/CMakeLists.txt @@ -14,4 +14,14 @@ ament_index_register_resource( CONTENT_FILE "classpath.bat.template" PACKAGE_NAME "ament_build_type_gradle_classpath_bat") +ament_index_register_resource( + "templates" + CONTENT_FILE "jni_library_path.sh.template" + PACKAGE_NAME "ament_build_type_gradle_jni_library_path_sh") + +ament_index_register_resource( + "templates" + CONTENT_FILE "jni_library_path.bat.template" + PACKAGE_NAME "ament_build_type_gradle_jni_library_path_bat") + ament_package() diff --git a/ament_java_resources/jni_library_path.bat.template b/ament_java_resources/jni_library_path.bat.template new file mode 100644 index 0000000..f759d3a --- /dev/null +++ b/ament_java_resources/jni_library_path.bat.template @@ -0,0 +1 @@ +ament_prepend_unique_value PATH "%AMENT_CURRENT_PREFIX%\lib\jni" diff --git a/ament_java_resources/jni_library_path.sh.template b/ament_java_resources/jni_library_path.sh.template new file mode 100644 index 0000000..f2ccd76 --- /dev/null +++ b/ament_java_resources/jni_library_path.sh.template @@ -0,0 +1,14 @@ +# detect if running on Darwin platform +_UNAME=`uname -s` +_IS_DARWIN=0 +if [ "$_UNAME" = "Darwin" ]; then + _IS_DARWIN=1 +fi +unset _UNAME + +if [ $_IS_DARWIN -eq 0 ]; then + ament_prepend_unique_value LD_LIBRARY_PATH "$AMENT_CURRENT_PREFIX/lib/jni" +else + ament_prepend_unique_value DYLD_LIBRARY_PATH "$AMENT_CURRENT_PREFIX/lib/jni" +fi +unset _IS_DARWIN From c4eeb7fd71948a1a5ea472d5baa779575bf632b3 Mon Sep 17 00:00:00 2001 From: Esteve Fernandez Date: Sun, 1 Oct 2017 19:52:56 +0200 Subject: [PATCH 13/27] Copy files before building to keep the source space clean --- .../ament_build_type_gradle/__init__.py | 98 +++++++++++++------ ament_build_type_gradle/setup.py | 9 +- 2 files changed, 69 insertions(+), 38 deletions(-) diff --git a/ament_build_type_gradle/ament_build_type_gradle/__init__.py b/ament_build_type_gradle/ament_build_type_gradle/__init__.py index d53cbf5..78f7d74 100644 --- a/ament_build_type_gradle/ament_build_type_gradle/__init__.py +++ b/ament_build_type_gradle/ament_build_type_gradle/__init__.py @@ -19,6 +19,7 @@ import os import shutil +from distutils import dir_util from ament_build_type_gradle.templates import get_environment_hook_template_path @@ -40,29 +41,28 @@ class AmentGradleBuildType(BuildType): build_type = 'ament_gradle' description = "ament package built with Gradle" - def prepare_arguments(self, parser): - parser.add_argument( - '--ament-gradle-args', - nargs='*', - default=[], - help="Arbitrary arguments which are passed to 'ament_gradle' Gradle projects. " - "Argument collection can be terminated with '--'.") - - def argument_preprocessor(self, args): - # The ament CMake pass-through flag collects dashed options. - # This requires special handling or argparse will complain about - # unrecognized options. - args, gradle_args = extract_argument_group(args, '--ament-gradle-args') - extras = {'ament_gradle_args': gradle_args, } - return args, extras - - def ament_gradle_recursive_dependencies(self, context): + def _build_file_tree(self, start_path): + out_dirnames = set() + out_filenames = set() + for dirname, dirnames, filenames in os.walk(start_path): + for subdirname in dirnames: + out_dirnames.add( + os.path.relpath( + os.path.join(dirname, subdirname), start=start_path)) + + for filename in filenames: + out_filenames.add( + os.path.relpath( + os.path.join(dirname, filename), start=start_path)) + return (out_dirnames, out_filenames) + + def _ament_gradle_recursive_dependencies(self, context): for export in context.package_manifest.exports: if export.tagname == 'ament_gradle_recursive_dependencies': return True return False - def get_ament_args(self, context): + def _get_ament_args(self, context): cmd_args = [ '-Pament.build_space=' + context.build_space, '-Pament.install_space=' + context.install_space, @@ -72,19 +72,19 @@ def get_ament_args(self, context): '-Pament.exec_dependency_paths_in_workspace=' + ':'.join(context.exec_dependency_paths_in_workspace), '-Pament.gradle_recursive_dependencies=' + str( - self.ament_gradle_recursive_dependencies(context)), + self._ament_gradle_recursive_dependencies(context)), '-Pament.gradle_isolated=' + str(context.ament_gradle_isolated), ] return cmd_args - def get_gradle_wrapper(self, context): + def _get_gradle_wrapper(self, context): gradlew_script = 'gradlew.bat' if IS_WINDOWS else 'gradlew' gradlew_path = os.path.join(context.source_space, gradlew_script) if os.path.isfile(gradlew_path): return gradle_path - def get_gradle_executable(self, context): - gradlew_path = self.get_gradle_wrapper(context) + def _get_gradle_executable(self, context): + gradlew_path = self._get_gradle_wrapper(context) if gradlew_path: return gradlew_path @@ -99,11 +99,27 @@ def get_gradle_executable(self, context): return gradle_path raise VerbExecutionError("Could not find 'gradle' executable") - def prepare_cmd(self, context, gradle_task=None): - cmd_args = self.get_ament_args(context) + def prepare_arguments(self, parser): + parser.add_argument( + '--ament-gradle-args', + nargs='*', + default=[], + help="Arbitrary arguments which are passed to 'ament_gradle' Gradle projects. " + "Argument collection can be terminated with '--'.") + + def argument_preprocessor(self, args): + # The ament CMake pass-through flag collects dashed options. + # This requires special handling or argparse will complain about + # unrecognized options. + args, gradle_args = extract_argument_group(args, '--ament-gradle-args') + extras = {'ament_gradle_args': gradle_args, } + return args, extras + + def _prepare_cmd(self, context, gradle_task=None): + cmd_args = self._get_ament_args(context) cmd_args += context.ament_gradle_args - cmd = [self.get_gradle_executable(context)] + cmd = [self._get_gradle_executable(context)] cmd += cmd_args if gradle_task: cmd += [gradle_task] @@ -149,12 +165,32 @@ def on_build(self, context): expand_package_level_setup_files(context, [classpath_environment_hook], environment_hooks_path) + # remove anything that's on the destination tree but not in the source tree + src_package_src_dir = os.path.join(context.source_space, 'src') + dst_package_src_dir = os.path.join(context.build_space, 'src') + + src_dirnames, src_filenames = self._build_file_tree(src_package_src_dir) + dst_dirnames, dst_filenames = self._build_file_tree(dst_package_src_dir) + + prune_dirnames = dst_dirnames - src_dirnames + prune_filenames = dst_filenames - src_filenames + + for prune_filename in prune_filenames: + os.remove(os.path.join(dst_package_src_dir, prune_filename)) + for prune_dirname in prune_dirnames: + if os.path.exists(prune_dirname): + shutil.rmtree(os.path.join(dst_package_src_dir, prune_dirname)) + + # copy files from source_space to build_space to avoid poluting the latter + # during the build process + dir_util.copy_tree(context.source_space, context.build_space, update=1) + yield BuildAction( - self.prepare_cmd( - context, gradle_task='assemble'), cwd=context.source_space) + self._prepare_cmd( + context, gradle_task='assemble'), cwd=context.build_space) def on_test(self, context): - yield BuildAction(self.prepare_cmd(context, gradle_task='test'), cwd=context.source_space) + yield BuildAction(self._prepare_cmd(context, gradle_task='test'), cwd=context.build_space) def on_install(self, context): # deploy package manifest @@ -189,8 +225,8 @@ def on_install(self, context): os.path.join('share', context.package_manifest.name, name[:-3])) yield BuildAction( - self.prepare_cmd( - context, gradle_task='assemble'), cwd=context.source_space) + self._prepare_cmd( + context, gradle_task='assemble'), cwd=context.build_space) def on_uninstall(self, context): - yield BuildAction(self.prepare_cmd(context, gradle_task='clean'), cwd=context.source_space) + yield BuildAction(self._prepare_cmd(context, gradle_task='clean'), cwd=context.build_space) diff --git a/ament_build_type_gradle/setup.py b/ament_build_type_gradle/setup.py index a89eb3b..ae6415c 100644 --- a/ament_build_type_gradle/setup.py +++ b/ament_build_type_gradle/setup.py @@ -3,7 +3,6 @@ from setuptools import find_packages from setuptools import setup - setup( name='ament_build_type_gradle', version='0.0.0', @@ -24,10 +23,6 @@ license='Apache License, Version 2.0', test_suite='test', entry_points={ - 'ament.build_types': - ['ament_gradle = ament_build_type_gradle:AmentGradleBuildType', ], - }, - package_data={ - 'ament_build_type_gradle': ['template/environment_hook/*.in'] + 'ament.build_types': ['ament_gradle = ament_build_type_gradle:AmentGradleBuildType', ], }, - ) + package_data={'ament_build_type_gradle': ['template/environment_hook/*.in']}, ) From ad42502048568c6e528025c71f5fdd51434abf38 Mon Sep 17 00:00:00 2001 From: Esteve Fernandez Date: Sun, 29 Oct 2017 00:32:57 +0200 Subject: [PATCH 14/27] Added AMENT_PREFIX_PATH and PATH environment hooks --- .../ament_build_type_gradle/__init__.py | 34 ++++++++++++++++--- .../ament_build_type_gradle/templates.py | 2 +- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/ament_build_type_gradle/ament_build_type_gradle/__init__.py b/ament_build_type_gradle/ament_build_type_gradle/__init__.py index 78f7d74..2575923 100644 --- a/ament_build_type_gradle/ament_build_type_gradle/__init__.py +++ b/ament_build_type_gradle/ament_build_type_gradle/__init__.py @@ -21,7 +21,8 @@ import shutil from distutils import dir_util -from ament_build_type_gradle.templates import get_environment_hook_template_path +from ament_package.templates import get_environment_hook_template_path +from ament_build_type_gradle.templates import get_environment_hook_classpath_template_path from ament_package.templates import configure_string from ament_package.templates import get_package_level_template_names @@ -137,11 +138,18 @@ def extend_context(self, options): return ce def on_build(self, context): + environment_hooks_path = os.path.join('share', context.package_manifest.name, 'environment') + ext = '.sh' if not IS_WINDOWS else '.bat' - classpath_filename = 'classpath' + ext + # expand environment hook for AMENT_PREFIX_PATH + ament_prefix_path_environment_hook = os.path.join(environment_hooks_path, + 'ament_prefix_path' + ext) + # expand environment hook for PATH + path_environment_hook = os.path.join(environment_hooks_path, 'path' + ext) # expand environment hook for CLASSPATH - template = get_environment_hook_template_path() + classpath_filename = 'classpath' + ext + template = get_environment_hook_classpath_template_path() # If using the Gradle Ament Plugin, JAR files are installed into # $AMENT_CURRENT_PREFIX/share/$PROJECT_NAME/java/$PROJECT_NAME.jar @@ -150,7 +158,6 @@ def on_build(self, context): content = configure_string(template, {'_AMENT_EXPORT_JARS_CLASSPATH': classpath, }) - environment_hooks_path = os.path.join('share', context.package_manifest.name, 'environment') classpath_environment_hook = os.path.join(environment_hooks_path, os.path.basename(classpath_filename)) @@ -161,8 +168,14 @@ def on_build(self, context): with open(destination_path, 'w') as h: h.write(content) + environment_hooks = [ + ament_prefix_path_environment_hook, + classpath_environment_hook, + path_environment_hook, + ] + # expand package-level setup files - expand_package_level_setup_files(context, [classpath_environment_hook], + expand_package_level_setup_files(context, environment_hooks, environment_hooks_path) # remove anything that's on the destination tree but not in the source tree @@ -211,6 +224,17 @@ def on_install(self, context): pass ext = '.sh' if not IS_WINDOWS else '.bat' + # deploy AMENT_PREFIX_PATH environment hook + app_template_path = get_environment_hook_template_path('ament_prefix_path' + ext) + deploy_file( + context, os.path.dirname(app_template_path), os.path.basename(app_template_path), + dst_subfolder=os.path.join('share', context.package_manifest.name, 'environment')) + + # deploy PATH environment hook + path_template_path = get_environment_hook_template_path('path' + ext) + deploy_file( + context, os.path.dirname(path_template_path), os.path.basename(path_template_path), + dst_subfolder=os.path.join('share', context.package_manifest.name, 'environment')) # deploy CLASSPATH environment hook destination_file = 'classpath' + ('.sh' if not IS_WINDOWS else '.bat') diff --git a/ament_build_type_gradle/ament_build_type_gradle/templates.py b/ament_build_type_gradle/ament_build_type_gradle/templates.py index 0d12fae..07083ec 100644 --- a/ament_build_type_gradle/ament_build_type_gradle/templates.py +++ b/ament_build_type_gradle/ament_build_type_gradle/templates.py @@ -19,6 +19,6 @@ IS_WINDOWS = os.name == 'nt' -def get_environment_hook_template_path(): +def get_environment_hook_classpath_template_path(): ext = 'sh' if not IS_WINDOWS else 'bat' return get_resource('templates', 'ament_build_type_gradle_classpath_' + ext)[0] From e702b815fac9447d0883ed8feb9317e59104255e Mon Sep 17 00:00:00 2001 From: Esteve Fernandez Date: Sat, 4 Nov 2017 21:25:56 +0100 Subject: [PATCH 15/27] Pass ament.source_space to packages --- ament_build_type_gradle/ament_build_type_gradle/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/ament_build_type_gradle/ament_build_type_gradle/__init__.py b/ament_build_type_gradle/ament_build_type_gradle/__init__.py index 2575923..fbf8bb5 100644 --- a/ament_build_type_gradle/ament_build_type_gradle/__init__.py +++ b/ament_build_type_gradle/ament_build_type_gradle/__init__.py @@ -65,6 +65,7 @@ def _ament_gradle_recursive_dependencies(self, context): def _get_ament_args(self, context): cmd_args = [ + '-Pament.source_space=' + context.source_space, '-Pament.build_space=' + context.build_space, '-Pament.install_space=' + context.install_space, '-Pament.dependencies=' + ':'.join(context.build_dependencies), From 0aeeaf67864d0d2fe7165c06b9434bf756308f97 Mon Sep 17 00:00:00 2001 From: Duncan Calvert Date: Mon, 4 Jun 2018 11:49:48 -0500 Subject: [PATCH 16/27] Fix bug on Windows where for variable can be only one letter in length. --- ament_java_resources/classpath.bat.template | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ament_java_resources/classpath.bat.template b/ament_java_resources/classpath.bat.template index bd2506b..6dc448a 100644 --- a/ament_java_resources/classpath.bat.template +++ b/ament_java_resources/classpath.bat.template @@ -1,4 +1,5 @@ ament_prepend_unique_value CLASSPATH "." REM https://ss64.com/nt/for.html -FOR %%jarfile IN (@_AMENT_EXPORT_JARS_CLASSPATH@) DO ( - ament_prepend_unique_value CLASSPATH "%%jarfile") +FOR %%j IN (@_AMENT_EXPORT_JARS_CLASSPATH@) DO ( + ament_prepend_unique_value CLASSPATH "%%j" +) From 93061ecfc41e071b87acaf81c25a57d2c3b9ec52 Mon Sep 17 00:00:00 2001 From: Duncan Calvert Date: Fri, 20 Jul 2018 14:29:38 -0500 Subject: [PATCH 17/27] Set zip_safe to True. --- ament_build_type_gradle/setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/ament_build_type_gradle/setup.py b/ament_build_type_gradle/setup.py index ae6415c..3d8c803 100644 --- a/ament_build_type_gradle/setup.py +++ b/ament_build_type_gradle/setup.py @@ -8,6 +8,7 @@ version='0.0.0', packages=find_packages(exclude=['test']), install_requires=['ament-package', 'osrf_pycommon'], + zip_safe=True, author='Esteve Fernandez', author_email='esteve@apache.org', maintainer='Esteve Fernandez', From 9996be893b16939b6467574a23bedf67b45d41c0 Mon Sep 17 00:00:00 2001 From: Esteve Fernandez Date: Wed, 25 Jul 2018 22:29:20 +0200 Subject: [PATCH 18/27] Use uncrustify_vendor --- ament_java.repos | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ament_java.repos b/ament_java.repos index 3c8ca96..af967cb 100644 --- a/ament_java.repos +++ b/ament_java.repos @@ -31,9 +31,9 @@ repositories: type: git url: https://github.com/osrf/osrf_pycommon.git version: master - ament/uncrustify: + ament/uncrustify_vendor: type: git - url: https://github.com/ament/uncrustify.git + url: https://github.com/ament/uncrustify_vendor.git version: master ament_java/ament_java: type: git From 3918ad9ffff3aebbc51d95eea39133e376c975be Mon Sep 17 00:00:00 2001 From: Esteve Fernandez Date: Sat, 4 Aug 2018 20:50:28 +0200 Subject: [PATCH 19/27] Use win32-platform branch --- ament_java.repos | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ament_java.repos b/ament_java.repos index af967cb..5679568 100644 --- a/ament_java.repos +++ b/ament_java.repos @@ -17,8 +17,8 @@ repositories: version: master ament/ament_tools: type: git - url: https://github.com/ament/ament_tools.git - version: master + url: https://github.com/esteve/ament_tools.git + version: win32-platform ament/gmock_vendor: type: git url: https://github.com/ament/gmock_vendor.git From b05e4593a6d5d51639beaba72e6a0e9135b123ef Mon Sep 17 00:00:00 2001 From: Esteve Fernandez Date: Tue, 14 Aug 2018 16:56:02 +0000 Subject: [PATCH 20/27] Fix typo. Thanks @johnmarkwayve ! --- ament_build_type_gradle/ament_build_type_gradle/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ament_build_type_gradle/ament_build_type_gradle/__init__.py b/ament_build_type_gradle/ament_build_type_gradle/__init__.py index fbf8bb5..800ee81 100644 --- a/ament_build_type_gradle/ament_build_type_gradle/__init__.py +++ b/ament_build_type_gradle/ament_build_type_gradle/__init__.py @@ -83,7 +83,7 @@ def _get_gradle_wrapper(self, context): gradlew_script = 'gradlew.bat' if IS_WINDOWS else 'gradlew' gradlew_path = os.path.join(context.source_space, gradlew_script) if os.path.isfile(gradlew_path): - return gradle_path + return gradlew_path def _get_gradle_executable(self, context): gradlew_path = self._get_gradle_wrapper(context) From e6e23fbf54c2027999afa234474a4126175617cd Mon Sep 17 00:00:00 2001 From: Esteve Fernandez Date: Tue, 25 Sep 2018 13:07:36 +0200 Subject: [PATCH 21/27] Pin commit ids --- ament_java.repos | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/ament_java.repos b/ament_java.repos index 5679568..9498230 100644 --- a/ament_java.repos +++ b/ament_java.repos @@ -2,39 +2,35 @@ repositories: ament/ament_cmake: type: git url: https://github.com/ament/ament_cmake.git - version: master + version: 0.5.1 ament/ament_index: type: git url: https://github.com/ament/ament_index.git - version: master + version: 0.5.1 ament/ament_lint: type: git url: https://github.com/ament/ament_lint.git - version: master + version: 0.5.2 ament/ament_package: type: git url: https://github.com/ament/ament_package.git - version: master + version: 0.5.2 ament/ament_tools: type: git url: https://github.com/esteve/ament_tools.git version: win32-platform - ament/gmock_vendor: + ament/googletest: type: git - url: https://github.com/ament/gmock_vendor.git - version: master - ament/gtest_vendor: - type: git - url: https://github.com/ament/gtest_vendor.git - version: master + url: https://github.com/ament/googletest.git + version: 4b6e624e78ba3d43c1602ffc80478ee7253e0b04 ament/osrf_pycommon: type: git url: https://github.com/osrf/osrf_pycommon.git - version: master - ament/uncrustify_vendor: + version: 0.1.5 + ament/uncrustify: type: git - url: https://github.com/ament/uncrustify_vendor.git - version: master + url: https://github.com/ament/uncrustify.git + version: 0.66.1 ament_java/ament_java: type: git url: https://github.com/esteve/ament_java.git From b36a59bef4e81040f058c020adf57ce3271851a2 Mon Sep 17 00:00:00 2001 From: Jacob Perron Date: Wed, 16 Oct 2019 17:00:21 -0700 Subject: [PATCH 22/27] Add templates for .dsv files For more information about the introduction of .dsv files, see - https://github.com/colcon/colcon-core/pull/209 - https://github.com/ament/ament_package/pull/89 Signed-off-by: Jacob Perron --- ament_java_resources/CMakeLists.txt | 12 +++++++++++- ament_java_resources/classpath.dsv.template | 1 + ament_java_resources/jni_library_path.dsv.template | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 ament_java_resources/classpath.dsv.template create mode 100644 ament_java_resources/jni_library_path.dsv.template diff --git a/ament_java_resources/CMakeLists.txt b/ament_java_resources/CMakeLists.txt index a0bbf00..1eb5f90 100644 --- a/ament_java_resources/CMakeLists.txt +++ b/ament_java_resources/CMakeLists.txt @@ -9,6 +9,11 @@ ament_index_register_resource( CONTENT_FILE "classpath.sh.template" PACKAGE_NAME "ament_build_type_gradle_classpath_sh") +ament_index_register_resource( + "templates" + CONTENT_FILE "classpath.dsv.template" + PACKAGE_NAME "ament_build_type_gradle_classpath_dsv") + ament_index_register_resource( "templates" CONTENT_FILE "classpath.bat.template" @@ -23,5 +28,10 @@ ament_index_register_resource( "templates" CONTENT_FILE "jni_library_path.bat.template" PACKAGE_NAME "ament_build_type_gradle_jni_library_path_bat") - + +ament_index_register_resource( + "templates" + CONTENT_FILE "jni_library_path.dsv.template" + PACKAGE_NAME "ament_build_type_gradle_jni_library_path_dsv") + ament_package() diff --git a/ament_java_resources/classpath.dsv.template b/ament_java_resources/classpath.dsv.template new file mode 100644 index 0000000..428e14d --- /dev/null +++ b/ament_java_resources/classpath.dsv.template @@ -0,0 +1 @@ +prepend-non-duplicate;CLASSPATH;@_AMENT_EXPORT_JARS_CLASSPATH@ diff --git a/ament_java_resources/jni_library_path.dsv.template b/ament_java_resources/jni_library_path.dsv.template new file mode 100644 index 0000000..640bff5 --- /dev/null +++ b/ament_java_resources/jni_library_path.dsv.template @@ -0,0 +1 @@ +prepend-non-duplicate;@JNI_LIB_ENV_VAR@;lib/jni From dcb45ee6a240850591ffc8c37f422269326880f7 Mon Sep 17 00:00:00 2001 From: Jacob Perron Date: Tue, 7 Apr 2020 21:05:43 +0000 Subject: [PATCH 23/27] Drop old sh/bat templates Signed-off-by: Jacob Perron --- ament_java_resources/CMakeLists.txt | 20 -------------- ament_java_resources/classpath.bat.template | 5 ---- ament_java_resources/classpath.sh.template | 27 ------------------- .../jni_library_path.bat.template | 1 - .../jni_library_path.sh.template | 14 ---------- 5 files changed, 67 deletions(-) delete mode 100644 ament_java_resources/classpath.bat.template delete mode 100644 ament_java_resources/classpath.sh.template delete mode 100644 ament_java_resources/jni_library_path.bat.template delete mode 100644 ament_java_resources/jni_library_path.sh.template diff --git a/ament_java_resources/CMakeLists.txt b/ament_java_resources/CMakeLists.txt index 1eb5f90..fab14ab 100644 --- a/ament_java_resources/CMakeLists.txt +++ b/ament_java_resources/CMakeLists.txt @@ -4,31 +4,11 @@ project(ament_java_resources NONE) find_package(ament_cmake REQUIRED) -ament_index_register_resource( - "templates" - CONTENT_FILE "classpath.sh.template" - PACKAGE_NAME "ament_build_type_gradle_classpath_sh") - ament_index_register_resource( "templates" CONTENT_FILE "classpath.dsv.template" PACKAGE_NAME "ament_build_type_gradle_classpath_dsv") -ament_index_register_resource( - "templates" - CONTENT_FILE "classpath.bat.template" - PACKAGE_NAME "ament_build_type_gradle_classpath_bat") - -ament_index_register_resource( - "templates" - CONTENT_FILE "jni_library_path.sh.template" - PACKAGE_NAME "ament_build_type_gradle_jni_library_path_sh") - -ament_index_register_resource( - "templates" - CONTENT_FILE "jni_library_path.bat.template" - PACKAGE_NAME "ament_build_type_gradle_jni_library_path_bat") - ament_index_register_resource( "templates" CONTENT_FILE "jni_library_path.dsv.template" diff --git a/ament_java_resources/classpath.bat.template b/ament_java_resources/classpath.bat.template deleted file mode 100644 index 6dc448a..0000000 --- a/ament_java_resources/classpath.bat.template +++ /dev/null @@ -1,5 +0,0 @@ -ament_prepend_unique_value CLASSPATH "." -REM https://ss64.com/nt/for.html -FOR %%j IN (@_AMENT_EXPORT_JARS_CLASSPATH@) DO ( - ament_prepend_unique_value CLASSPATH "%%j" -) diff --git a/ament_java_resources/classpath.sh.template b/ament_java_resources/classpath.sh.template deleted file mode 100644 index fc8ace3..0000000 --- a/ament_java_resources/classpath.sh.template +++ /dev/null @@ -1,27 +0,0 @@ -if [ -n "$ZSH_VERSION" ]; then - if [[ $options[shwordsplit] = off ]]; then - _AMENT_JAVA_SH_WORD_SPLIT=1 - setopt shwordsplit - fi -fi - -ament_prepend_unique_value CLASSPATH "." -_AMENT_JAVA_IFS=$IFS -IFS=";" -jars="@_AMENT_EXPORT_JARS_CLASSPATH@" - -for jar in $jars -do - ament_prepend_unique_value CLASSPATH "$jar" -done - -IFS=$_AMENT_JAVA_IFS - -unset jar -unset jars -unset AMENT_JAVA_IFS - -if [ -n "$_AMENT_JAVA_SH_WORD_SPLIT" ]; then - unsetopt shwordsplit - unset _AMENT_JAVA_SH_WORD_SPLIT -fi diff --git a/ament_java_resources/jni_library_path.bat.template b/ament_java_resources/jni_library_path.bat.template deleted file mode 100644 index f759d3a..0000000 --- a/ament_java_resources/jni_library_path.bat.template +++ /dev/null @@ -1 +0,0 @@ -ament_prepend_unique_value PATH "%AMENT_CURRENT_PREFIX%\lib\jni" diff --git a/ament_java_resources/jni_library_path.sh.template b/ament_java_resources/jni_library_path.sh.template deleted file mode 100644 index f2ccd76..0000000 --- a/ament_java_resources/jni_library_path.sh.template +++ /dev/null @@ -1,14 +0,0 @@ -# detect if running on Darwin platform -_UNAME=`uname -s` -_IS_DARWIN=0 -if [ "$_UNAME" = "Darwin" ]; then - _IS_DARWIN=1 -fi -unset _UNAME - -if [ $_IS_DARWIN -eq 0 ]; then - ament_prepend_unique_value LD_LIBRARY_PATH "$AMENT_CURRENT_PREFIX/lib/jni" -else - ament_prepend_unique_value DYLD_LIBRARY_PATH "$AMENT_CURRENT_PREFIX/lib/jni" -fi -unset _IS_DARWIN From 5ac4c71f4d9d56a1809e11c717198fed190596b7 Mon Sep 17 00:00:00 2001 From: Esteve Fernandez Date: Sat, 9 May 2020 11:47:24 +0200 Subject: [PATCH 24/27] Revert "Add templates for .dsv files" --- ament_java_resources/CMakeLists.txt | 18 ++++++++++--- ament_java_resources/classpath.bat.template | 5 ++++ ament_java_resources/classpath.dsv.template | 1 - ament_java_resources/classpath.sh.template | 27 +++++++++++++++++++ .../jni_library_path.bat.template | 1 + .../jni_library_path.dsv.template | 1 - .../jni_library_path.sh.template | 14 ++++++++++ 7 files changed, 61 insertions(+), 6 deletions(-) create mode 100644 ament_java_resources/classpath.bat.template delete mode 100644 ament_java_resources/classpath.dsv.template create mode 100644 ament_java_resources/classpath.sh.template create mode 100644 ament_java_resources/jni_library_path.bat.template delete mode 100644 ament_java_resources/jni_library_path.dsv.template create mode 100644 ament_java_resources/jni_library_path.sh.template diff --git a/ament_java_resources/CMakeLists.txt b/ament_java_resources/CMakeLists.txt index fab14ab..a0bbf00 100644 --- a/ament_java_resources/CMakeLists.txt +++ b/ament_java_resources/CMakeLists.txt @@ -6,12 +6,22 @@ find_package(ament_cmake REQUIRED) ament_index_register_resource( "templates" - CONTENT_FILE "classpath.dsv.template" - PACKAGE_NAME "ament_build_type_gradle_classpath_dsv") + CONTENT_FILE "classpath.sh.template" + PACKAGE_NAME "ament_build_type_gradle_classpath_sh") ament_index_register_resource( "templates" - CONTENT_FILE "jni_library_path.dsv.template" - PACKAGE_NAME "ament_build_type_gradle_jni_library_path_dsv") + CONTENT_FILE "classpath.bat.template" + PACKAGE_NAME "ament_build_type_gradle_classpath_bat") +ament_index_register_resource( + "templates" + CONTENT_FILE "jni_library_path.sh.template" + PACKAGE_NAME "ament_build_type_gradle_jni_library_path_sh") + +ament_index_register_resource( + "templates" + CONTENT_FILE "jni_library_path.bat.template" + PACKAGE_NAME "ament_build_type_gradle_jni_library_path_bat") + ament_package() diff --git a/ament_java_resources/classpath.bat.template b/ament_java_resources/classpath.bat.template new file mode 100644 index 0000000..6dc448a --- /dev/null +++ b/ament_java_resources/classpath.bat.template @@ -0,0 +1,5 @@ +ament_prepend_unique_value CLASSPATH "." +REM https://ss64.com/nt/for.html +FOR %%j IN (@_AMENT_EXPORT_JARS_CLASSPATH@) DO ( + ament_prepend_unique_value CLASSPATH "%%j" +) diff --git a/ament_java_resources/classpath.dsv.template b/ament_java_resources/classpath.dsv.template deleted file mode 100644 index 428e14d..0000000 --- a/ament_java_resources/classpath.dsv.template +++ /dev/null @@ -1 +0,0 @@ -prepend-non-duplicate;CLASSPATH;@_AMENT_EXPORT_JARS_CLASSPATH@ diff --git a/ament_java_resources/classpath.sh.template b/ament_java_resources/classpath.sh.template new file mode 100644 index 0000000..fc8ace3 --- /dev/null +++ b/ament_java_resources/classpath.sh.template @@ -0,0 +1,27 @@ +if [ -n "$ZSH_VERSION" ]; then + if [[ $options[shwordsplit] = off ]]; then + _AMENT_JAVA_SH_WORD_SPLIT=1 + setopt shwordsplit + fi +fi + +ament_prepend_unique_value CLASSPATH "." +_AMENT_JAVA_IFS=$IFS +IFS=";" +jars="@_AMENT_EXPORT_JARS_CLASSPATH@" + +for jar in $jars +do + ament_prepend_unique_value CLASSPATH "$jar" +done + +IFS=$_AMENT_JAVA_IFS + +unset jar +unset jars +unset AMENT_JAVA_IFS + +if [ -n "$_AMENT_JAVA_SH_WORD_SPLIT" ]; then + unsetopt shwordsplit + unset _AMENT_JAVA_SH_WORD_SPLIT +fi diff --git a/ament_java_resources/jni_library_path.bat.template b/ament_java_resources/jni_library_path.bat.template new file mode 100644 index 0000000..f759d3a --- /dev/null +++ b/ament_java_resources/jni_library_path.bat.template @@ -0,0 +1 @@ +ament_prepend_unique_value PATH "%AMENT_CURRENT_PREFIX%\lib\jni" diff --git a/ament_java_resources/jni_library_path.dsv.template b/ament_java_resources/jni_library_path.dsv.template deleted file mode 100644 index 640bff5..0000000 --- a/ament_java_resources/jni_library_path.dsv.template +++ /dev/null @@ -1 +0,0 @@ -prepend-non-duplicate;@JNI_LIB_ENV_VAR@;lib/jni diff --git a/ament_java_resources/jni_library_path.sh.template b/ament_java_resources/jni_library_path.sh.template new file mode 100644 index 0000000..f2ccd76 --- /dev/null +++ b/ament_java_resources/jni_library_path.sh.template @@ -0,0 +1,14 @@ +# detect if running on Darwin platform +_UNAME=`uname -s` +_IS_DARWIN=0 +if [ "$_UNAME" = "Darwin" ]; then + _IS_DARWIN=1 +fi +unset _UNAME + +if [ $_IS_DARWIN -eq 0 ]; then + ament_prepend_unique_value LD_LIBRARY_PATH "$AMENT_CURRENT_PREFIX/lib/jni" +else + ament_prepend_unique_value DYLD_LIBRARY_PATH "$AMENT_CURRENT_PREFIX/lib/jni" +fi +unset _IS_DARWIN From 61239ce260f598437adab767a729743fc56629b8 Mon Sep 17 00:00:00 2001 From: Jacob Perron Date: Thu, 17 Jun 2021 07:38:47 -0700 Subject: [PATCH 25/27] Revert "Revert "Add templates for .dsv files"" (#15) This reverts commit 5ac4c71f4d9d56a1809e11c717198fed190596b7. --- ament_java_resources/CMakeLists.txt | 18 +++---------- ament_java_resources/classpath.bat.template | 5 ---- ament_java_resources/classpath.dsv.template | 1 + ament_java_resources/classpath.sh.template | 27 ------------------- .../jni_library_path.bat.template | 1 - .../jni_library_path.dsv.template | 1 + .../jni_library_path.sh.template | 14 ---------- 7 files changed, 6 insertions(+), 61 deletions(-) delete mode 100644 ament_java_resources/classpath.bat.template create mode 100644 ament_java_resources/classpath.dsv.template delete mode 100644 ament_java_resources/classpath.sh.template delete mode 100644 ament_java_resources/jni_library_path.bat.template create mode 100644 ament_java_resources/jni_library_path.dsv.template delete mode 100644 ament_java_resources/jni_library_path.sh.template diff --git a/ament_java_resources/CMakeLists.txt b/ament_java_resources/CMakeLists.txt index a0bbf00..fab14ab 100644 --- a/ament_java_resources/CMakeLists.txt +++ b/ament_java_resources/CMakeLists.txt @@ -6,22 +6,12 @@ find_package(ament_cmake REQUIRED) ament_index_register_resource( "templates" - CONTENT_FILE "classpath.sh.template" - PACKAGE_NAME "ament_build_type_gradle_classpath_sh") + CONTENT_FILE "classpath.dsv.template" + PACKAGE_NAME "ament_build_type_gradle_classpath_dsv") ament_index_register_resource( "templates" - CONTENT_FILE "classpath.bat.template" - PACKAGE_NAME "ament_build_type_gradle_classpath_bat") + CONTENT_FILE "jni_library_path.dsv.template" + PACKAGE_NAME "ament_build_type_gradle_jni_library_path_dsv") -ament_index_register_resource( - "templates" - CONTENT_FILE "jni_library_path.sh.template" - PACKAGE_NAME "ament_build_type_gradle_jni_library_path_sh") - -ament_index_register_resource( - "templates" - CONTENT_FILE "jni_library_path.bat.template" - PACKAGE_NAME "ament_build_type_gradle_jni_library_path_bat") - ament_package() diff --git a/ament_java_resources/classpath.bat.template b/ament_java_resources/classpath.bat.template deleted file mode 100644 index 6dc448a..0000000 --- a/ament_java_resources/classpath.bat.template +++ /dev/null @@ -1,5 +0,0 @@ -ament_prepend_unique_value CLASSPATH "." -REM https://ss64.com/nt/for.html -FOR %%j IN (@_AMENT_EXPORT_JARS_CLASSPATH@) DO ( - ament_prepend_unique_value CLASSPATH "%%j" -) diff --git a/ament_java_resources/classpath.dsv.template b/ament_java_resources/classpath.dsv.template new file mode 100644 index 0000000..428e14d --- /dev/null +++ b/ament_java_resources/classpath.dsv.template @@ -0,0 +1 @@ +prepend-non-duplicate;CLASSPATH;@_AMENT_EXPORT_JARS_CLASSPATH@ diff --git a/ament_java_resources/classpath.sh.template b/ament_java_resources/classpath.sh.template deleted file mode 100644 index fc8ace3..0000000 --- a/ament_java_resources/classpath.sh.template +++ /dev/null @@ -1,27 +0,0 @@ -if [ -n "$ZSH_VERSION" ]; then - if [[ $options[shwordsplit] = off ]]; then - _AMENT_JAVA_SH_WORD_SPLIT=1 - setopt shwordsplit - fi -fi - -ament_prepend_unique_value CLASSPATH "." -_AMENT_JAVA_IFS=$IFS -IFS=";" -jars="@_AMENT_EXPORT_JARS_CLASSPATH@" - -for jar in $jars -do - ament_prepend_unique_value CLASSPATH "$jar" -done - -IFS=$_AMENT_JAVA_IFS - -unset jar -unset jars -unset AMENT_JAVA_IFS - -if [ -n "$_AMENT_JAVA_SH_WORD_SPLIT" ]; then - unsetopt shwordsplit - unset _AMENT_JAVA_SH_WORD_SPLIT -fi diff --git a/ament_java_resources/jni_library_path.bat.template b/ament_java_resources/jni_library_path.bat.template deleted file mode 100644 index f759d3a..0000000 --- a/ament_java_resources/jni_library_path.bat.template +++ /dev/null @@ -1 +0,0 @@ -ament_prepend_unique_value PATH "%AMENT_CURRENT_PREFIX%\lib\jni" diff --git a/ament_java_resources/jni_library_path.dsv.template b/ament_java_resources/jni_library_path.dsv.template new file mode 100644 index 0000000..640bff5 --- /dev/null +++ b/ament_java_resources/jni_library_path.dsv.template @@ -0,0 +1 @@ +prepend-non-duplicate;@JNI_LIB_ENV_VAR@;lib/jni diff --git a/ament_java_resources/jni_library_path.sh.template b/ament_java_resources/jni_library_path.sh.template deleted file mode 100644 index f2ccd76..0000000 --- a/ament_java_resources/jni_library_path.sh.template +++ /dev/null @@ -1,14 +0,0 @@ -# detect if running on Darwin platform -_UNAME=`uname -s` -_IS_DARWIN=0 -if [ "$_UNAME" = "Darwin" ]; then - _IS_DARWIN=1 -fi -unset _UNAME - -if [ $_IS_DARWIN -eq 0 ]; then - ament_prepend_unique_value LD_LIBRARY_PATH "$AMENT_CURRENT_PREFIX/lib/jni" -else - ament_prepend_unique_value DYLD_LIBRARY_PATH "$AMENT_CURRENT_PREFIX/lib/jni" -fi -unset _IS_DARWIN From 6fd444c282f123b50878ba4bf63b8cca5b159fcc Mon Sep 17 00:00:00 2001 From: Ivan Santiago Paunovic Date: Tue, 22 Jun 2021 17:59:05 -0300 Subject: [PATCH 26/27] [ament_build_type_gradle] Install package marker and package.xml (#16) Signed-off-by: Ivan Santiago Paunovic --- .../resource/ament_build_type_gradle | 0 ament_build_type_gradle/setup.py | 13 ++++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 ament_build_type_gradle/resource/ament_build_type_gradle diff --git a/ament_build_type_gradle/resource/ament_build_type_gradle b/ament_build_type_gradle/resource/ament_build_type_gradle new file mode 100644 index 0000000..e69de29 diff --git a/ament_build_type_gradle/setup.py b/ament_build_type_gradle/setup.py index 3d8c803..b20dec2 100644 --- a/ament_build_type_gradle/setup.py +++ b/ament_build_type_gradle/setup.py @@ -3,10 +3,17 @@ from setuptools import find_packages from setuptools import setup +package_name = 'ament_build_type_gradle' + setup( - name='ament_build_type_gradle', + name=package_name, version='0.0.0', packages=find_packages(exclude=['test']), + data_files=[ + ('share/' + package_name, ['package.xml']), + ('share/ament_index/resource_index/packages', + ['resource/' + package_name]), + ], install_requires=['ament-package', 'osrf_pycommon'], zip_safe=True, author='Esteve Fernandez', @@ -24,6 +31,6 @@ license='Apache License, Version 2.0', test_suite='test', entry_points={ - 'ament.build_types': ['ament_gradle = ament_build_type_gradle:AmentGradleBuildType', ], + 'ament.build_types': [f'ament_gradle = {package_name}:AmentGradleBuildType', ], }, - package_data={'ament_build_type_gradle': ['template/environment_hook/*.in']}, ) + package_data={f'{package_name}': ['template/environment_hook/*.in']}, ) From c430324f0e8aa12106e67799795994b8aede10a9 Mon Sep 17 00:00:00 2001 From: Jacob Perron Date: Fri, 13 May 2022 11:28:18 -0700 Subject: [PATCH 27/27] Remove unused test dependency declarations (#17) When following install instructions for ros2-java, rosdep cannot resolve 'ament_pep8'. Since we are not actually running any tests for this package, remove all test dependency declarations. Signed-off-by: Jacob Perron --- ament_build_type_gradle/package.xml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/ament_build_type_gradle/package.xml b/ament_build_type_gradle/package.xml index c6fd0bd..044789f 100644 --- a/ament_build_type_gradle/package.xml +++ b/ament_build_type_gradle/package.xml @@ -13,11 +13,6 @@ ament_java_resources ament_java_resources - ament_copyright - ament_pep257 - ament_pep8 - ament_pyflakes - ament_python