@@ -68,6 +68,9 @@ applyv25patches() {
6868 done
6969 addGradleDep " commons-io" " commons-io" developmentOnly
7070 ;;
71+ archetype* |bookstore-* |client-server-addon-template|flow-spring-examples|initializer-vaadin-maven-flow|initializer-vaadin-maven-react|latest-java_partial-auth_partial-prerelease|business-app-starter-flow|layout-examples|mpr-demo|releases-graph|spreadsheet-demo|testbench-demo|vaadin-database-example|vaadin-form-example|vaadin-localization-example|vaadin-oauth-example|vaadin-rest-example)
72+ # # TODO: document that if no @Theme it needs to be added
73+ addLumoStyleSheet;;
7174 esac
7275
7376 case $vers_ in
@@ -261,6 +264,34 @@ updateTheme() {
261264 perl -pi -e ' s|(public\s+class\s+.*?implements\s+AppShellConfigurator\s*\{)|\@com.vaadin.flow.component.dependency.CssImport("\@vaadin/vaadin-lumo-styles/lumo.css")\n\1|' $F
262265 fi
263266}
267+
268+ # # Add @StyleSheet(Lumo.STYLESHEET) to AppShellConfigurator classes that don't have @Theme or @StyleSheet
269+ # # TODO: needs to be documented in vaadin migration guide to 25
270+ addLumoStyleSheet () {
271+ F=` grep -rl ' implements AppShellConfigurator' . --include=' *.java' `
272+ [ -z " $F " ] && return 0
273+
274+ for file in $F ; do
275+ # Skip if file already has @Theme or @StyleSheet
276+ grep -q ' @Theme' " $file " && continue
277+ grep -q ' @StyleSheet' " $file " && continue
278+
279+ [ -z " $TEST " ] && warn " adding @StyleSheet(Lumo.STYLESHEET) to $file " || cmd " ## adding @StyleSheet(Lumo.STYLESHEET) to $file "
280+
281+ # Add import for Lumo if not present
282+ if ! grep -q ' import com.vaadin.flow.theme.lumo.Lumo;' " $file " ; then
283+ perl -pi -e ' s|^(package\s+.*?;\s*)|\1\nimport com.vaadin.flow.theme.lumo.Lumo;|' " $file "
284+ fi
285+
286+ # Add import for StyleSheet if not present
287+ if ! grep -q ' import com.vaadin.flow.component.dependency.StyleSheet;' " $file " ; then
288+ perl -pi -e ' s|^(package\s+.*?;\s*)|\1\nimport com.vaadin.flow.component.dependency.StyleSheet;|' " $file "
289+ fi
290+
291+ # Add @StyleSheet(Lumo.STYLESHEET) annotation before the class declaration
292+ perl -pi -e ' s|(public\s+class\s+\w+\s+implements\s+AppShellConfigurator)|\@StyleSheet(Lumo.STYLESHEET)\n\1|' " $file "
293+ done
294+ }
264295removeJsImport () {
265296 value=$1
266297 # remove @JsModule("$1") if present
0 commit comments