websocket icon indicating copy to clipboard operation
websocket copied to clipboard

Wrong "optional" dependency in jakarta.websocket-api Maven artifact

Open loetifuss opened this issue 3 months ago • 1 comments

Since https://github.com/jakartaee/websocket/issues/180 the Maven artifact of jakarta.websocket-api lists jakarta.websocket-client-api as an optional "provided" dependency. With this setup the following code does not compile, although dependencies are defined correctly:

Compiling the following class:

import jakarta.websocket.server.ServerEndpointConfig;

public class Server {

    public String registerWebsocketEndpoint(ServerEndpointConfig serverEndpointConfig)
    {
        return serverEndpointConfig.getPath();
    }

}

with a dependency on:

dependencies {
    api 'jakarta.websocket:jakarta.websocket-api:2.2.0'
    // PROBLEM: this is needed to compile but should be included transitively
    // implementation 'jakarta.websocket:jakarta.websocket-client-api:2.2.0'
}

will fail with:

error: cannot access EndpointConfig
        return serverEndpointConfig.getPath();
                                   ^
  class file for jakarta.websocket.EndpointConfig not found

Either "jakarta.websocket-client-api" should be a transitive compile dependency or EndpointConfig should not be part of the "client-api" artifact since it is needed to compile server related classes.

I have attached a simple example reproducing the issue: jakarta-websocket-dependencies.zip

loetifuss avatar Nov 13 '24 08:11 loetifuss