-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fix class and resource loading in maven plugin
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
- Loading branch information
1 parent
80813cb
commit 395f38c
Showing
43 changed files
with
3,030 additions
and
810 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
**/src/main/bundles | ||
**/src/main/frontend/generated | ||
**/src/main/frontend/index.html | ||
**/package*.json | ||
**/tsconfig.json | ||
**/types.d.ts | ||
**/vite.*.ts |
18 changes: 18 additions & 0 deletions
18
...ns/flow-maven-plugin/src/it/appshellconfiguration-external-annotations/invoker.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# | ||
# Copyright 2000-2024 Vaadin Ltd. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
# use this file except in compliance with the License. You may obtain a copy of | ||
# the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations under | ||
# the License. | ||
# | ||
invoker.goals=clean package | ||
invoker.profiles.1=prepare-frontend-after-compile | ||
invoker.profiles.2=build-frontend-full-dep-scan |
118 changes: 118 additions & 0 deletions
118
flow-plugins/flow-maven-plugin/src/it/appshellconfiguration-external-annotations/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>com.vaadin.test.maven</groupId> | ||
<artifactId>classfinder-lookup</artifactId> | ||
<version>1.0</version> | ||
<packaging>jar</packaging> | ||
|
||
<description><![CDATA[ | ||
Tests that prepare-frontend does not fail when both plugin and ClassFinder loads | ||
transitive classes from different classloaders. | ||
In this test the plugin loads classes from spring-data-commons (RepositoryFactoryBeanSupport) | ||
that implements ApplicationEventPublisherAware that is however in spring-context artifact. | ||
Since spring-context is referenced only by the project, by default the plugin class loader | ||
would not able to find ApplicationEventPublisherAware when loading RepositoryFactoryBeanSupport, | ||
causing a ClassNotFoundException exception. | ||
Usually this error happens when prepare-fronted is called after compilation, or when build-frontend is | ||
configured with optimizeBundle=false, causing FullDependenciesScanner to be used. | ||
Flow maven plugin must make sure that class loading works fine combining plugin and project dependencies. | ||
]]></description> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<maven.compiler.release>17</maven.compiler.release> | ||
<maven.compiler.source>${maven.compiler.release}</maven.compiler.source> | ||
<maven.compiler.target>${maven.compiler.release}</maven.compiler.target> | ||
<maven.test.skip>true</maven.test.skip> | ||
|
||
<flow.version>@project.version@</flow.version> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.vaadin</groupId> | ||
<artifactId>flow-server</artifactId> | ||
<version>${flow.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.vaadin</groupId> | ||
<artifactId>flow-client</artifactId> | ||
<version>${flow.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.data</groupId> | ||
<artifactId>spring-data-jpa</artifactId> | ||
<version>3.3.4</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.13.0</version> | ||
</plugin> | ||
<plugin> | ||
<groupId>com.vaadin</groupId> | ||
<artifactId>flow-maven-plugin</artifactId> | ||
<version>${flow.version}</version> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.data</groupId> | ||
<artifactId>spring-data-commons</artifactId> | ||
<version>3.3.4</version> | ||
</dependency> | ||
</dependencies> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<profiles> | ||
<profile> | ||
<id>prepare-frontend-after-compile</id> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>com.vaadin</groupId> | ||
<artifactId>flow-maven-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<phase>compile</phase> | ||
<goals> | ||
<goal>prepare-frontend</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</profile> | ||
<profile> | ||
<id>build-frontend-full-dep-scan</id> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>com.vaadin</groupId> | ||
<artifactId>flow-maven-plugin</artifactId> | ||
<configuration> | ||
<optimizeBundle>false</optimizeBundle> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>prepare-frontend</goal> | ||
<goal>build-frontend</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</profile> | ||
</profiles> | ||
|
||
</project> |
Oops, something went wrong.