|Note: This tutorial assumes that you have completed the previous tutorials: Anatomy of a RosJava Package, Creating Rosjava Packages.|
|Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags.|
To Build with Catkin or GradleDescription: Explains when to use catkin_make and when to use the gradle wrapper.
Tutorial Level: BEGINNER
This tutorial provides some information on the different build methods for rosjava packages - these are catkin_make and the gradle wrapper.
A typical workspace will look like (refer to anatomy of a rosjava package for more details):
/src /rosjava_catkin_package_a /rosjava_gradle_subproject_a /rosjava_gradle_subproject_b /rosjava_gradle_subproject_c /rosjava_catkin_package_b /rosjava_gradle_subproject_d /rosjava_gradle_subproject_e /rosjava_gradle_subproject_f
The best way of understanding the usefulness of both build commands is to understand their scope. In the above workspace, catkin_make has scope across the whole workspace - it is responsible for linking and sequencing each catkin package/gradle (super)project. The gradle wrapper on the other hand only has scope within a single catkin package.
When to Use Catkin Make
Catkin make is useful in the following situations:
- A first build of your entire workspace since it creates the setup.bash and is a one-shot way of building the entire workspace.
- Continuous integration builds.
If we didn't have catkin packages linking the gradle projects, you'd need to compile each by hand, one by one, or have a bash script to do so for you.
When to Use the Gradle Wrapper
You can use catkin_make exclusively, but that can be annoyingly slow as it's running through the entire workspace. Just as for c++ catkin builds (where you use make), you can drop down a level and directly use the gradle wrapper to compile single gradle projects, or even subprojects.
Compiling a binary app subproject:
> source devel/setup.bash > cd src/rosjava_catkin_package_a/my_pub_sub_tutorial > ../gradlew installApp
Compiling a library subproject:
> source devel/setup.bash > cd src/rosjava_catkin_package_a/my_java_library > ../gradlew publishMavenJavaPublicationToMavenRepository