[Documentation] [TitleIndex] [WordIndex

Repository Structure

The most practical/optimal way to structure your code that we've found is in the following manner:

1 repository = 1 catkin package = 1 multi-project gradle build

All of the repositories in the github rosjava organisation are structured in this way. Note that this is slightly different to usual ros repository structures, e.g.:

Ros

Rosjava

Catkin Stack

Catkin Package/Gradle Multi-project

Catkin Package

Gradle Subproject

Since gradle builds whole repositories (multi-projects) in one hit, and catkin is relaying builds from cmake -> gradle, then this is the easiest way to avoid alot of repetitive relay calls to gradle (wastes time) and almost redundant package.xml information spread through each subproject.

Internals

Consider a hypothetical repository called rosjava_foo:

+ rosjava_foo
 - package.xml
 - CMakeLists.txt
 - build.gradle
 - settings.gradle
 - gradlew
 + projectA
   - build.gradle
   + src/main/java
   + src/main/tests 
 + projectB
   - build.gradle
   + src/main/java
   + src/main/tests 

Package Xml

<?xml version="1.0"?>
<package>
  <name>rosjava_foo</name>
  <version>0.1.0</version>
  <description>
    An implementation of rosjava foo.
  </description>
  <url>http://ros.org/wiki/rosjava_foo</url>
  <maintainer email="foo@ros.org">Foo</maintainer>
  <author email="bar@ros.org">Bar</author>
  <license>Apache 2.0</license>

  <buildtool_depend>catkin</buildtool_depend>
  <build_depend>rosjava_build_tools</build_depend>
  <build_depend>rosjava_bootstrap</build_depend>
  <build_depend>rosjava_messages</build_depend>
  <run_depend>rosjava_build_tools</run_depend>
  <run_depend>rosjava_bootstrap</run_depend>
  <run_depend>rosjava_messages</run_depend>
</package>

Important points:

CMakeLists

cmake_minimum_required(VERSION 2.8.3)
project(rosjava_core)

find_package(catkin REQUIRED rosjava_build_tools)
catkin_rosjava_setup(publishMavenJavaPublicationToMavenRepository)
catkin_package()

install(DIRECTORY ${CATKIN_DEVEL_PREFIX}/${CATKIN_GLOBAL_MAVEN_DESTINATION}/org/ros/rosjava_core/ 
        DESTINATION ${CATKIN_GLOBAL_MAVEN_DESTINATION}/org/ros/rosjava_core)

This is very light - it has just enough information to relay the gradle builds and provide installation information so that rosjava debs can be rolled. The catkin_rosjava_setup macro is special - any gradle target can be used here, even multiple targets if you wish. The specified target enables deployment of artifacts (.jar's) into the local workspace (under devel/share/maven and install/share/maven by default.

Project Gradle Files

These are changing, but stabilising now. To get a good idea of what is contained in these files, check any of the repos in the rosjava organisation.

settings.gradle

TODO

build.gradle

TODO

SubProject Gradle Files

build.gradle

TODO


2024-04-13 13:05