2727import java .util .stream .Collectors ;
2828import java .util .stream .Stream ;
2929
30+ import org .apache .maven .artifact .Artifact ;
31+ import org .apache .maven .artifact .DependencyResolutionRequiredException ;
32+ import org .apache .maven .plugin .AbstractMojo ;
33+ import org .apache .maven .plugins .annotations .Parameter ;
34+ import org .apache .maven .project .MavenProject ;
35+
3036import com .vaadin .flow .internal .StringUtil ;
3137import com .vaadin .flow .plugin .base .BuildFrontendUtil ;
3238import com .vaadin .flow .plugin .base .PluginAdapterBase ;
3743import com .vaadin .flow .server .frontend .installer .NodeInstaller ;
3844import com .vaadin .flow .server .frontend .installer .Platform ;
3945import com .vaadin .flow .server .frontend .scanner .ClassFinder ;
40- import org .apache .maven .artifact .Artifact ;
41- import org .apache .maven .artifact .DependencyResolutionRequiredException ;
42- import org .apache .maven .plugin .AbstractMojo ;
43- import org .apache .maven .plugins .annotations .Parameter ;
44- import org .apache .maven .project .MavenProject ;
4546
4647import static com .vaadin .flow .server .Constants .VAADIN_SERVLET_RESOURCES ;
4748import static com .vaadin .flow .server .Constants .VAADIN_WEBAPP_RESOURCES ;
@@ -241,6 +242,8 @@ public abstract class FlowModeAbstractMojo extends AbstractMojo
241242 @ Parameter (property = InitParameters .APPLICATION_IDENTIFIER )
242243 private String applicationIdentifier ;
243244
245+ private ClassFinder classFinder ;
246+
244247 /**
245248 * Generates a List of ClasspathElements (Run and CompileTime) from a
246249 * MavenProject.
@@ -274,10 +277,8 @@ public static List<String> getClasspathElements(MavenProject project) {
274277 * Target Maven project
275278 * @return true if Hilla is available, false otherwise
276279 */
277- public static boolean isHillaAvailable (MavenProject mavenProject ) {
278- List <String > classpathElements = FlowModeAbstractMojo
279- .getClasspathElements (mavenProject );
280- return BuildFrontendUtil .getClassFinder (classpathElements ).getResource (
280+ public boolean isHillaAvailable (MavenProject mavenProject ) {
281+ return getOrCreateClassFinder (mavenProject ).getResource (
281282 "com/vaadin/hilla/EndpointController.class" ) != null ;
282283 }
283284
@@ -292,7 +293,7 @@ public static boolean isHillaAvailable(MavenProject mavenProject) {
292293 * @return {@code true} if Hilla is available and Hilla views are used,
293294 * {@code false} otherwise
294295 */
295- public static boolean isHillaUsed (MavenProject mavenProject ,
296+ public boolean isHillaUsed (MavenProject mavenProject ,
296297 File frontendDirectory ) {
297298 return isHillaAvailable (mavenProject )
298299 && FrontendUtils .isHillaViewsUsed (frontendDirectory );
@@ -325,11 +326,15 @@ public File generatedTsFolder() {
325326
326327 @ Override
327328 public ClassFinder getClassFinder () {
329+ return getOrCreateClassFinder (project );
330+ }
328331
329- List <String > classpathElements = getClasspathElements (project );
330-
331- return BuildFrontendUtil .getClassFinder (classpathElements );
332-
332+ private ClassFinder getOrCreateClassFinder (MavenProject project ) {
333+ if (classFinder == null ) {
334+ List <String > classpathElements = getClasspathElements (project );
335+ classFinder = BuildFrontendUtil .getClassFinder (classpathElements );
336+ }
337+ return classFinder ;
333338 }
334339
335340 @ Override
0 commit comments