From af94f2da45006c2bf93a178c6bcc16d105144719 Mon Sep 17 00:00:00 2001 From: caalador Date: Mon, 4 Nov 2024 17:10:57 +0200 Subject: [PATCH] fix: Theme asset collection and ComponentTracker path check (#20390) Fix collection of theme assets in windows. Fix componentTracker patch check in windows. --- .../vaadin/flow/component/internal/ComponentTracker.java | 9 ++++++--- .../plugins/application-theme-plugin/theme-copy.js | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/flow-server/src/main/java/com/vaadin/flow/component/internal/ComponentTracker.java b/flow-server/src/main/java/com/vaadin/flow/component/internal/ComponentTracker.java index 3a86968fd7a..cb6e153b6ff 100644 --- a/flow-server/src/main/java/com/vaadin/flow/component/internal/ComponentTracker.java +++ b/flow-server/src/main/java/com/vaadin/flow/component/internal/ComponentTracker.java @@ -147,9 +147,12 @@ public File findSourceFile(AbstractConfiguration configuration) { } File src = configuration.getJavaSourceFolder(); - if (ext.equals(".kt") && src.getPath().endsWith("/java")) { - src = new File(src.getPath().substring(0, - src.getPath().lastIndexOf("/java")) + "/kotlin"); + + // Windows path is with '\' and not '/'. normalize path for check. + String path = src.getPath().replaceAll("\\\\", "/"); + if (ext.equals(".kt") && path.endsWith("/java")) { + src = new File(path.substring(0, path.lastIndexOf("/java")) + + "/kotlin"); } File javaFile = new File(src, cls.replace(".", File.separator) + ext); diff --git a/flow-server/src/main/resources/plugins/application-theme-plugin/theme-copy.js b/flow-server/src/main/resources/plugins/application-theme-plugin/theme-copy.js index 062ec639ca1..87d62a9be74 100644 --- a/flow-server/src/main/resources/plugins/application-theme-plugin/theme-copy.js +++ b/flow-server/src/main/resources/plugins/application-theme-plugin/theme-copy.js @@ -142,7 +142,8 @@ function copyStaticAssets(themeName, themeProperties, projectStaticAssetsOutputF Object.keys(assets).forEach((module) => { const copyRules = assets[module]; Object.keys(copyRules).forEach((copyRule) => { - const nodeSources = resolve('node_modules/', module, copyRule); + // Glob doesn't work with windows path separator so replacing it here. + const nodeSources = resolve('node_modules/', module, copyRule).replace(/\\/g,'/'); const files = globSync(nodeSources, { nodir: true }); const targetFolder = resolve(projectStaticAssetsOutputFolder, 'themes', themeName, copyRules[copyRule]);