jakartaee / jsonp-api

Jakarta JSON Processing
https://eclipse.org/ee4j/jsonp
Other
141 stars 61 forks source link

module-info seems broken? #159

Closed mtdowling closed 5 years ago

mtdowling commented 5 years ago

Adding the following to my pom.xml:

        <dependency>
            <groupId>javax.json</groupId>
            <artifactId>javax.json-api</artifactId>
            <version>1.1.4</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish</groupId>
            <artifactId>javax.json</artifactId>
            <version>1.1.4</version>
        </dependency>

And the following module-info.java:

module blah {
    requires java.json;
}

Results in an ambiguous implementation because javax.json-api-1.1.4.jar and javax.json-1.1.4.jar both claim they provide the module? That's what IntelliJ says. When I try to run my tests, nothing works.

When I comment out javax.json-api, everything works.

        <!--dependency>
            <groupId>javax.json</groupId>
            <artifactId>javax.json-api</artifactId>
            <version>1.1.4</version>
        </dependency-->
        <dependency>
            <groupId>org.glassfish</groupId>
            <artifactId>javax.json</artifactId>
            <version>1.1.4</version>
        </dependency>

How is this library supposed to be used?

lukasj commented 5 years ago

see https://github.com/eclipse-ee4j/jsonp/blob/master/bundles/ri/src/main/resources/README.txt

hohwille commented 5 years ago

Please note that is is a design flaw: The idea of modularity and also of maven is that people can implement libraries that only depend on an API and let the user decide which implementation to choose. Therefore the implementation has to come separately and depend on the API. What is a JEE/JakartaEE standard for, if I can not exchange the implementation?

leadpony commented 5 years ago

Hello @hohwille

The library using JSON-P should specify only the API artifact as its dependency:

<dependency>
    <groupId>javax.json</groupId>
    <artifactId>javax.json-api</artifactId>
    <version>1.1.5</version>
</dependency>

And the application using the library specifies the implementation as follows:

<dependency>
    <groupId>org.glassfish</groupId>
    <artifactId>jakarta.json</artifactId>
    <classifier>module</classifier>
    <version>1.1.5</version>
    <scope>runtime</scope>
</dependency>

Please note that classifier element is needed here. You can switch the latter dependency to other implementation such as Joy if you like it.

<dependency>
    <groupId>org.leadpony.joy</groupId>
    <artifactId>joy</artifactId>
    <version>1.0.1</version>
    <scope>runtime</scope>
</dependency>