Skip to content

Commit

Permalink
feat: simplify React support (#432)
Browse files Browse the repository at this point in the history
This change introduces the quarkus-hilla-react extension, to be used for
application using React as front-end development framework.
In addition, it also updates the codestarts to provide a working
application, leveraging on Hilla scaffold utility.

Fixes #393

Co-authored-by: Dario Götze <Dario@ok.de>
  • Loading branch information
mcollovati and Dudeplayz committed Nov 28, 2023
1 parent d4db832 commit a42db57
Show file tree
Hide file tree
Showing 131 changed files with 34,124 additions and 221 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pom.xml.versionsBackup
*.iml
.DS_Store


# The following files are generated/updated by vaadin-maven-plugin
node_modules/
**/frontend/generated/
Expand All @@ -20,6 +21,12 @@ vite*.ts
tsconfig.json
types.d.ts

# Codestarts
!**/codestarts/**/package*.json
!**/codestarts/**/tsconfig.json
!**/codestarts/**/types.d.ts
!**/codestarts/**/vite.config.ts

# Browser drivers for local integration tests
drivers/
# Error screenshots generated by TestBench for failed integration tests
Expand Down
26 changes: 25 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ as [Endpoints](https://hilla.dev/docs/lit/guides/endpoints),
[Reactive Endpoints](https://hilla.dev/docs/lit/guides/reactive-endpoints)
and [Security](https://hilla.dev/docs/lit/guides/security).

Starting with `2.4.1`, the extension is subdivided into two main artifacts based on the desired front-end framework:
* `quarkus-hilla` for `Lit` based applications
* `quarkus-hilla-react` for `React` based applications

**NOTE**: This is an **unofficial community extension**, and it is **not**
directly related **nor** supported by Vaadin Ltd.

Expand Down Expand Up @@ -52,7 +56,17 @@ or download the [starter project](https://github.com/mcollovati/quarkus-hilla-st
<dependency>
<groupId>com.github.mcollovati</groupId>
<artifactId>quarkus-hilla</artifactId>
<version>2.3.0</version>
<version>2.4.x</version>
</dependency>
```

or

```xml
<dependency>
<groupId>com.github.mcollovati</groupId>
<artifactId>quarkus-hilla-react</artifactId>
<version>2.4.x</version>
</dependency>
```

Expand Down Expand Up @@ -107,6 +121,16 @@ unless a debugger is attached to the JVM, either by running the tests in debug m
mvn -DtrimStackTrace=false -Dmaven.surefire.debug -Pit-tests verify
```

## Update codestarts

The source code of the extension codestarts are built, using the Hilla application scaffold utility (`HillaAppInitUtility`).
To update the source code, run the following command in the `runtime` and `runtime-react` folders,
and commit the changes.

```terminal
mvn -Pupdate-hilla-codestart
```

## Release

The release process is based on the awesome [JReleaser](https://jreleaser.org/) tool.
Expand Down
130 changes: 130 additions & 0 deletions deployment-commons/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.github.mcollovati</groupId>
<artifactId>quarkus-hilla-parent</artifactId>
<version>${revision}</version>
</parent>

<artifactId>quarkus-hilla-commons-deployment</artifactId>
<name>Quarkus - Hilla - Deployment Commons</name>
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-arc-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-reactive-jackson-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-reactive-servlet-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-validator-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-undertow-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-websockets-deployment</artifactId>
</dependency>
<dependency>
<groupId>com.github.mcollovati</groupId>
<artifactId>quarkus-hilla-commons</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5-internal</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-validator</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-security-deployment</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-security-test-utils</artifactId>
<scope>test</scope>
<version>${quarkus.version}</version>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.mcollovati</groupId>
<artifactId>hilla-jandex</artifactId>
<version>${project.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.github.mcollovati</groupId>
<artifactId>hilla-react-jandex</artifactId>
<version>${project.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-orm-panache</artifactId>
<scope>test</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-spring-data-jpa</artifactId>
<scope>test</scope>
<optional>true</optional>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-extension-processor</artifactId>
<version>${quarkus.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<vaadin.frontend.frontend.folder>${project.build.directory}/frontend
</vaadin.frontend.frontend.folder>
<vaadin.project.frontend.generated>${project.build.directory}/frontend/generated
</vaadin.project.frontend.generated>
</systemPropertyVariables>
<forkNode implementation="org.apache.maven.plugin.surefire.extensions.SurefireForkNodeFactory"/>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,16 @@ class BrowserCallableControllerTest extends AbstractEndpointControllerTest {

@RegisterExtension
static final QuarkusUnitTest config = new QuarkusUnitTest()
.withConfigurationResource(testResource("test-application.properties"))
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)
.addClasses(TestUtils.class, Pojo.class, TestBrowserCallable.class));

@Override
protected String getEndpointName() {
return ENDPOINT_NAME;
}

private static String testResource(String name) {
return BrowserCallableControllerTest.class.getPackageName().replace('.', '/') + '/' + name;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,16 @@ class EndpointControllerTest extends AbstractEndpointControllerTest {

@RegisterExtension
static final QuarkusUnitTest config = new QuarkusUnitTest()
.withConfigurationResource(testResource("test-application.properties"))
.setArchiveProducer(() ->
ShrinkWrap.create(JavaArchive.class).addClasses(TestUtils.class, Pojo.class, TestEndpoint.class));

@Override
protected String getEndpointName() {
return ENDPOINT_NAME;
}

private static String testResource(String name) {
return EndpointControllerTest.class.getPackageName().replace('.', '/') + '/' + name;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import io.quarkus.test.QuarkusUnitTest;
import io.restassured.specification.RequestSpecification;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
Expand All @@ -43,12 +42,16 @@
class EndpointSecurityTest {

@RegisterExtension
static final QuarkusUnitTest config = new QuarkusUnitTest().setArchiveProducer(() -> ShrinkWrap.create(
JavaArchive.class)
.addClasses(TestIdentityProvider.class, TestIdentityController.class, TestUtils.class, SecureEndpoint.class)
.addAsResource(
new StringAsset("quarkus.http.auth.basic=true\nquarkus.http.auth.proactive=true\n"),
"application.properties"));
static final QuarkusUnitTest config = new QuarkusUnitTest()
.withConfigurationResource(testResource("test-application.properties"))
.overrideRuntimeConfigKey("quarkus.http.auth.basic", "true")
.overrideRuntimeConfigKey("quarkus.http.auth.proactive", "true")
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)
.addClasses(
TestIdentityProvider.class,
TestIdentityController.class,
TestUtils.class,
SecureEndpoint.class));

public static final String SECURE_ENDPOINT = "SecureEndpoint";

Expand Down Expand Up @@ -199,4 +202,8 @@ void securedEndpoint_notAnnotatedMethod_denyAll() {
private static UnaryOperator<RequestSpecification> authenticate(User user) {
return spec -> spec.auth().preemptive().basic(user.username, user.pwd);
}

private static String testResource(String name) {
return EndpointSecurityTest.class.getPackageName().replace('.', '/') + '/' + name;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import io.quarkus.test.QuarkusUnitTest;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.jupiter.api.extension.RegisterExtension;

Expand All @@ -28,12 +27,16 @@ class ReactiveEndpointTest extends AbstractReactiveEndpointTest {

@RegisterExtension
static final QuarkusUnitTest config = new QuarkusUnitTest()
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)
.addClasses(ReactiveEndpoint.class, HillaPushClient.class)
.add(new StringAsset("com.vaadin.experimental.hillaPush=true"), "vaadin-featureflags.properties"));
.withConfigurationResource(testResource("test-application.properties"))
.setArchiveProducer(() ->
ShrinkWrap.create(JavaArchive.class).addClasses(ReactiveEndpoint.class, HillaPushClient.class));

@Override
public String getEndpointName() {
return ENDPOINT_NAME;
}

private static String testResource(String name) {
return ReactiveEndpointTest.class.getPackageName().replace('.', '/') + '/' + name;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import org.assertj.core.api.AbstractStringAssert;
import org.assertj.core.api.Assertions;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
Expand All @@ -55,17 +54,16 @@ class ReactiveSecureEndpointTest {

@RegisterExtension
static final QuarkusUnitTest config = new QuarkusUnitTest()
.withConfigurationResource(testResource("test-application.properties"))
.overrideRuntimeConfigKey("quarkus.http.auth.basic", "true")
.overrideRuntimeConfigKey("quarkus.http.auth.proactive", "true")
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)
.addClasses(
TestIdentityProvider.class,
TestIdentityController.class,
TestUtils.class,
ReactiveSecureEndpoint.class,
HillaPushClient.class)
.addAsResource(
new StringAsset("quarkus.http.auth.basic=true\nquarkus.http.auth.proactive=true\n"),
"application.properties")
.add(new StringAsset("com.vaadin.experimental.hillaPush=true"), "vaadin-featureflags.properties"));
HillaPushClient.class));

@BeforeAll
public static void setupUsers() {
Expand Down Expand Up @@ -164,4 +162,8 @@ public void beforeRequest(Map<String, List<String>> headers) {
}
}
}

private static String testResource(String name) {
return ReactiveSecureEndpointTest.class.getPackageName().replace('.', '/') + '/' + name;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import io.quarkus.maven.dependency.Dependency;
import io.quarkus.test.QuarkusUnitTest;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.jupiter.api.extension.RegisterExtension;

Expand All @@ -32,13 +31,21 @@ class SpringDiExtensionSupportReactiveEndpointTest extends AbstractReactiveEndpo

@RegisterExtension
static final QuarkusUnitTest config = new QuarkusUnitTest()
.withConfigurationResource(testResource("test-spring-di-application.properties"))
.setForcedDependencies(List.of(Dependency.of("io.quarkus", "quarkus-spring-di", Version.getVersion())))
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)
.addClasses(ReactiveEndpoint.class, HillaPushClient.class)
.add(new StringAsset("com.vaadin.experimental.hillaPush=true"), "vaadin-featureflags.properties"));
.setArchiveProducer(() ->
ShrinkWrap.create(JavaArchive.class).addClasses(ReactiveEndpoint.class, HillaPushClient.class));

@Override
public String getEndpointName() {
return ENDPOINT_NAME;
}

private static String testResource(String name) {
return SpringDiExtensionSupportReactiveEndpointTest.class
.getPackageName()
.replace('.', '/')
+ '/'
+ name;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,16 @@ class SpringDiExtensionsSupportTest extends AbstractEndpointControllerTest {

@RegisterExtension
static final QuarkusUnitTest config = new QuarkusUnitTest()
.withConfigurationResource(testResource("test-spring-di-application.properties"))
.setForcedDependencies(List.of(Dependency.of("io.quarkus", "quarkus-spring-di", Version.getVersion())))
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)
.addClasses(TestUtils.class, Pojo.class, TestBrowserCallable.class));

protected String getEndpointName() {
return ENDPOINT_NAME;
}

private static String testResource(String name) {
return SpringDiExtensionsSupportTest.class.getPackageName().replace('.', '/') + '/' + name;
}
}

0 comments on commit a42db57

Please sign in to comment.