From 611a15a2c796ac05e81850a52f881507ec6bd899 Mon Sep 17 00:00:00 2001 From: Javier Godoy <11554739+javier-godoy@users.noreply.github.com> Date: Thu, 26 Mar 2026 12:30:24 -0300 Subject: [PATCH] fix: register VaadinServiceInitListener to bundle grid styles Close #171 --- .../GridHelperServiceInitListener.java | 46 +++++++++++++++++++ ...adin.flow.server.VaadinServiceInitListener | 1 + 2 files changed, 47 insertions(+) create mode 100644 src/main/java/com/flowingcode/vaadin/addons/gridhelpers/GridHelperServiceInitListener.java create mode 100644 src/main/resources/META-INF/services/com.vaadin.flow.server.VaadinServiceInitListener diff --git a/src/main/java/com/flowingcode/vaadin/addons/gridhelpers/GridHelperServiceInitListener.java b/src/main/java/com/flowingcode/vaadin/addons/gridhelpers/GridHelperServiceInitListener.java new file mode 100644 index 0000000..25f3be4 --- /dev/null +++ b/src/main/java/com/flowingcode/vaadin/addons/gridhelpers/GridHelperServiceInitListener.java @@ -0,0 +1,46 @@ +/*- + * #%L + * Grid Helpers Add-on + * %% + * Copyright (C) 2022 - 2026 Flowing Code + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + +package com.flowingcode.vaadin.addons.gridhelpers; + +import com.vaadin.flow.component.dependency.CssImport; +import com.vaadin.flow.server.ServiceInitEvent; +import com.vaadin.flow.server.VaadinServiceInitListener; + +/** + * Ensures that the addon's grid styles are always included in the production bundle. + * + *

{@code VaadinServiceInitListener} subtypes are discovered via ClassGraph reflection and are + * always treated as entry points, regardless of how consumers use the addon. Placing the + * {@code @CssImport} annotation here guarantees that the grid styles are included even when + * {@link GridHelper} is not reachable through bytecode analysis. + * + * @see Issue #171 + */ +@CssImport(value = GridHelper.GRID_STYLES, themeFor = "vaadin-grid") +public class GridHelperServiceInitListener implements VaadinServiceInitListener { + + @Override + public void serviceInit(ServiceInitEvent event) { + // No initialization needed; this class exists solely to anchor the + // @CssImport annotation so it is always picked up during the production + // bundle build via ClassGraph entry-point seeding. + } +} diff --git a/src/main/resources/META-INF/services/com.vaadin.flow.server.VaadinServiceInitListener b/src/main/resources/META-INF/services/com.vaadin.flow.server.VaadinServiceInitListener new file mode 100644 index 0000000..e483373 --- /dev/null +++ b/src/main/resources/META-INF/services/com.vaadin.flow.server.VaadinServiceInitListener @@ -0,0 +1 @@ +com.flowingcode.vaadin.addons.gridhelpers.GridHelperServiceInitListener