-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: enforce plugin-required dependencies and log incompatibilities (#…
…20601) (#20604) The Flow Maven Plugin uses a class loader that combines project and plugin dependencies to ensure class scanning happens on runtime artifacts. However, plugin execution may fail if the project defines dependency versions incompatible with those used by the plugin. This change enforces the use of plugin-defined versions for certain dependencies not directly used by Flow at runtime. Additionally, it logs potential incompatibilities for other dependencies if the build fails. Fixes vaadin/mpr-demo#23 Co-authored-by: Marco Collovati <marco@vaadin.com>
- Loading branch information
1 parent
ddfb795
commit ef0e8a6
Showing
12 changed files
with
463 additions
and
24 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
18 changes: 18 additions & 0 deletions
18
flow-plugins/flow-maven-plugin/src/it/offending-dependency-project/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.buildResult=failure |
68 changes: 68 additions & 0 deletions
68
flow-plugins/flow-maven-plugin/src/it/offending-dependency-project/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,68 @@ | ||
<?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>offending-dependency-project</artifactId> | ||
<version>1.0</version> | ||
<packaging>jar</packaging> | ||
|
||
<description> | ||
Tests that project dependencies does not override plugin required dependency. | ||
</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> | ||
<maven.version>3.9.9</maven.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> | ||
<!-- commons-io 2.6 is incompatible with Flow plugin --> | ||
<dependency> | ||
<groupId>commons-io</groupId> | ||
<artifactId>commons-io</artifactId> | ||
<version>2.6</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> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>prepare-frontend</goal> | ||
<goal>build-frontend</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
20 changes: 20 additions & 0 deletions
20
...c/it/offending-dependency-project/src/main/java/com/vaadin/test/ProjectFlowExtension.java
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,20 @@ | ||
package com.vaadin.test; | ||
|
||
import java.util.List; | ||
|
||
import com.vaadin.flow.server.frontend.Options; | ||
import com.vaadin.flow.server.frontend.TypeScriptBootstrapModifier; | ||
import com.vaadin.flow.server.frontend.scanner.FrontendDependenciesScanner; | ||
|
||
/** | ||
* Hello world! | ||
*/ | ||
public class ProjectFlowExtension implements TypeScriptBootstrapModifier { | ||
|
||
@Override | ||
public void modify(List<String> bootstrapTypeScript, Options options, | ||
FrontendDependenciesScanner frontendDependenciesScanner) { | ||
System.out.println("ProjectFlowExtension"); | ||
bootstrapTypeScript.add("(window as any).testProject=1;"); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
flow-plugins/flow-maven-plugin/src/it/offending-dependency-project/verify.bsh
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,15 @@ | ||
import java.nio.file.*; | ||
|
||
flowTsx = basedir.toPath().resolve("build.log"); | ||
if ( !Files.exists(flowTsx, new LinkOption[0]) ) | ||
{ | ||
throw new RuntimeException("build.log not found"); | ||
} | ||
|
||
lines = Files.readString(flowTsx); | ||
if ( | ||
!lines.contains("Found dependencies defined with different versions in project and Vaadin maven plugin") && | ||
!lines.matches("^commons-io:commons-io.*\\[2\\.6\\],.*") | ||
) { | ||
throw new RuntimeException("Offending commons-io 2.6 dependency not detected"); | ||
} |
17 changes: 17 additions & 0 deletions
17
flow-plugins/flow-maven-plugin/src/it/plugin-pinned-deps-project/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,17 @@ | ||
# | ||
# 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 |
Oops, something went wrong.