覆盖从 Maven 导入继承的 maven-surefire-plugin 的版本
Override the version of maven-surefire-plugin inherited from a Maven import
我的项目是由 Maven 驱动的,使用的 POM 不是我自己制作的(from Vaadin). Apparently the POM file I see in my project depends on some kind of inheritance of other POM files. While I see no dependency for the maven-surefire-plugin
在我自己的 POM 中,这个工件是在我的项目中找到的,正如您在这张截图的右侧所见IntelliJ 2019.
我不是 Maven maven,所以我不知道确切的细节,但在四处寻找时我发现了一些 import
行,所以我猜 Maven POM 可以动态地从其他 POM 继承。
问题是我项目中的 maven-surefire-plugin
版本很旧,版本 2.12.4。我正在尝试 运行 JUnit 5, which requires 2.22.0 or later. The current version 是 3.0.0-M3
。
查看那个粉红色箭头的左端,您可以看到我在我的 POM 中添加了一个 dependency
元素。
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M3</version>
</dependency>
在左箭头提示上,我要求 3.0.0-M3
试图覆盖在右箭头提示上看到的神秘 imported/inherited 指定版本 2.12.4
。但是我的尝试失败了,因为旧版本在执行 Maven clean
、install
后仍然存在。我什至尝试重新启动 IntelliJ。但是不行,当运行使用 Maven test
时,我的 JUnit 5 测试仍然被忽略。
➥ 是否有一些方法可以覆盖显然从某个神秘来源继承的依赖项的版本?
这是我的 POM,在尝试添加 <artifactId>maven-surefire-plugin</artifactId>
依赖项失败之前。
<?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.basilbourque.acmeapp</groupId>
<artifactId>acmeapp</artifactId>
<name>AcmeApp</name>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<failOnMissingWebXml>false</failOnMissingWebXml>
<!--<vaadin.version>11.0.1</vaadin.version>-->
<!--<vaadin.version>12.0.0.beta1</vaadin.version>-->
<vaadin.version>13.0.0.alpha3</vaadin.version>
</properties>
<repositories>
<!-- Repository used by many Vaadin add-ons -->
<repository>
<id>Vaadin Directory</id>
<url>http://maven.vaadin.com/vaadin-addons</url>
</repository>
<repository>
<id>vaadin-prereleases</id>
<url>https://maven.vaadin.com/vaadin-prereleases</url>
</repository>
</repositories>
<pluginRepositories>
<!-- Repository needed for prerelease versions of Vaadin -->
<pluginRepository>
<id>vaadin-prereleases</id>
<url>https://maven.vaadin.com/vaadin-prereleases</url>
</pluginRepository>
</pluginRepositories>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-bom</artifactId>
<type>pom</type>
<scope>import</scope>
<version>${vaadin.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-core</artifactId>
</dependency>
<!-- Added to provide logging output as Flow uses -->
<!-- the unbound SLF4J no-operation (NOP) logger implementation -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<!--<version>3.1.0</version>-->
<version>4.0.1</version>
<scope>provided</scope>
</dependency>
<!--JUnit 5-->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.4.0-RC1</version>
</dependency>
</dependencies>
<build>
<plugins>
<!-- Jetty plugin for easy testing without a server -->
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.4.14.v20181114</version>
<configuration>
<scanIntervalSeconds>1</scanIntervalSeconds>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<!-- Production mode can be activated with either property or profile -->
<id>production-mode</id>
<activation>
<property>
<name>vaadin.productionMode</name>
</property>
</activation>
<properties>
<vaadin.productionMode>true</vaadin.productionMode>
</properties>
<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>flow-server-production-mode</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-maven-plugin</artifactId>
<version>${vaadin.version}</version>
<executions>
<execution>
<goals>
<goal>copy-production-files</goal>
<goal>package-for-production</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
指定 <plugin>
,而不是 <dependency>
虽然我不是 Maven 专家,但解决方案似乎是在 plugin
元素而不是 dependency
元素中指定 <artifactId>maven-surefire-plugin</artifactId>
。
删除你添加的<dependency>
.
查找 POM 的 <plugins>
(复数)部分,其中包含 Jetty 的一个 <plugin
元素。添加第二个 plugin
元素:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M3</version>
</plugin>
然后做一个 Maven clean
和 install
。您应该看到新版本出现在 IntelliJ 的 Maven 面板中。
您现在可以执行 Maven test
来查看执行的 JUnit 5 测试。
如果您觉得需要,可以通过覆盖导入的 POM 来更新屏幕截图右侧列出的所有插件。
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-clean-plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-compiler-plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-deploy-plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.0.0-M1</version>
</plugin>
<!--https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-install-plugin-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>3.0.0-M1</version>
</plugin>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-resources-plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!--https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-war-plugin-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</version>
</plugin>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-site-plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<!--https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-surefire-plugin-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M3</version>
</plugin>
我的项目是由 Maven 驱动的,使用的 POM 不是我自己制作的(from Vaadin). Apparently the POM file I see in my project depends on some kind of inheritance of other POM files. While I see no dependency for the maven-surefire-plugin
在我自己的 POM 中,这个工件是在我的项目中找到的,正如您在这张截图的右侧所见IntelliJ 2019.
我不是 Maven maven,所以我不知道确切的细节,但在四处寻找时我发现了一些 import
行,所以我猜 Maven POM 可以动态地从其他 POM 继承。
问题是我项目中的 maven-surefire-plugin
版本很旧,版本 2.12.4。我正在尝试 运行 JUnit 5, which requires 2.22.0 or later. The current version 是 3.0.0-M3
。
查看那个粉红色箭头的左端,您可以看到我在我的 POM 中添加了一个 dependency
元素。
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M3</version>
</dependency>
在左箭头提示上,我要求 3.0.0-M3
试图覆盖在右箭头提示上看到的神秘 imported/inherited 指定版本 2.12.4
。但是我的尝试失败了,因为旧版本在执行 Maven clean
、install
后仍然存在。我什至尝试重新启动 IntelliJ。但是不行,当运行使用 Maven test
时,我的 JUnit 5 测试仍然被忽略。
➥ 是否有一些方法可以覆盖显然从某个神秘来源继承的依赖项的版本?
这是我的 POM,在尝试添加 <artifactId>maven-surefire-plugin</artifactId>
依赖项失败之前。
<?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.basilbourque.acmeapp</groupId>
<artifactId>acmeapp</artifactId>
<name>AcmeApp</name>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<failOnMissingWebXml>false</failOnMissingWebXml>
<!--<vaadin.version>11.0.1</vaadin.version>-->
<!--<vaadin.version>12.0.0.beta1</vaadin.version>-->
<vaadin.version>13.0.0.alpha3</vaadin.version>
</properties>
<repositories>
<!-- Repository used by many Vaadin add-ons -->
<repository>
<id>Vaadin Directory</id>
<url>http://maven.vaadin.com/vaadin-addons</url>
</repository>
<repository>
<id>vaadin-prereleases</id>
<url>https://maven.vaadin.com/vaadin-prereleases</url>
</repository>
</repositories>
<pluginRepositories>
<!-- Repository needed for prerelease versions of Vaadin -->
<pluginRepository>
<id>vaadin-prereleases</id>
<url>https://maven.vaadin.com/vaadin-prereleases</url>
</pluginRepository>
</pluginRepositories>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-bom</artifactId>
<type>pom</type>
<scope>import</scope>
<version>${vaadin.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-core</artifactId>
</dependency>
<!-- Added to provide logging output as Flow uses -->
<!-- the unbound SLF4J no-operation (NOP) logger implementation -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<!--<version>3.1.0</version>-->
<version>4.0.1</version>
<scope>provided</scope>
</dependency>
<!--JUnit 5-->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.4.0-RC1</version>
</dependency>
</dependencies>
<build>
<plugins>
<!-- Jetty plugin for easy testing without a server -->
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.4.14.v20181114</version>
<configuration>
<scanIntervalSeconds>1</scanIntervalSeconds>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<!-- Production mode can be activated with either property or profile -->
<id>production-mode</id>
<activation>
<property>
<name>vaadin.productionMode</name>
</property>
</activation>
<properties>
<vaadin.productionMode>true</vaadin.productionMode>
</properties>
<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>flow-server-production-mode</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-maven-plugin</artifactId>
<version>${vaadin.version}</version>
<executions>
<execution>
<goals>
<goal>copy-production-files</goal>
<goal>package-for-production</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
指定 <plugin>
,而不是 <dependency>
虽然我不是 Maven 专家,但解决方案似乎是在 plugin
元素而不是 dependency
元素中指定 <artifactId>maven-surefire-plugin</artifactId>
。
删除你添加的<dependency>
.
查找 POM 的 <plugins>
(复数)部分,其中包含 Jetty 的一个 <plugin
元素。添加第二个 plugin
元素:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M3</version>
</plugin>
然后做一个 Maven clean
和 install
。您应该看到新版本出现在 IntelliJ 的 Maven 面板中。
您现在可以执行 Maven test
来查看执行的 JUnit 5 测试。
如果您觉得需要,可以通过覆盖导入的 POM 来更新屏幕截图右侧列出的所有插件。
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-clean-plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-compiler-plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-deploy-plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.0.0-M1</version>
</plugin>
<!--https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-install-plugin-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>3.0.0-M1</version>
</plugin>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-resources-plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!--https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-war-plugin-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</version>
</plugin>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-site-plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<!--https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-surefire-plugin-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M3</version>
</plugin>