Skip to content

Commit

Permalink
Make use of conditional dependencies in rest data panache
Browse files Browse the repository at this point in the history
This way users don't have to manually add specify the links
implementation for their flavor of RESTEasy
  • Loading branch information
geoand committed Oct 20, 2021
1 parent f9a7a06 commit 5938fd2
Show file tree
Hide file tree
Showing 17 changed files with 242 additions and 40 deletions.
10 changes: 10 additions & 0 deletions bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1451,6 +1451,16 @@
<artifactId>quarkus-resteasy-jaxb-deployment</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-links</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-links-deployment</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-multipart</artifactId>
Expand Down
28 changes: 26 additions & 2 deletions docs/src/main/asciidoc/rest-data-panache.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ A lot of web applications are monotonous CRUD applications with REST APIs that a
To streamline this task, REST Data with Panache extension can generate the basic CRUD endpoints for your entities and repositories.

While this extension is still experimental and provides a limited feature set, we hope to get an early feedback for it.
Currently this extension supports Hibernate ORM and MongoDB with Panache and can generate CRUD resources that work with `application/json` and `application/hal+json` content.
Currently, this extension supports Hibernate ORM and MongoDB with Panache and can generate CRUD resources that work with `application/json` and `application/hal+json` content.

include::./status-include.adoc[]

Expand All @@ -23,7 +23,7 @@ include::./status-include.adoc[]
* Add the required dependencies to your `pom.xml`
** Hibernate ORM REST Data with Panache extension (`quarkus-hibernate-orm-rest-data-panache`)
** A JDBC driver extension (`quarkus-jdbc-postgresql`, `quarkus-jdbc-h2`, `quarkus-jdbc-mariadb`, ...)
** One of the RESTEasy JSON serialization extensions (`quarkus-resteasy-reactive-jackson` or `quarkus-resteasy-reactive-jsonb`)
** One of the RESTEasy JSON serialization extensions (the extension supports both RESTEasy and RESTEasy Reactive)

[source,xml]
----
Expand All @@ -36,10 +36,18 @@ include::./status-include.adoc[]
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jdbc-postgresql</artifactId>
</dependency>
<!-- Use these if you are using RESTEasy Reactive -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-reactive-jackson</artifactId>
</dependency>
<!-- Use this if you are going to use RESTEasy Classic -->
<!--
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jackson</artifactId>
</dependency>
-->
</dependencies>
----

Expand All @@ -59,10 +67,26 @@ include::./status-include.adoc[]
<groupId>io.quarkus</groupId>
<artifactId>quarkus-mongodb-rest-data-panache</artifactId>
</dependency>
<!-- Use these if you are using RESTEasy Reactive -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-reactive-jackson</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-reactive-links</artifactId>
</dependency>
<!-- Use this if you are going to use RESTEasy Classic -->
<!--
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jackson</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-links</artifactId>
</dependency>
-->
</dependencies>
----

Expand Down
2 changes: 2 additions & 0 deletions docs/src/main/asciidoc/spring-data-rest.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ This will add the following to your `pom.xml`:
</dependency>
----

Furthermore, the following dependency needs to be added

For the tests you will also need REST Assured. Add it to the `pom.xml`:
[source,xml]
----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@
<artifactId>quarkus-resteasy-jsonb-deployment</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-links</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
Expand Down
12 changes: 12 additions & 0 deletions extensions/panache/rest-data-panache/deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jsonb-spi</artifactId>
</dependency>

<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-links-deployment</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-reactive-links-deployment</artifactId>
<optional>true</optional>
</dependency>

<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5-internal</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.quarkus.rest.data.panache.deployment;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import io.quarkus.arc.deployment.AdditionalBeanBuildItem;
Expand Down Expand Up @@ -30,6 +31,10 @@
import io.quarkus.rest.data.panache.runtime.hal.HalLinkJsonbSerializer;
import io.quarkus.rest.data.panache.runtime.resource.RESTEasyClassicResourceLinksProvider;
import io.quarkus.rest.data.panache.runtime.resource.RESTEasyReactiveResourceLinksProvider;
import io.quarkus.rest.data.panache.runtime.sort.SortQueryParamFilter;
import io.quarkus.rest.data.panache.runtime.sort.SortQueryParamValidator;
import io.quarkus.resteasy.common.spi.ResteasyJaxrsProviderBuildItem;
import io.quarkus.resteasy.reactive.spi.ContainerRequestFilterBuildItem;
import io.quarkus.resteasy.reactive.spi.GeneratedJaxRsResourceBuildItem;
import io.quarkus.resteasy.reactive.spi.GeneratedJaxRsResourceGizmoAdaptor;

Expand All @@ -43,7 +48,9 @@ ReflectiveClassBuildItem registerReflection() {
@BuildStep
void supportingBuildItems(Capabilities capabilities,
BuildProducer<AdditionalBeanBuildItem> additionalBeanBuildItemBuildProducer,
BuildProducer<RuntimeInitializedClassBuildItem> runtimeInitializedClassBuildItemBuildProducer) {
BuildProducer<RuntimeInitializedClassBuildItem> runtimeInitializedClassBuildItemBuildProducer,
BuildProducer<ResteasyJaxrsProviderBuildItem> resteasyJaxrsProviderBuildItemBuildProducer,
BuildProducer<ContainerRequestFilterBuildItem> containerRequestFilterBuildItemBuildProducer) {
boolean isResteasyClassicAvailable = capabilities.isPresent(Capability.RESTEASY);
boolean isResteasyReactiveAvailable = capabilities.isPresent(Capability.RESTEASY_REACTIVE);

Expand All @@ -60,6 +67,12 @@ void supportingBuildItems(Capabilities capabilities,
if (isResteasyClassicAvailable) {
runtimeInitializedClassBuildItemBuildProducer
.produce(new RuntimeInitializedClassBuildItem("org.jboss.resteasy.links.impl.EL"));
resteasyJaxrsProviderBuildItemBuildProducer
.produce(new ResteasyJaxrsProviderBuildItem(SortQueryParamFilter.class.getName()));
} else {
containerRequestFilterBuildItemBuildProducer
.produce(new ContainerRequestFilterBuildItem.Builder(SortQueryParamFilter.class.getName())
.setNameBindingNames(Collections.singleton(SortQueryParamValidator.class.getName())).build());
}
}

Expand Down
25 changes: 23 additions & 2 deletions extensions/panache/rest-data-panache/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
<artifactId>jakarta.validation-api</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-links</artifactId>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-links</artifactId>
<optional>true</optional>
</dependency>
<dependency>
Expand Down Expand Up @@ -61,4 +61,25 @@
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-bootstrap-maven-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-extension-processor</artifactId>
<version>${project.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
</project>
1 change: 1 addition & 0 deletions extensions/resteasy-classic/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<module>resteasy-jsonb</module>
<module>resteasy-jackson</module>
<module>resteasy-jaxb</module>
<module>resteasy-links</module>
<module>resteasy-mutiny-common</module>
<module>resteasy-mutiny</module>
<module>resteasy-qute</module>
Expand Down
45 changes: 45 additions & 0 deletions extensions/resteasy-classic/resteasy-links/deployment/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-links-parent</artifactId>
<version>999-SNAPSHOT</version>
</parent>

<artifactId>quarkus-resteasy-links-deployment</artifactId>
<name>Quarkus - RESTEasy - Links - Deployment</name>

<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-links</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-extension-processor</artifactId>
<version>${project.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>


</project>
20 changes: 20 additions & 0 deletions extensions/resteasy-classic/resteasy-links/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-parent-aggregator</artifactId>
<version>999-SNAPSHOT</version>
</parent>

<artifactId>quarkus-resteasy-links-parent</artifactId>
<name>Quarkus - RESTEasy - Links</name>
<packaging>pom</packaging>
<modules>
<module>deployment</module>
<module>runtime</module>
</modules>
</project>
61 changes: 61 additions & 0 deletions extensions/resteasy-classic/resteasy-links/runtime/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-links-parent</artifactId>
<version>999-SNAPSHOT</version>
</parent>

<artifactId>quarkus-resteasy-links</artifactId>
<name>Quarkus - RESTEasy - Links - Runtime</name>
<description>Links support RESTEasy</description>

<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-links</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-bootstrap-maven-plugin</artifactId>
<executions>
<execution>
<phase>process-resources</phase>
<goals>
<goal>extension-descriptor</goal>
</goals>
<configuration>
<dependencyCondition>
<artifact>io.quarkus:quarkus-resteasy</artifact>
</dependencyCondition>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-extension-processor</artifactId>
<version>${project.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
artifact: ${project.groupId}:${project.artifactId}:${project.version}
name: "RESTEasy Links"
metadata:
keywords:
- "resteasy-links"
- "resteasy"
- "jaxrs"
- "links"
categories:
- "web"
- "serialization"
status: "stable"
config:
- "quarkus.resteasy."
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-bootstrap-maven-plugin</artifactId>
<executions>
<execution>
<phase>process-resources</phase>
<goals>
<goal>extension-descriptor</goal>
</goals>
<configuration>
<dependencyCondition>
<artifact>io.quarkus:quarkus-resteasy-reactive</artifact>
</dependencyCondition>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
Expand Down
5 changes: 0 additions & 5 deletions extensions/spring-data-rest/deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-spring-data-jpa-deployment</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-links</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5-internal</artifactId>
Expand Down
4 changes: 0 additions & 4 deletions integration-tests/hibernate-orm-rest-data-panache/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jackson</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-links</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-validator</artifactId>
Expand Down
Loading

0 comments on commit 5938fd2

Please sign in to comment.