Skip to content

Commit

Permalink
Merge pull request #1674 from zalando/support-jaxrs-2-via-shading
Browse files Browse the repository at this point in the history
Add support for traditional JAX-RS 2.x
  • Loading branch information
msdousti authored Nov 14, 2023
2 parents 3fe02ec + b86cfcf commit 2debdef
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 2 deletions.
30 changes: 28 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ library/framework/etc. to it.

## Dependencies

- Java 8 (for Spring 6 / Spring Boot 3 Java 17 is required)
- Java 8 (for Spring 6 / Spring Boot 3 and JAX-RS 3.x, Java 17 is required)
- Any build tool using Maven Central, or direct download
- Servlet Container (optional)
- Apache HTTP Client 4.x **or 5.x** (optional)
- JAX-RS 3.x (aka Jakarta RESTful Web Services) Client and Server (optional)
- JAX-RS 2.x Client and Server (optional)
- Netty 4.x (optional)
- OkHttp 2.x **or 3.x** (optional)
Expand Down Expand Up @@ -777,7 +778,32 @@ CloseableHttpAsyncClient client = HttpAsyncClientBuilder.create()
client.execute(producer, new LogbookHttpAsyncResponseConsumer<>(consumer), callback)
```

### JAX-RS
### JAX-RS 2.x and 3.x (aka Jakarta RESTful Web Services)

> [!NOTE]
> **Support for JAX-RS 2.x**
>
> JAX-RS 2.x (legacy) support was dropped in Logbook 3.0 to 3.6.
>
> As of Logbook 3.7, JAX-RS 2.x support is back.
>
> However, you need to add the `javax` **classifier** to use the proper Logbook module:
>
> ```xml
> <dependency>
> <groupId>org.zalando</groupId>
> <artifactId>logbook-jaxrs</artifactId>
> <version>${logbook.version}</version>
> <classifier>javax</classifier>
> </dependency>
> ```
>
> You should also make sure that the following dependencies are on your classpath.
> By default, `logbook-jaxrs` imports `jersey-client 3.x`, which is not compatible with JAX-RS 2.x:
>
> * [jersey-client 2.x](https://mvnrepository.com/artifact/org.glassfish.jersey.core/jersey-client/2.41)
> * [jersey-hk2 2.x](https://mvnrepository.com/artifact/org.glassfish.jersey.inject/jersey-hk2/2.41)
> * [javax.activation](https://mvnrepository.com/artifact/javax.activation/activation/1.1.1)
The `logbook-jaxrs` module contains:
Expand Down
6 changes: 6 additions & 0 deletions logbook-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@
<artifactId>logbook-jaxrs</artifactId>
<version>3.7.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.zalando</groupId>
<artifactId>logbook-jaxrs</artifactId>
<version>3.7.0-SNAPSHOT</version>
<classifier>javax</classifier>
</dependency>
<dependency>
<groupId>org.zalando</groupId>
<artifactId>logbook-json</artifactId>
Expand Down
59 changes: 59 additions & 0 deletions logbook-jaxrs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
<connection>scm:git:git@github.com:zalando/logbook.git</connection>
<developerConnection>scm:git:git@github.com:zalando/logbook.git</developerConnection>
</scm>
<properties>
<shadedClassifierName>javax</shadedClassifierName>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
Expand Down Expand Up @@ -110,6 +113,62 @@

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<id>jakarta</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>${shadedClassifierName}</shadedClassifierName>
<artifactSet>
<includes>
<include>${project.groupId}:${project.artifactId}</include>
</includes>
</artifactSet>
<relocations>
<relocation>
<pattern>jakarta.ws</pattern>
<shadedPattern>javax.ws</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>

<!-- Make IntelliJ understand the shaded artifact location -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.4.0</version>
<executions>
<execution>
<id>compile</id>
<phase>package</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<file>
${project.build.directory}/${project.build.finalName}-${shadedClassifierName}.jar
</file>
<classifier>${shadedClassifierName}</classifier>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>


<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
Expand Down

0 comments on commit 2debdef

Please sign in to comment.