Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug and add livereload cache for dev-ui #212

Merged
merged 1 commit into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading