Skip to content

Commit faeb4b6

Browse files
authored
fix: check legacy frontend folder from prepare step (#22401)
1 parent 1b0462a commit faeb4b6

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

flow-plugins/flow-maven-plugin/src/main/java/com/vaadin/flow/plugin/maven/PrepareFrontendMojo.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.apache.maven.plugins.annotations.ResolutionScope;
2525

2626
import com.vaadin.flow.plugin.base.BuildFrontendUtil;
27+
import com.vaadin.flow.server.frontend.FrontendUtils;
2728

2829
/**
2930
* This goal checks that node and npm tools are installed and creates or updates
@@ -52,6 +53,8 @@ protected void executeInternal()
5253
// been updated in order to trigger server re-deployment (#6103)
5354
triggerRefresh(tokenFile.getParentFile());
5455

56+
FrontendUtils.checkLegacyFrontendFolder(projectBaseDirectory());
57+
5558
try {
5659
BuildFrontendUtil.prepareFrontend(this);
5760
} catch (Exception exception) {

flow-server/src/main/java/com/vaadin/flow/server/frontend/FrontendUtils.java

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -641,24 +641,36 @@ public static File resolveFrontendPath(File projectRoot,
641641
* @return frontend directory to use
642642
*/
643643
public static File getFrontendFolder(File projectRoot, File frontendDir) {
644-
File legacyDir = new File(projectRoot, LEGACY_FRONTEND_DIR);
644+
if (!frontendDir.exists() && frontendDir.toPath()
645+
.endsWith(DEFAULT_FRONTEND_DIR.substring(2))) {
646+
File legacy = new File(projectRoot, LEGACY_FRONTEND_DIR);
647+
if (legacy.exists()) {
648+
return legacy;
649+
}
650+
}
651+
return frontendDir;
652+
}
645653

646-
if (legacyDir.exists()) {
654+
/**
655+
* Check for existence of legacy frontend folder and log a warning if it is
656+
* present.
657+
*
658+
* @param projectRoot
659+
* project's root directory
660+
*/
661+
public static void checkLegacyFrontendFolder(Path projectRoot) {
662+
if (new File(projectRoot.toString(), LEGACY_FRONTEND_DIR).exists()) {
647663
getLogger().warn(
648664
"This project has a legacy frontend directory ({}) "
649-
+ "present and it will be used as a fallback."
650-
+ "\n\nSupport for the legacy directory will be removed "
665+
+ "present and it will be used as a fallback. "
666+
+ "Support for the legacy directory will be removed "
651667
+ "in a future release. Please move its contents to "
652668
+ "the default frontend directory ({}), or delete it "
653669
+ "if its contents are not needed in the project. "
654670
+ "Also remove 'frontendDirectory' parameter that "
655671
+ "points to the legacy directory, if present.",
656672
LEGACY_FRONTEND_DIR, DEFAULT_FRONTEND_DIR);
657-
return legacyDir;
658673
}
659-
660-
// Legacy dir does not exist. Use default or custom-set dir.
661-
return frontendDir;
662674
}
663675

664676
/**

0 commit comments

Comments
 (0)