|
| 1 | +/*- |
| 2 | + * #%L |
| 3 | + * Grid Helpers Add-on |
| 4 | + * %% |
| 5 | + * Copyright (C) 2022 - 2026 Flowing Code |
| 6 | + * %% |
| 7 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | + * you may not use this file except in compliance with the License. |
| 9 | + * You may obtain a copy of the License at |
| 10 | + * |
| 11 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | + * |
| 13 | + * Unless required by applicable law or agreed to in writing, software |
| 14 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | + * See the License for the specific language governing permissions and |
| 17 | + * limitations under the License. |
| 18 | + * #L% |
| 19 | + */ |
| 20 | + |
| 21 | +package com.flowingcode.vaadin.addons.gridhelpers; |
| 22 | + |
| 23 | +import com.vaadin.flow.component.dependency.CssImport; |
| 24 | +import com.vaadin.flow.server.ServiceInitEvent; |
| 25 | +import com.vaadin.flow.server.VaadinServiceInitListener; |
| 26 | + |
| 27 | +/** |
| 28 | + * Ensures that the addon's grid styles are always included in the production bundle. |
| 29 | + * |
| 30 | + * <p>{@code VaadinServiceInitListener} subtypes are discovered via ClassGraph reflection and are |
| 31 | + * always treated as entry points, regardless of how consumers use the addon. Placing the |
| 32 | + * {@code @CssImport} annotation here guarantees that the grid styles are included even when |
| 33 | + * {@link GridHelper} is not reachable through bytecode analysis. |
| 34 | + * |
| 35 | + * @see <a href="https://github.com/FlowingCode/GridHelpers/issues/171">Issue #171</a> |
| 36 | + */ |
| 37 | +@CssImport(value = GridHelper.GRID_STYLES, themeFor = "vaadin-grid") |
| 38 | +public class GridHelperServiceInitListener implements VaadinServiceInitListener { |
| 39 | + |
| 40 | + @Override |
| 41 | + public void serviceInit(ServiceInitEvent event) { |
| 42 | + // No initialization needed; this class exists solely to anchor the |
| 43 | + // @CssImport annotation so it is always picked up during the production |
| 44 | + // bundle build via ClassGraph entry-point seeding. |
| 45 | + } |
| 46 | +} |
0 commit comments