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: fix class and resource loading in maven plugin #20457

Conversation

mcollovati
Copy link
Collaborator

Description

Extracts logics from Flow mojos to separated task classes, loaded with a custom class loader composed by project and plugin dependencies, with the firsts having precedence on the others.
This make sure classes are always loaded from the same class loader, preventing errors like having a class loaded by plugin class loader, but one of its parent present only in project class loader (see #19616). It also prevents retrieving resources from plugin dependency instead of from same artifact defined in the project (see #19009). This refactoring caches a ClassFinder per execution phase, so that it can be reused by multiple goals configured to run on the same phase. It also removes the need to instantiate a ClassFinder to checking for Hilla classes, limiting the number or scans processed during the build.

Fixes #19616
Fixes #19009
Fixes #20385

Extracts logics from Flow mojos to separated task classes, loaded with a
custom class loader composed by project and plugin dependencies, with
the firsts having precedence on the others.
This make sure classes are always loaded from the same class loader,
preventing errors like having a class loaded by plugin class loader, but
one of its parent present only in project class loader (see #19616).
It also prevents retrieving resources from plugin dependency instead of
from same artifact defined in the project (see #19009).
This refactoring caches a ClassFinder per execution phase, so that it can be
reused by multiple goals configured to run on the same phase.
It also removes the need to instantiate a ClassFinder to checking for Hilla
classes, limiting the number or scans processed during the build.

Fixes #19616
Fixes #19009
Fixes #20385
@mcollovati
Copy link
Collaborator Author

This is another attempt to resolve the issues, without accessing Maven internal APIs as done in #20344

Copy link

sonarcloud bot commented Nov 12, 2024

Copy link

Test Results

1 141 files   -  5  1 141 suites   - 5   1h 31m 55s ⏱️ + 2m 13s
7 492 tests + 3  7 443 ✅ + 4  49 💤  - 1  0 ❌ ±0 
7 859 runs  +29  7 800 ✅ +30  59 💤  - 1  0 ❌ ±0 

Results for commit 395f38c. ± Comparison against base commit 80813cb.

This pull request removes 48 and adds 51 tests. Note that renamed tests count towards both.
com.vaadin.flow.mixedtest.ui.IdTestIT(production) ‑ Unknown test
com.vaadin.flow.mixedtest.ui.IdTestIT(production) ‑ testIds[any_Chrome_]
com.vaadin.flow.mixedtest.ui.NpmUsedIT(production) ‑ npmIsUsed
com.vaadin.flow.mixedtest.ui.PolymerIdTestIT(production) ‑ testIds[any_Chrome_]
com.vaadin.flow.plugin.maven.BuildFrontendMojoTest ‑ changedBuildDirectory_resourcesCopiedNoTargetFolderExists
com.vaadin.flow.plugin.maven.BuildFrontendMojoTest ‑ existingTokenFile_customApplicationIdentifierWritten
com.vaadin.flow.plugin.maven.BuildFrontendMojoTest ‑ existingTokenFile_defaultApplicationIdentifierWritten
com.vaadin.flow.plugin.maven.BuildFrontendMojoTest ‑ existingTokenFile_parametersShouldBeRemoved
com.vaadin.flow.plugin.maven.BuildFrontendMojoTest ‑ mavenGoalWhenPackageJsonContainsDependencies_onlyFrameworkHandledDependencyIsTouched
com.vaadin.flow.plugin.maven.BuildFrontendMojoTest ‑ mavenGoal_generateOpenApiJson_when_itIsInClientSideMode
…
com.vaadin.flow.plugin.maven.BuildFrontendTaskTest ‑ changedBuildDirectory_resourcesCopiedNoTargetFolderExists
com.vaadin.flow.plugin.maven.BuildFrontendTaskTest ‑ existingTokenFile_customApplicationIdentifierWritten
com.vaadin.flow.plugin.maven.BuildFrontendTaskTest ‑ existingTokenFile_defaultApplicationIdentifierWritten
com.vaadin.flow.plugin.maven.BuildFrontendTaskTest ‑ existingTokenFile_parametersShouldBeRemoved
com.vaadin.flow.plugin.maven.BuildFrontendTaskTest ‑ mavenGoalWhenPackageJsonContainsDependencies_onlyFrameworkHandledDependencyIsTouched
com.vaadin.flow.plugin.maven.BuildFrontendTaskTest ‑ mavenGoal_generateOpenApiJson_when_itIsInClientSideMode
com.vaadin.flow.plugin.maven.BuildFrontendTaskTest ‑ mavenGoal_generateTsFiles_when_enabled
com.vaadin.flow.plugin.maven.BuildFrontendTaskTest ‑ noTokenFile_noTokenFileShouldBeCreated
com.vaadin.flow.plugin.maven.BuildFrontendTaskTest ‑ shouldNot_ContainExternalUrls
com.vaadin.flow.plugin.maven.BuildFrontendTaskTest ‑ shouldNot_UpdateJsFile_when_NoChanges
…

@mcollovati mcollovati closed this Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment