Skip to content

Commit

Permalink
Make Nessie build with javax.* and jakarta.* dependencies (#6064)
Browse files Browse the repository at this point in the history
This change adds the Jakarta API dependencies next to the (old) javax
dependencies. Hint: the findbugs JSR-305 dependency is the
"javax-equivalent" for jakarta-annotations.

There's no production code change in this PR, but dependency
configurations/scopes have changed. Assuming that server
_implementations_ come with the "right" dependencies for the
annotations, which should work fine.

This change alone will _not_ make Nessie work with Jakarte EE 10,
because
* neither the javax-annotations are not "duplicated" with their "jakarta
counterparts",
* nor are the javax-interface implementations duplicated with their
"jakarta counterparts" (think: `implements
javax.ws.rs.ext.ParamConverterProvider` or `implements
javax.ws.rs.ext.ExceptionMapper`).

Related to: #5264
  • Loading branch information
snazy authored Feb 9, 2023
1 parent 810d636 commit cbe597b
Show file tree
Hide file tree
Showing 35 changed files with 233 additions and 70 deletions.
5 changes: 4 additions & 1 deletion clients/client-testextension/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,8 @@ dependencies {
implementation(project(":nessie-client"))
implementation(project(":nessie-multi-env-test-engine"))
compileOnly(libs.junit.jupiter.engine)
implementation(libs.findbugs.jsr305)

// javax/jakarta
compileOnly(libs.jakarta.annotation.api)
compileOnly(libs.findbugs.jsr305)
}
13 changes: 11 additions & 2 deletions clients/client/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,16 @@ dependencies {
implementation(libs.jackson.databind)
implementation(libs.jackson.annotations)
implementation(libs.microprofile.openapi)

// javax/jakarta
compileOnly(libs.jakarta.annotation.api)
compileOnly(libs.findbugs.jsr305)
compileOnly(libs.jakarta.validation.api)
compileOnly(libs.javax.validation.api)
compileOnly(libs.jakarta.ws.rs.api)
compileOnly(libs.javax.ws.rs)

implementation(libs.slf4j.api)
implementation(libs.javax.ws.rs)
implementation(libs.findbugs.jsr305)
compileOnly(libs.errorprone.annotations)

compileOnly(libs.immutables.builder)
Expand All @@ -58,6 +64,9 @@ dependencies {
compileOnly(platform(libs.awssdk.bom))
compileOnly(libs.awssdk.auth)

// javax/jakarta
testCompileOnly(libs.jakarta.annotation.api)

testImplementation(platform(libs.opentelemetry.bom))
testImplementation(libs.opentelemetry.api)
testImplementation(libs.opentelemetry.sdk)
Expand Down
4 changes: 4 additions & 0 deletions clients/spark-extensions-basetests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ dependencies {
// picks the right dependencies for scala compilation
forScala(sparkScala.scalaVersion)

// javax/jakarta
compileOnly(libs.jakarta.annotation.api)
compileOnly(libs.findbugs.jsr305)

implementation(nessieProject("nessie-spark-extensions-grammar"))
compileOnly("org.apache.spark:spark-hive_${sparkScala.scalaMajorVersion}") {
forSpark(sparkScala.sparkVersion)
Expand Down
12 changes: 9 additions & 3 deletions compatibility/common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ dependencies {
api(project(":nessie-multi-env-test-engine"))
implementation(project(":nessie-services"))
implementation(project(":nessie-versioned-persist-adapter"))
compileOnly(project(":nessie-versioned-persist-mongodb-test"))

implementation(platform(libs.jersey.bom))
api(libs.slf4j.api)
Expand All @@ -39,8 +40,12 @@ dependencies {
implementation(libs.maven.resolver.transport.file)
implementation(libs.maven.resolver.transport.http)
implementation(libs.guava)
implementation(libs.jakarta.enterprise.cdi.api)
implementation(libs.microprofile.openapi)

// javax/jakarta
compileOnly(libs.jakarta.enterprise.cdi.api)
compileOnly(libs.javax.enterprise.cdi.api)

compileOnly(libs.microprofile.openapi)

implementation(platform(libs.jackson.bom))
implementation(libs.jackson.annotations)
Expand All @@ -56,7 +61,8 @@ dependencies {
implementation(project(":nessie-versioned-persist-in-memory-test"))
implementation(project(":nessie-versioned-persist-rocks"))
implementation(project(":nessie-versioned-persist-rocks-test"))
compileOnly(project(":nessie-versioned-persist-mongodb-test"))

testCompileOnly(libs.microprofile.openapi)

testImplementation(libs.junit.platform.testkit)
testImplementation(libs.junit.jupiter.params)
Expand Down
16 changes: 11 additions & 5 deletions compatibility/jersey/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,17 @@ dependencies {
implementation(project(":nessie-versioned-persist-store"))
implementation(project(":nessie-versioned-persist-testextension"))
implementation(project(":nessie-versioned-spi"))
implementation(libs.javax.ws.rs21)
implementation(libs.jakarta.enterprise.cdi.api)
implementation(libs.jakarta.annotation.api)
implementation(libs.jakarta.validation.api)
implementation(libs.javax.ws.rs)

// javax/jakarta
compileOnly(libs.jakarta.ws.rs.api)
compileOnly(libs.javax.ws.rs)
compileOnly(libs.javax.ws.rs21)
compileOnly(libs.jakarta.enterprise.cdi.api)
compileOnly(libs.javax.enterprise.cdi.api)
compileOnly(libs.jakarta.annotation.api)
compileOnly(libs.findbugs.jsr305)
compileOnly(libs.jakarta.validation.api)
compileOnly(libs.javax.validation.api)

implementation(platform(libs.jackson.bom))
implementation(libs.jackson.databind)
Expand Down
4 changes: 4 additions & 0 deletions gc/gc-base-tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ dependencies {
implementation(nessieProject("nessie-gc-base"))

compileOnly(libs.microprofile.openapi)

// javax/jakarta
compileOnly(libs.jakarta.validation.api)
compileOnly(libs.javax.validation.api)
compileOnly(libs.jakarta.annotation.api)
compileOnly(libs.findbugs.jsr305)

compileOnly(platform(libs.jackson.bom))
Expand Down
8 changes: 8 additions & 0 deletions gc/gc-base/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ dependencies {
implementation(libs.agrona)

compileOnly(libs.microprofile.openapi)

// javax/jakarta
compileOnly(libs.jakarta.validation.api)
compileOnly(libs.javax.validation.api)
compileOnly(libs.jakarta.annotation.api)
compileOnly(libs.findbugs.jsr305)

compileOnly(platform(libs.jackson.bom))
Expand All @@ -53,7 +57,11 @@ dependencies {
testRuntimeOnly(libs.logback.classic)

testCompileOnly(libs.microprofile.openapi)

// javax/jakarta
testCompileOnly(libs.jakarta.validation.api)
testCompileOnly(libs.javax.validation.api)

testCompileOnly(libs.immutables.value.annotations)
testAnnotationProcessor(libs.immutables.value.processor)

Expand Down
5 changes: 5 additions & 0 deletions gc/gc-iceberg-inttest/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ dependencies {
testAnnotationProcessor(libs.immutables.value.processor)

testRuntimeOnly(libs.logback.classic)

// javax/jakarta
testCompileOnly(libs.jakarta.validation.api)
testCompileOnly(libs.jakarta.annotation.api)

testCompileOnly(libs.microprofile.openapi)

testImplementation(platform(libs.junit.bom))
Expand Down
6 changes: 5 additions & 1 deletion gc/gc-iceberg-mock/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,12 @@ dependencies {
implementation(libs.slf4j.api)

compileOnly(libs.microprofile.openapi)
compileOnly(libs.jakarta.validation.api)
compileOnly(libs.jackson.annotations)

// javax/jakarta
compileOnly(libs.jakarta.validation.api)
compileOnly(libs.javax.validation.api)
compileOnly(libs.jakarta.annotation.api)
compileOnly(libs.findbugs.jsr305)

testRuntimeOnly(libs.logback.classic)
Expand Down
4 changes: 4 additions & 0 deletions gc/gc-iceberg/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ dependencies {
compileOnly(platform(libs.jackson.bom))
compileOnly(libs.jackson.annotations)
compileOnly(libs.microprofile.openapi)

// javax/jakarta
compileOnly(libs.jakarta.validation.api)
compileOnly(libs.javax.validation.api)
compileOnly(libs.jakarta.annotation.api)
compileOnly(libs.findbugs.jsr305)

testImplementation(nessieProject("nessie-gc-iceberg-mock"))
Expand Down
4 changes: 4 additions & 0 deletions gc/gc-repository-jdbc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ dependencies {
implementation(libs.slf4j.api)

compileOnly(libs.microprofile.openapi)

// javax/jakarta
compileOnly(libs.jakarta.validation.api)
compileOnly(libs.javax.validation.api)
compileOnly(libs.jakarta.annotation.api)
compileOnly(libs.findbugs.jsr305)

compileOnly(platform(libs.jackson.bom))
Expand Down
6 changes: 5 additions & 1 deletion gc/gc-tool/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,12 @@ dependencies {
runtimeOnly(libs.logback.classic)

compileOnly(libs.microprofile.openapi)
compileOnly(libs.jakarta.validation.api)
compileOnly(libs.jackson.annotations)

// javax/jakarta
compileOnly(libs.jakarta.validation.api)
compileOnly(libs.javax.validation.api)
compileOnly(libs.jakarta.annotation.api)
compileOnly(libs.findbugs.jsr305)

runtimeOnly(libs.h2)
Expand Down
11 changes: 8 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,16 @@ jackson-jaxrs-xml-provider = { module = "com.fasterxml.jackson.jaxrs:jackson-jax
jacoco-ant = { module = "org.jacoco:org.jacoco.ant", version.ref = "jacoco" }
jacoco-report = { module = "org.jacoco:org.jacoco.report", version.ref = "jacoco" }
jacoco-maven-plugin = { module = "org.jacoco:jacoco-maven-plugin", version.ref = "jacoco" }
jakarta-annotation-api = { module = "jakarta.annotation:jakarta.annotation-api", version = "1.3.5" }
jakarta-enterprise-cdi-api = { module = "jakarta.enterprise:jakarta.enterprise.cdi-api", version = "2.0.2" }
jakarta-validation-api = { module = "jakarta.validation:jakarta.validation-api", version = "2.0.2" }
jakarta-annotation-api = { module = "jakarta.annotation:jakarta.annotation-api", version = "2.1.1" }
jakarta-enterprise-cdi-api = { module = "jakarta.enterprise:jakarta.enterprise.cdi-api", version = "4.0.1" }
jakarta-inject-api = { module = "jakarta.inject:jakarta.inject-api", version = "2.0.1" }
jakarta-servlet-api = { module = "jakarta.servlet:jakarta.servlet-api", version = "6.0.0" }
jakarta-validation-api = { module = "jakarta.validation:jakarta.validation-api", version = "3.0.2" }
jakarta-ws-rs-api = { module = "jakarta.ws.rs:jakarta.ws.rs-api", version = "3.1.0" }
jandex = { module = "org.jboss:jandex", version.ref = "jandex" }
javax-enterprise-cdi-api = { module = "javax.enterprise:cdi-api", version = "2.0.SP1" }
javax-servlet = { module = "javax.servlet:javax.servlet-api", version = "4.0.1" }
javax-validation-api = { module = "javax.validation:validation-api", version = "2.0.1.Final"}
javax-ws-rs = { module = "javax.ws.rs:javax.ws.rs-api", version = "2.1.1" }
javax-ws-rs21 = { module = "org.jboss.spec.javax.ws.rs:jboss-jaxrs-api_2.1_spec", version = "2.0.2.Final" }
jersey-bom = { module = "org.glassfish.jersey:jersey-bom", version = "2.38" }
Expand Down
11 changes: 8 additions & 3 deletions model/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,15 @@ dependencies {
implementation(libs.jackson.databind)
implementation(libs.jackson.annotations)

implementation(libs.javax.ws.rs)
compileOnly(libs.microprofile.openapi)
// javax/jakarta
compileOnly(libs.jakarta.ws.rs.api)
compileOnly(libs.javax.ws.rs)
compileOnly(libs.jakarta.validation.api)
implementation(libs.findbugs.jsr305)
compileOnly(libs.javax.validation.api)
compileOnly(libs.jakarta.annotation.api)
compileOnly(libs.findbugs.jsr305)

compileOnly(libs.microprofile.openapi)

compileOnly(libs.immutables.builder)
compileOnly(libs.immutables.value.annotations)
Expand Down
19 changes: 10 additions & 9 deletions model/src/test/java/org/projectnessie/error/TestNessieError.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.regex.Pattern;
import javax.ws.rs.core.Response;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.parallel.Execution;
import org.junit.jupiter.api.parallel.ExecutionMode;
Expand All @@ -29,22 +28,24 @@
class TestNessieError {

private static final ObjectMapper mapper = new ObjectMapper();
public static final int HTTP_500_CODE = 500;
public static final String HTTP_500_MESSAGE = "Internal Server Error";

@Test
void fullMessage() {
NessieError e =
ImmutableNessieError.builder()
.message("message")
.errorCode(ErrorCode.UNKNOWN)
.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode())
.reason(Response.Status.INTERNAL_SERVER_ERROR.getReasonPhrase())
.status(HTTP_500_CODE)
.reason(HTTP_500_MESSAGE)
.serverStackTrace("foo.bar.InternalServerError\n" + "\tat some.other.Class")
.build();
assertThat(e.getFullMessage())
.matches(
Response.Status.INTERNAL_SERVER_ERROR.getReasonPhrase()
HTTP_500_MESSAGE
+ " [(]HTTP/"
+ Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()
+ HTTP_500_CODE
+ "[)]: message\\R"
+ "foo.bar.InternalServerError\\R"
+ "\tat some.other.Class");
Expand All @@ -59,9 +60,9 @@ void fullMessage() {
// Using a regex here, because the stack trace looks different with
// junit-platform-maven-plugin
Pattern.compile(
Response.Status.INTERNAL_SERVER_ERROR.getReasonPhrase()
HTTP_500_MESSAGE
+ " [(]HTTP/"
+ Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()
+ HTTP_500_CODE
+ "[)]: message\\R"
+ "foo.bar.InternalServerError\\R"
+ "\tat some.other.Class\\R"
Expand All @@ -77,8 +78,8 @@ void jsonRoundTrip() throws JsonProcessingException {
ImmutableNessieError.builder()
.message("message")
.errorCode(ErrorCode.UNKNOWN)
.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode())
.reason(Response.Status.INTERNAL_SERVER_ERROR.getReasonPhrase())
.status(HTTP_500_CODE)
.reason(HTTP_500_MESSAGE)
.serverStackTrace("foo.bar.InternalServerError\n" + "\tat some.other.Class")
.clientProcessingException(new Exception("processingException"))
.build();
Expand Down
12 changes: 8 additions & 4 deletions servers/jax-rs-tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,20 @@ dependencies {
implementation(project(":nessie-client-testextension"))
implementation(libs.guava)
api(libs.rest.assured)
implementation(libs.findbugs.jsr305)

// javax/jakarta
compileOnly(libs.jakarta.validation.api)
compileOnly(libs.javax.validation.api)
compileOnly(libs.jakarta.annotation.api)
compileOnly(libs.findbugs.jsr305)

compileOnly(libs.microprofile.openapi)

api(libs.assertj.core)
api(platform(libs.junit.bom))
api(libs.junit.jupiter.api)
api(libs.junit.jupiter.params)

compileOnly(libs.microprofile.openapi)
compileOnly(libs.jakarta.validation.api)

implementation(platform(libs.jackson.bom))
implementation(libs.jackson.databind)
compileOnly(libs.jackson.annotations)
Expand Down
22 changes: 14 additions & 8 deletions servers/jax-rs/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,22 @@ dependencies {
api(project(":nessie-versioned-persist-adapter"))
api(project(":nessie-versioned-persist-serialize"))
implementation(libs.slf4j.api)
implementation(libs.javax.ws.rs21)
api(libs.jakarta.enterprise.cdi.api)
api(libs.jakarta.annotation.api)
api(libs.jakarta.validation.api)
api(libs.hibernate.validator.cdi)

// javax/jakarta
compileOnly(libs.jakarta.ws.rs.api)
compileOnly(libs.javax.ws.rs21)
compileOnly(libs.jakarta.enterprise.cdi.api)
compileOnly(libs.javax.enterprise.cdi.api)
compileOnly(libs.jakarta.annotation.api)
compileOnly(libs.findbugs.jsr305)
compileOnly(libs.jakarta.validation.api)
compileOnly(libs.javax.validation.api)

compileOnly(libs.microprofile.openapi)

compileOnly(libs.hibernate.validator.cdi)

api(platform(libs.jackson.bom))
api(libs.jackson.databind)
compileOnly(libs.jackson.annotations)

compileOnly(libs.microprofile.openapi)
compileOnly(libs.jakarta.validation.api)
}
5 changes: 4 additions & 1 deletion servers/quarkus-cli/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ dependencies {

implementation(libs.protobuf.java)

implementation(libs.findbugs.jsr305)
// javax/jakarta
compileOnly(libs.jakarta.annotation.api)
compileOnly(libs.findbugs.jsr305)

compileOnly(libs.errorprone.annotations)
compileOnly(libs.microprofile.openapi)

Expand Down
5 changes: 4 additions & 1 deletion servers/quarkus-common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ dependencies {
implementation("io.quarkus:quarkus-mongodb-client")
implementation("org.jboss.slf4j:slf4j-jboss-logmanager")

implementation(libs.jakarta.validation.api)
// javax/jakarta
compileOnly(libs.jakarta.validation.api)
compileOnly(libs.javax.validation.api)

implementation(libs.protobuf.java)

compileOnly(libs.graalvm.nativeimage.svm)
Expand Down
Loading

0 comments on commit cbe597b

Please sign in to comment.