Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: prevent failure when Spring MainClassFinder is not available #3210

Merged
merged 4 commits into from
Feb 11, 2025
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ static List<Class<?>> findEndpointClasses(
// Determine the main application class
var applicationClass = determineApplicationClass(engineConfiguration);
if (applicationClass == null) {
LOGGER.warn("This project has not been recognized as a Spring Boot"
+ " application because a main class could not be found."
+ " Hilla services will not be available.");
return List.of();
}

Expand All @@ -55,10 +52,26 @@ private static String determineApplicationClass(
if (mainClass != null) {
return mainClass;
}

return MainClassFinder.findSingleMainClass(
engineConfiguration.getClassesDir().toFile(),
SPRING_BOOT_APPLICATION_CLASS_NAME);
try {
mainClass = MainClassFinder.findSingleMainClass(
engineConfiguration.getClassesDir().toFile(),
SPRING_BOOT_APPLICATION_CLASS_NAME);
if (mainClass == null) {
LOGGER.warn(
"This project has not been recognized as a Spring Boot"
+ " application because a main class could not be found."
+ " Hilla services will not be available.");
}
return mainClass;
} catch (NoClassDefFoundError e) {
LOGGER.debug(
"Spring Boot org.springframework.boot.loader.toolsMainClassFinder class not found. "
mcollovati marked this conversation as resolved.
Show resolved Hide resolved
+ "Can happen when a Maven project is configured to use com.vaadin:flow-maven-plugin instead of com.vaadin:vaadin-maven-plugin, "
+ "for example projects using Vaadin Multiplatform Runtime. "
+ "If Hilla is not a project requirement exclude it from the dependency tree, "
+ "otherwise consider replacing com.vaadin:flow-maven-plugin with com.vaadin:hilla-maven-plugin.");
return null;
}
}

private static Path generateAotArtifacts(
Expand Down
Loading