Skip to content

Commit c664ff6

Browse files
authored
fix: Try determining the project folder from the classpath (#16266)
Resolves the correct project folder when running a Vaadin project inside a multi module project Fixes #16265
1 parent 94d92d9 commit c664ff6

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

‎flow-server/src/main/java/com/vaadin/flow/server/AbstractConfiguration.java‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import java.io.File;
1919
import java.io.Serializable;
20+
import java.net.URL;
2021
import java.nio.file.Path;
2122
import java.nio.file.Paths;
2223

@@ -187,6 +188,17 @@ default File getProjectFolder() {
187188
}
188189

189190
String folder = getStringProperty(FrontendUtils.PROJECT_BASEDIR, null);
191+
if (folder == null) {
192+
/* Try determining the project folder from the classpath. */
193+
URL url = getClass().getClassLoader().getResource(".");
194+
if (url != null && url.getProtocol().equals("file")) {
195+
String path = url.getPath();
196+
if (path.endsWith("/target/classes/")) {
197+
folder = path.replaceFirst("/target/classes/$", "");
198+
}
199+
}
200+
}
201+
190202
if (folder == null) {
191203
/*
192204
* Accept user.dir or cwd as a fallback only if the directory seems

0 commit comments

Comments
 (0)