gpt4 book ai didi

java - Maven checkstyle 未在目标中触发

转载 作者:行者123 更新时间:2023-12-04 03:46:59 27 4
gpt4 key购买 nike

不知何故,checkstyle 目标没有触发我设置要运行的任务。

这是我的POM:

<?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>
...
<version>1.0-SNAPSHOT</version>

<name>...</name>
<!-- FIXME change it to the project's website -->
<url>http://www.idk.com</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<pluginManagement>
<plugins>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.17</version>
<configuration>
<failsOnError>true</failsOnError>
<configLocation>checkstyle.xml</configLocation>
<consoleOutput>true</consoleOutput>
</configuration>
<executions>
<execution>
<id>build</id>
<phase>build</phase>
<goals>
<goal>checkstyle</goal>
</goals>
</execution>
<execution>
<id>verify</id>
<phase>verify</phase>
<goals>
<goal>checkstyle</goal>
</goals>
</execution>
<execution>
<id>package</id>
<phase>package</phase>
<goals>
<goal>checkstyle</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>

但是如果我运行 mvn verify 我没有看到 checkstyle 被运行:

[INFO] Scanning for projects...
[INFO]
[INFO] -----------------< ... >-----------------
[INFO] Building Icecream Shop Manager 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) @ ... ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory ...
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ ... ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to ...
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:testResources (default-testResources) @ ... ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory ...
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:testCompile (default-testCompile) @ ... ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to ...
[INFO]
[INFO] --- maven-surefire-plugin:2.22.1:test (default-test) @ ... ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running it.unipd.tos.AppTest
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.047 s - in it.unipd.tos.AppTest
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO]
[INFO] --- maven-jar-plugin:3.0.2:jar (default-jar) @ ... ---
[INFO] Building jar: ...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.423 s
[INFO] Finished at: 2020-11-24T22:19:44+01:00
[INFO] ------------------------------------------------------------------------

我错过了什么?我不应该看到类似的东西吗:

[INFO] --- maven-checkstyle-plugin:2.17:checkstyle (default) @ ... ---

最佳答案

<pluginManagement>元素用于配置要继承的插件。您需要将 Checkstyle 插件定义放在 <plugins> 下元素,不在 <pluginManagement> 下元素。

关于java - Maven checkstyle 未在目标中触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64995067/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com