Skip to content

Commit

Permalink
Merge pull request #21190 from geoand/rr-kogito
Browse files Browse the repository at this point in the history
Ensure that Vertx Static resource handler can pick up generated resources
  • Loading branch information
geoand authored Nov 5, 2021
2 parents c55e2dd + 53575f0 commit cfcc660
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 0 deletions.
5 changes: 5 additions & 0 deletions bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1587,6 +1587,11 @@
<artifactId>quarkus-vertx-http-deployment</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx-http-deployment-spi</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-reactive-routes</artifactId>
Expand Down
23 changes: 23 additions & 0 deletions extensions/vertx-http/deployment-spi/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?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">
<parent>
<artifactId>quarkus-vertx-http-parent</artifactId>
<groupId>io.quarkus</groupId>
<version>999-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>quarkus-vertx-http-deployment-spi</artifactId>
<name>Quarkus - Vert.x - HTTP - Deployment - SPI</name>

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

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package io.quarkus.vertx.http.deployment.spi;

import io.quarkus.builder.item.MultiBuildItem;

/**
* Meant to be used by extensions that generate resource into {@code META-INF/resources}.
* These resources cannot be picked up automatically by the standard Static resources handling because
* when the check is made, these resources don't exist yet on the file system.
*
* The value of {@code path} should be prefixed with {@code '/'} and is assumed to be a path under {@code 'META-INF/resources'}.
*/
public final class AdditionalStaticResourceBuildItem extends MultiBuildItem {

private final String path;
private final boolean isDirectory;

public AdditionalStaticResourceBuildItem(String path, boolean isDirectory) {
this.path = path;
this.isDirectory = isDirectory;
}

public String getPath() {
return path;
}

public boolean isDirectory() {
return isDirectory;
}
}
4 changes: 4 additions & 0 deletions extensions/vertx-http/deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx-http</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx-http-deployment-spi</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-mutiny-deployment</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import io.quarkus.deployment.pkg.steps.NativeBuild;
import io.quarkus.runtime.util.ClassPathUtils;
import io.quarkus.vertx.core.deployment.CoreVertxBuildItem;
import io.quarkus.vertx.http.deployment.spi.AdditionalStaticResourceBuildItem;
import io.quarkus.vertx.http.runtime.StaticResourcesRecorder;

/**
Expand Down Expand Up @@ -93,12 +94,16 @@ public int hashCode() {

@BuildStep
void collectStaticResources(Capabilities capabilities, ApplicationArchivesBuildItem applicationArchivesBuildItem,
List<AdditionalStaticResourceBuildItem> additionalStaticResources,
BuildProducer<StaticResourcesBuildItem> staticResources) throws Exception {
if (capabilities.isPresent(Capability.SERVLET)) {
// Servlet container handles static resources
return;
}
Set<StaticResourcesBuildItem.Entry> paths = getClasspathResources(applicationArchivesBuildItem);
for (AdditionalStaticResourceBuildItem bi : additionalStaticResources) {
paths.add(new StaticResourcesBuildItem.Entry(bi.getPath(), bi.isDirectory()));
}
if (!paths.isEmpty()) {
staticResources.produce(new StaticResourcesBuildItem(paths));
}
Expand Down
1 change: 1 addition & 0 deletions extensions/vertx-http/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
<module>runtime</module>
<module>dev-console-spi</module>
<module>dev-console-runtime-spi</module>
<module>deployment-spi</module>
</modules>
</project>

0 comments on commit cfcc660

Please sign in to comment.