ros2-java / ros2_java

Java and Android bindings for ROS2
Apache License 2.0
173 stars 93 forks source link

How to build a java project outside ros2_java folder #238

Open sanke69 opened 7 months ago

sanke69 commented 7 months ago

Hello,

My question is quite simple but I don't figure out how to do, I get no issue to compile ros2_java by running procedure described in this repository

cd /src/ros2_java_ws
source /opt/ros/${ROS_DISTRO}/setup.bash \ 
    && curl -skL https://raw.githubusercontent.com/ros2-java/ros2_java/main/ros2_java_desktop.repos -o ros2_java_desktop.repos \
    && vcs import src < ros2_java_desktop.repos \
    && rosdep install --from-paths src -y -i --skip-keys "ament_tools" \
    && colcon build

All examples work fine but just if I try to build them outside the ros2_java_ws, it failed

mkdir -p /src/test/src
cp -r /src/ros2_java_ws/src/ros2-java/ros2_java_examples/ /src/test/src
cd /src/test
source /opt/ros/${ROS_DISTRO}/setup.bash
source /src/ros2_java_ws/install/setup.bash
colcon build --event-handlers console_cohesion+

with

[...]/SubscriberMemberFunction.java:18: error: cannot find symbol
import org.ros2.rcljava.RCLJava;

If someone have the solution, which must not be so complicated as everything work fine in the ros2_java_ws, it will be greatly appreciated :)

My environment: Ubuntu 22.04 ROS2 Humble JAVA 11 Gradle 6.0

And the full log of colcon build

Starting >>> rcljava_examples
--- output: rcljava_examples                         
Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reused, use --status for details

> Task :compileJava FAILED
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/subscriber/SubscriberMemberFunction.java:18: error: cannot find symbol
import org.ros2.rcljava.RCLJava;
                       ^
  symbol:   class RCLJava
  location: package org.ros2.rcljava
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/subscriber/SubscriberMemberFunction.java:19: error: package org.ros2.rcljava.consumers does not exist
import org.ros2.rcljava.consumers.Consumer;
                                 ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/subscriber/SubscriberMemberFunction.java:20: error: package org.ros2.rcljava.node does not exist
import org.ros2.rcljava.node.BaseComposableNode;
                            ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/subscriber/SubscriberMemberFunction.java:21: error: package org.ros2.rcljava.subscription does not exist
import org.ros2.rcljava.subscription.Subscription;
                                    ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/subscriber/SubscriberMemberFunction.java:23: error: cannot find symbol
public class SubscriberMemberFunction extends BaseComposableNode {
                                              ^
  symbol: class BaseComposableNode
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/subscriber/SubscriberMemberFunction.java:24: error: cannot find symbol
  private Subscription<std_msgs.msg.String> subscription;
          ^
  symbol:   class Subscription
  location: class SubscriberMemberFunction
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/subscriber/SubscriberMemberFunction.java:24: error: package std_msgs.msg does not exist
  private Subscription<std_msgs.msg.String> subscription;
                                   ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/subscriber/SubscriberMemberFunction.java:32: error: package std_msgs.msg does not exist
  private void topicCallback(final std_msgs.msg.String msg) {
                                               ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/subscriber/SubscriberNotComposable.java:18: error: cannot find symbol
import org.ros2.rcljava.RCLJava;
                       ^
  symbol:   class RCLJava
  location: package org.ros2.rcljava
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/subscriber/SubscriberNotComposable.java:19: error: package org.ros2.rcljava.consumers does not exist
import org.ros2.rcljava.consumers.Consumer;
                                 ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/subscriber/SubscriberNotComposable.java:20: error: package org.ros2.rcljava.node does not exist
import org.ros2.rcljava.node.Node;
                            ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/subscriber/SubscriberNotComposable.java:21: error: package org.ros2.rcljava.subscription does not exist
import org.ros2.rcljava.subscription.Subscription;
                                    ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/subscriber/SubscriberNotComposable.java:24: error: package std_msgs.msg does not exist
  public static void topicCallback(final std_msgs.msg.String msg) {
                                                     ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/subscriber/SubscriberLambda.java:18: error: cannot find symbol
import org.ros2.rcljava.RCLJava;
                       ^
  symbol:   class RCLJava
  location: package org.ros2.rcljava
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/subscriber/SubscriberLambda.java:19: error: package org.ros2.rcljava.consumers does not exist
import org.ros2.rcljava.consumers.Consumer;
                                 ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/subscriber/SubscriberLambda.java:20: error: package org.ros2.rcljava.node does not exist
import org.ros2.rcljava.node.BaseComposableNode;
                            ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/subscriber/SubscriberLambda.java:21: error: package org.ros2.rcljava.subscription does not exist
import org.ros2.rcljava.subscription.Subscription;
                                    ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/subscriber/SubscriberLambda.java:23: error: cannot find symbol
public class SubscriberLambda extends BaseComposableNode {
                                      ^
  symbol: class BaseComposableNode
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/subscriber/SubscriberLambda.java:24: error: cannot find symbol
  private Subscription<std_msgs.msg.String> subscription;
          ^
  symbol:   class Subscription
  location: class SubscriberLambda
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/subscriber/SubscriberLambda.java:24: error: package std_msgs.msg does not exist
  private Subscription<std_msgs.msg.String> subscription;
                                   ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/service/AddTwoIntsService.java:18: error: cannot find symbol
import org.ros2.rcljava.RCLJava;
                       ^
  symbol:   class RCLJava
  location: package org.ros2.rcljava
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/service/AddTwoIntsService.java:19: error: package org.ros2.rcljava.consumers does not exist
import org.ros2.rcljava.consumers.TriConsumer;
                                 ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/service/AddTwoIntsService.java:20: error: package org.ros2.rcljava.node does not exist
import org.ros2.rcljava.node.Node;
                            ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/service/AddTwoIntsService.java:21: error: package org.ros2.rcljava.service does not exist
import org.ros2.rcljava.service.RMWRequestId;
                               ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/service/AddTwoIntsService.java:22: error: package org.ros2.rcljava.service does not exist
import org.ros2.rcljava.service.Service;
                               ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/service/AddTwoIntsService.java:25: error: cannot find symbol
  public static void handleService(final RMWRequestId header,
                                         ^
  symbol:   class RMWRequestId
  location: class AddTwoIntsService
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/service/AddTwoIntsService.java:26: error: package example_interfaces.srv does not exist
      final example_interfaces.srv.AddTwoInts_Request request,
                                  ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/service/AddTwoIntsService.java:27: error: package example_interfaces.srv does not exist
      final example_interfaces.srv.AddTwoInts_Response response) {
                                  ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/composition/Composed.java:18: error: cannot find symbol
import org.ros2.rcljava.RCLJava;
                       ^
  symbol:   class RCLJava
  location: package org.ros2.rcljava
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/composition/Composed.java:19: error: package org.ros2.rcljava.executors does not exist
import org.ros2.rcljava.executors.SingleThreadedExecutor;
                                 ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/composition/Composed.java:20: error: package org.ros2.rcljava.executors does not exist
import org.ros2.rcljava.executors.MultiThreadedExecutor;
                                 ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/composition/PublisherNode.java:20: error: cannot find symbol
import org.ros2.rcljava.RCLJava;
                       ^
  symbol:   class RCLJava
  location: package org.ros2.rcljava
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/composition/PublisherNode.java:21: error: package org.ros2.rcljava.node does not exist
import org.ros2.rcljava.node.BaseComposableNode;
                            ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/composition/PublisherNode.java:22: error: package org.ros2.rcljava.publisher does not exist
import org.ros2.rcljava.publisher.Publisher;
                                 ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/composition/PublisherNode.java:23: error: package org.ros2.rcljava.timer does not exist
import org.ros2.rcljava.timer.WallTimer;
                             ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/composition/PublisherNode.java:25: error: cannot find symbol
public class PublisherNode extends BaseComposableNode {
                                   ^
  symbol: class BaseComposableNode
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/composition/PublisherNode.java:26: error: cannot find symbol
  private Publisher<std_msgs.msg.String> publisher;
          ^
  symbol:   class Publisher
  location: class PublisherNode
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/composition/PublisherNode.java:26: error: package std_msgs.msg does not exist
  private Publisher<std_msgs.msg.String> publisher;
                                ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/composition/PublisherNode.java:28: error: cannot find symbol
  private WallTimer timer;
          ^
  symbol:   class WallTimer
  location: class PublisherNode
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/composition/SubscriberNode.java:18: error: cannot find symbol
import org.ros2.rcljava.RCLJava;
                       ^
  symbol:   class RCLJava
  location: package org.ros2.rcljava
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/composition/SubscriberNode.java:19: error: package org.ros2.rcljava.consumers does not exist
import org.ros2.rcljava.consumers.Consumer;
                                 ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/composition/SubscriberNode.java:20: error: package org.ros2.rcljava.node does not exist
import org.ros2.rcljava.node.BaseComposableNode;
                            ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/composition/SubscriberNode.java:21: error: package org.ros2.rcljava.subscription does not exist
import org.ros2.rcljava.subscription.Subscription;
                                    ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/composition/SubscriberNode.java:23: error: cannot find symbol
public class SubscriberNode extends BaseComposableNode {
                                    ^
  symbol: class BaseComposableNode
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/composition/SubscriberNode.java:24: error: cannot find symbol
  private Subscription<std_msgs.msg.String> subscription;
          ^
  symbol:   class Subscription
  location: class SubscriberNode
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/composition/SubscriberNode.java:24: error: package std_msgs.msg does not exist
  private Subscription<std_msgs.msg.String> subscription;
                                   ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/timer/TimerMemberFunction.java:20: error: cannot find symbol
import org.ros2.rcljava.RCLJava;
                       ^
  symbol:   class RCLJava
  location: package org.ros2.rcljava
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/timer/TimerMemberFunction.java:21: error: package org.ros2.rcljava.consumers does not exist
import org.ros2.rcljava.consumers.Consumer;
                                 ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/timer/TimerMemberFunction.java:22: error: package org.ros2.rcljava.node does not exist
import org.ros2.rcljava.node.BaseComposableNode;
                            ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/timer/TimerMemberFunction.java:23: error: package org.ros2.rcljava.subscription does not exist
import org.ros2.rcljava.subscription.Subscription;
                                    ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/timer/TimerMemberFunction.java:24: error: package org.ros2.rcljava.timer does not exist
import org.ros2.rcljava.timer.WallTimer;
                             ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/timer/TimerMemberFunction.java:26: error: cannot find symbol
public class TimerMemberFunction extends BaseComposableNode {
                                         ^
  symbol: class BaseComposableNode
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/timer/TimerMemberFunction.java:27: error: cannot find symbol
  private WallTimer timer;
          ^
  symbol:   class WallTimer
  location: class TimerMemberFunction
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/timer/TimerLambda.java:20: error: cannot find symbol
import org.ros2.rcljava.RCLJava;
                       ^
  symbol:   class RCLJava
  location: package org.ros2.rcljava
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/timer/TimerLambda.java:21: error: package org.ros2.rcljava.concurrent does not exist
import org.ros2.rcljava.concurrent.Callback;
                                  ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/timer/TimerLambda.java:22: error: package org.ros2.rcljava.node does not exist
import org.ros2.rcljava.node.BaseComposableNode;
                            ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/timer/TimerLambda.java:23: error: package org.ros2.rcljava.subscription does not exist
import org.ros2.rcljava.subscription.Subscription;
                                    ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/timer/TimerLambda.java:24: error: package org.ros2.rcljava.timer does not exist
import org.ros2.rcljava.timer.WallTimer;
                             ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/timer/TimerLambda.java:26: error: cannot find symbol
public class TimerLambda extends BaseComposableNode {
                                 ^
  symbol: class BaseComposableNode
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/timer/TimerLambda.java:27: error: cannot find symbol
  private WallTimer timer;
          ^
  symbol:   class WallTimer
  location: class TimerLambda
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/client/AddTwoIntsClient.java:18: error: cannot find symbol
import org.ros2.rcljava.RCLJava;
                       ^
  symbol:   class RCLJava
  location: package org.ros2.rcljava
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/client/AddTwoIntsClient.java:19: error: package org.ros2.rcljava.client does not exist
import org.ros2.rcljava.client.Client;
                              ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/client/AddTwoIntsClient.java:20: error: package org.ros2.rcljava.node does not exist
import org.ros2.rcljava.node.Node;
                            ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/publisher/PublisherNotComposable.java:20: error: cannot find symbol
import org.ros2.rcljava.RCLJava;
                       ^
  symbol:   class RCLJava
  location: package org.ros2.rcljava
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/publisher/PublisherNotComposable.java:21: error: package org.ros2.rcljava.concurrent does not exist
import org.ros2.rcljava.concurrent.Callback;
                                  ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/publisher/PublisherNotComposable.java:22: error: package org.ros2.rcljava.node does not exist
import org.ros2.rcljava.node.Node;
                            ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/publisher/PublisherNotComposable.java:23: error: package org.ros2.rcljava.publisher does not exist
import org.ros2.rcljava.publisher.Publisher;
                                 ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/publisher/PublisherNotComposable.java:24: error: package org.ros2.rcljava.timer does not exist
import org.ros2.rcljava.timer.WallTimer;
                             ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/publisher/PublisherMemberFunction.java:20: error: cannot find symbol
import org.ros2.rcljava.RCLJava;
                       ^
  symbol:   class RCLJava
  location: package org.ros2.rcljava
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/publisher/PublisherMemberFunction.java:21: error: package org.ros2.rcljava.concurrent does not exist
import org.ros2.rcljava.concurrent.Callback;
                                  ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/publisher/PublisherMemberFunction.java:22: error: package org.ros2.rcljava.node does not exist
import org.ros2.rcljava.node.BaseComposableNode;
                            ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/publisher/PublisherMemberFunction.java:23: error: package org.ros2.rcljava.publisher does not exist
import org.ros2.rcljava.publisher.Publisher;
                                 ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/publisher/PublisherMemberFunction.java:24: error: package org.ros2.rcljava.timer does not exist
import org.ros2.rcljava.timer.WallTimer;
                             ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/publisher/PublisherMemberFunction.java:26: error: cannot find symbol
public class PublisherMemberFunction extends BaseComposableNode {
                                             ^
  symbol: class BaseComposableNode
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/publisher/PublisherMemberFunction.java:29: error: cannot find symbol
  private Publisher<std_msgs.msg.String> publisher;
          ^
  symbol:   class Publisher
  location: class PublisherMemberFunction
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/publisher/PublisherMemberFunction.java:29: error: package std_msgs.msg does not exist
  private Publisher<std_msgs.msg.String> publisher;
                                ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/publisher/PublisherMemberFunction.java:31: error: cannot find symbol
  private WallTimer timer;
          ^
  symbol:   class WallTimer
  location: class PublisherMemberFunction
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/publisher/PublisherLambda.java:20: error: cannot find symbol
import org.ros2.rcljava.RCLJava;
                       ^
  symbol:   class RCLJava
  location: package org.ros2.rcljava
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/publisher/PublisherLambda.java:21: error: package org.ros2.rcljava.concurrent does not exist
import org.ros2.rcljava.concurrent.Callback;
                                  ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/publisher/PublisherLambda.java:22: error: package org.ros2.rcljava.node does not exist
import org.ros2.rcljava.node.BaseComposableNode;
                            ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/publisher/PublisherLambda.java:23: error: package org.ros2.rcljava.publisher does not exist
import org.ros2.rcljava.publisher.Publisher;
                                 ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/publisher/PublisherLambda.java:24: error: package org.ros2.rcljava.timer does not exist
import org.ros2.rcljava.timer.WallTimer;
                             ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/publisher/PublisherLambda.java:26: error: cannot find symbol
public class PublisherLambda extends BaseComposableNode {
                                     ^
  symbol: class BaseComposableNode
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/publisher/PublisherLambda.java:29: error: cannot find symbol
  private Publisher<std_msgs.msg.String> publisher;
          ^
  symbol:   class Publisher
  location: class PublisherLambda
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/publisher/PublisherLambda.java:29: error: package std_msgs.msg does not exist
  private Publisher<std_msgs.msg.String> publisher;
                                ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/publisher/PublisherLambda.java:31: error: cannot find symbol
  private WallTimer timer;
          ^
  symbol:   class WallTimer
  location: class PublisherLambda
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/subscriber/SubscriberMemberFunction.java:29: error: package std_msgs.msg does not exist
        std_msgs.msg.String.class, "topic", this ::topicCallback);
                    ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/subscriber/SubscriberMemberFunction.java:28: error: package std_msgs.msg does not exist
    subscription = node.<std_msgs.msg.String>createSubscription(
                                     ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/subscriber/SubscriberMemberFunction.java:28: error: cannot find symbol
    subscription = node.<std_msgs.msg.String>createSubscription(
                   ^
  symbol:   variable node
  location: class SubscriberMemberFunction
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/subscriber/SubscriberMemberFunction.java:38: error: cannot find symbol
    RCLJava.rclJavaInit();
    ^
  symbol:   variable RCLJava
  location: class SubscriberMemberFunction
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/subscriber/SubscriberMemberFunction.java:40: error: cannot find symbol
    RCLJava.spin(new SubscriberMemberFunction());
    ^
  symbol:   variable RCLJava
  location: class SubscriberMemberFunction
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/subscriber/SubscriberNotComposable.java:30: error: cannot find symbol
    RCLJava.rclJavaInit();
    ^
  symbol:   variable RCLJava
  location: class SubscriberNotComposable
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/subscriber/SubscriberNotComposable.java:33: error: cannot find symbol
    Node node = RCLJava.createNode("minimal_subscriber");
    ^
  symbol:   class Node
  location: class SubscriberNotComposable
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/subscriber/SubscriberNotComposable.java:33: error: cannot find symbol
    Node node = RCLJava.createNode("minimal_subscriber");
                ^
  symbol:   variable RCLJava
  location: class SubscriberNotComposable
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/subscriber/SubscriberNotComposable.java:38: error: cannot find symbol
    Subscription<std_msgs.msg.String> sub = node.<std_msgs.msg.String>createSubscription(
    ^
  symbol:   class Subscription
  location: class SubscriberNotComposable
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/subscriber/SubscriberNotComposable.java:38: error: package std_msgs.msg does not exist
    Subscription<std_msgs.msg.String> sub = node.<std_msgs.msg.String>createSubscription(
                             ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/subscriber/SubscriberNotComposable.java:39: error: package std_msgs.msg does not exist
        std_msgs.msg.String.class, "topic", SubscriberNotComposable::topicCallback);
                    ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/subscriber/SubscriberNotComposable.java:38: error: package std_msgs.msg does not exist
    Subscription<std_msgs.msg.String> sub = node.<std_msgs.msg.String>createSubscription(
                                                              ^
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/subscriber/SubscriberNotComposable.java:41: error: cannot find symbol
    RCLJava.spin(node);
    ^
  symbol:   variable RCLJava
  location: class SubscriberNotComposable
/src/test/build/rcljava_examples/src/main/java/org/ros2/rcljava/examples/subscriber/SubscriberLambda.java:28: error: package std_msgs.msg does not exist
    subscription = node.<std_msgs.msg.String>createSubscription(std_msgs.msg.String.class, "topic",
                                                                            ^
100 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':compileJava'.
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:187)
        at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:263)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:185)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:166)
        at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:109)
        at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
        at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:62)
        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:56)
        at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:77)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:55)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:416)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:406)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:102)
        at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:52)
        at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:41)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:374)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:361)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:354)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:340)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.lambda$run$0(DefaultPlanExecutor.java:127)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:191)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:182)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:124)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
        at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
Caused by: org.gradle.api.internal.tasks.compile.CompilationFailedException: Compilation failed; see the compiler error output for details.
        at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:56)
        at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:39)
        at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.delegateAndHandleErrors(NormalizingJavaCompiler.java:100)
        at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute(NormalizingJavaCompiler.java:52)
        at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute(NormalizingJavaCompiler.java:38)
        at org.gradle.api.internal.tasks.compile.AnnotationProcessorDiscoveringCompiler.execute(AnnotationProcessorDiscoveringCompiler.java:51)
        at org.gradle.api.internal.tasks.compile.AnnotationProcessorDiscoveringCompiler.execute(AnnotationProcessorDiscoveringCompiler.java:37)
        at org.gradle.api.internal.tasks.compile.CleaningJavaCompiler.execute(CleaningJavaCompiler.java:53)
        at org.gradle.api.internal.tasks.compile.incremental.IncrementalCompilerFactory.lambda$createRebuildAllCompiler$0(IncrementalCompilerFactory.java:98)
        at org.gradle.api.internal.tasks.compile.incremental.IncrementalResultStoringCompiler.execute(IncrementalResultStoringCompiler.java:60)
        at org.gradle.api.internal.tasks.compile.incremental.IncrementalResultStoringCompiler.execute(IncrementalResultStoringCompiler.java:44)
        at org.gradle.api.internal.tasks.compile.CompileJavaBuildOperationReportingCompiler$2.call(CompileJavaBuildOperationReportingCompiler.java:59)
        at org.gradle.api.internal.tasks.compile.CompileJavaBuildOperationReportingCompiler$2.call(CompileJavaBuildOperationReportingCompiler.java:51)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:416)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:406)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:102)
        at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
        at org.gradle.api.internal.tasks.compile.CompileJavaBuildOperationReportingCompiler.execute(CompileJavaBuildOperationReportingCompiler.java:51)
        at org.gradle.api.tasks.compile.JavaCompile.performCompilation(JavaCompile.java:208)
        at org.gradle.api.tasks.compile.JavaCompile.compile(JavaCompile.java:179)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:104)
        at org.gradle.api.internal.project.taskfactory.IncrementalInputsTaskAction.doExecute(IncrementalInputsTaskAction.java:32)
        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:42)
        at org.gradle.api.internal.project.taskfactory.AbstractIncrementalTaskAction.execute(AbstractIncrementalTaskAction.java:25)
        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:28)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$3.run(ExecuteActionsTaskExecuter.java:539)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:402)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:394)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:92)
        at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:524)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:507)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.access$300(ExecuteActionsTaskExecuter.java:109)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$TaskExecution.executeWithPreviousOutputFiles(ExecuteActionsTaskExecuter.java:258)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$TaskExecution.execute(ExecuteActionsTaskExecuter.java:247)
        at org.gradle.internal.execution.steps.ExecuteStep.lambda$execute$0(ExecuteStep.java:32)
        at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:32)
        at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:26)
        at org.gradle.internal.execution.steps.CleanupOutputsStep.execute(CleanupOutputsStep.java:63)
        at org.gradle.internal.execution.steps.CleanupOutputsStep.execute(CleanupOutputsStep.java:35)
        at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:49)
        at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:34)
        at org.gradle.internal.execution.steps.CancelExecutionStep.execute(CancelExecutionStep.java:43)
        at org.gradle.internal.execution.steps.TimeoutStep.executeWithoutTimeout(TimeoutStep.java:73)
        at org.gradle.internal.execution.steps.TimeoutStep.execute(TimeoutStep.java:54)
        at org.gradle.internal.execution.steps.CatchExceptionStep.execute(CatchExceptionStep.java:34)
        at org.gradle.internal.execution.steps.CreateOutputsStep.execute(CreateOutputsStep.java:44)
        at org.gradle.internal.execution.steps.SnapshotOutputsStep.execute(SnapshotOutputsStep.java:54)
        at org.gradle.internal.execution.steps.SnapshotOutputsStep.execute(SnapshotOutputsStep.java:38)
        at org.gradle.internal.execution.steps.CacheStep.executeWithoutCache(CacheStep.java:153)
        at org.gradle.internal.execution.steps.CacheStep.execute(CacheStep.java:67)
        at org.gradle.internal.execution.steps.CacheStep.execute(CacheStep.java:41)
        at org.gradle.internal.execution.steps.BroadcastChangingOutputsStep.execute(BroadcastChangingOutputsStep.java:49)
        at org.gradle.internal.execution.steps.StoreExecutionStateStep.execute(StoreExecutionStateStep.java:44)
        at org.gradle.internal.execution.steps.StoreExecutionStateStep.execute(StoreExecutionStateStep.java:33)
        at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:38)
        at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:24)
        at org.gradle.internal.execution.steps.SkipUpToDateStep.executeBecause(SkipUpToDateStep.java:92)
        at org.gradle.internal.execution.steps.SkipUpToDateStep.lambda$execute$0(SkipUpToDateStep.java:85)
        at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:55)
        at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:39)
        at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:76)
        at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:37)
        at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:36)
        at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:26)
        at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:94)
        at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:49)
        at org.gradle.internal.execution.steps.CaptureStateBeforeExecutionStep.execute(CaptureStateBeforeExecutionStep.java:79)
        at org.gradle.internal.execution.steps.CaptureStateBeforeExecutionStep.execute(CaptureStateBeforeExecutionStep.java:53)
        at org.gradle.internal.execution.steps.ValidateStep.execute(ValidateStep.java:74)
        at org.gradle.internal.execution.steps.SkipEmptyWorkStep.lambda$execute$2(SkipEmptyWorkStep.java:78)
        at org.gradle.internal.execution.steps.SkipEmptyWorkStep.execute(SkipEmptyWorkStep.java:78)
        at org.gradle.internal.execution.steps.SkipEmptyWorkStep.execute(SkipEmptyWorkStep.java:34)
        at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsStartedStep.execute(MarkSnapshottingInputsStartedStep.java:39)
        at org.gradle.internal.execution.steps.LoadExecutionStateStep.execute(LoadExecutionStateStep.java:40)
        at org.gradle.internal.execution.steps.LoadExecutionStateStep.execute(LoadExecutionStateStep.java:28)
        at org.gradle.internal.execution.impl.DefaultWorkExecutor.execute(DefaultWorkExecutor.java:33)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:174)
        ... 30 more

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.0/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 5s
3 actionable tasks: 3 executed

---
Failed   <<< rcljava_examples [5.57s, exited with code 1]

Summary: 0 packages finished [5.71s]
  1 package failed: rcljava_examples
sanke69 commented 7 months ago

For those with the same problem and before adding a most valuable solution, a working hack:

1- add to build.gradle


ext {
    ROS2_JAVA_CP = files(System.getenv("ROS2_JAVA_CLASSPATH").split(File.pathSeparator))
}

compileJava {
  doFirst {
    classpath += ROS2_JAVA_CP
  }
}

then before colcon build

source /opt/ros/humble/setup.bash
source /src/ros2_java_ws/install/setup.bash
export ROS2_JAVA_CLASSPATH=$CLASSPATH
colcon build