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
+
+