Skip to content

Commit

Permalink
Fix bug and add livereload cache for dev-ui
Browse files Browse the repository at this point in the history
  • Loading branch information
ia3andy committed May 6, 2024
1 parent 3bdb376 commit 0fdbdc8
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ record WebDependencyAsset(String name,
}

public record DevUIWebDependency(String type,
String webDependencyName,
String name,
String version,
WebDependencyAsset rootAsset) {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import io.quarkus.bootstrap.classloading.QuarkusClassLoader;
import io.quarkus.deployment.IsDevelopment;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.builditem.LiveReloadBuildItem;
import io.quarkus.maven.dependency.ArtifactKey;
import io.quarkus.maven.dependency.ResolvedDependency;
import io.quarkus.vertx.http.runtime.HttpBuildTimeConfig;
Expand All @@ -36,7 +37,16 @@ public class WebBundlerDevUIWebDependenciesProcessor {
@BuildStep(onlyIf = IsDevelopment.class)
public DevUIWebDependenciesBuildItem findWebDependenciesAssets(
HttpBuildTimeConfig httpConfig,
LiveReloadBuildItem liveReload,
WebDependenciesBuildItem webDependencies) {
final DevUIWebDependenciesContext webDependenciesContext = liveReload
.getContextObject(DevUIWebDependenciesContext.class);

if (liveReload.isLiveReload() && webDependenciesContext != null
&& webDependenciesContext.dependencies().equals(webDependencies.list())) {
return new DevUIWebDependenciesBuildItem(webDependenciesContext.devUIWebDependencies());
}

final List<ClassPathElement> providers = new ArrayList<>();
providers.addAll(QuarkusClassLoader.getElements(PREFIX + MVNPM_PATH, false));
providers.addAll(QuarkusClassLoader.getElements(PREFIX + WEBJARS_PATH, false));
Expand All @@ -50,8 +60,13 @@ public DevUIWebDependenciesBuildItem findWebDependenciesAssets(

final List<DevUIWebDependency> webJarDeps = new ArrayList<>(webDependencies.list().size());
for (WebDependenciesBuildItem.Dependency dependency : webDependencies.list()) {
webJarDeps.add(getDep(httpConfig, providersByKeys, dependency));
final DevUIWebDependency dep = getDep(httpConfig, providersByKeys, dependency);
if (dep != null) {
webJarDeps.add(dep);
}
}
liveReload.setContextObject(DevUIWebDependenciesContext.class,
new DevUIWebDependenciesContext(webDependencies.list(), webJarDeps));
return new DevUIWebDependenciesBuildItem(webJarDeps);
}
return new DevUIWebDependenciesBuildItem(List.of());
Expand Down Expand Up @@ -149,4 +164,9 @@ private WebDependencyAsset createAssetForDep(Path rootPath, String urlBase, bool
return root;
}

public record DevUIWebDependenciesContext(List<WebDependenciesBuildItem.Dependency> dependencies,
List<DevUIWebDependency> devUIWebDependencies) {

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ export class QwcWebBundlerWebDependencies extends LitElement {
return html`
<vaadin-tabs @selected-changed="${this._tabSelectedChanged}" orientation="vertical">
${this._webDependencies.map(webDependency => html`
<vaadin-tab id="${webDependency.webDependencyName}">
${webDependency.webDependencyName + " (" + webDependency.version + ")"}
<vaadin-tab id="${webDependency.name}">
${webDependency.name + " (" + webDependency.version + ")"}
</vaadin-tab>`)}
</vaadin-tabs>
Expand All @@ -69,7 +69,7 @@ export class QwcWebBundlerWebDependencies extends LitElement {
};

return html`
<div tab="${dep.webDependencyName}" class="tabcontent">
<div tab="${dep.name}" class="tabcontent">
<vaadin-grid .itemHasChildrenPath="${'children'}" .dataProvider="${dataProvider}"
theme="compact no-border" class="full-height">
<vaadin-grid-tree-column path="name"></vaadin-grid-tree-column>
Expand Down
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/includes/attributes.adoc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
:project-version: 1.4.0
:project-version: 1.5.0.CR1

:maven-version: 3.8.1+

Expand Down

0 comments on commit 0fdbdc8

Please sign in to comment.