我在Windows系统上构建项目时遇到了一些问题。我的项目使用formatter-maven-plugin插件,并使用“validate”目标。在将项目推送到GitHub之前,我会对其进行格式化并推送。之后,我在Windows计算机上克隆它并尝试运行“mvn clean install”,但是我得到了以下错误:
Failed to execute goal net.revelc.code.formatter:formatter-maven-plugin:2.9.0:validate (default) on project application: File 'C:\Users\AUser\Desktop\demo\application\src\main\java\com\myapp\Application.java' has not been previously formatted. Please format file and commit before running validation!
在 Linux 中,这个问题是不存在的。为什么呢?在提交到 Git 之前,我对其进行了格式化处理。为什么在 Linux 上不存在这个问题?我无法改变格式化的目标。
<plugin>
<groupId>net.revelc.code.formatter</groupId>
<artifactId>formatter-maven-plugin</artifactId>
<version>2.9.0</version>
<executions>
<execution>
<goals>
<goal>validate</goal>
</goals>
<configuration>
<configFile>${project.basedir}/../eclipse/eclipse-formatter.xml</configFile>
<encoding>UTF-8</encoding>
</configuration>
</execution>
</executions>
</plugin>
${project.basedir}/../eclipse/eclipse-formatter.xml
在你本地机器和Github上是相同的吗?我的猜测是文件不同或者Github上根本不存在该引用的configFile
文件,因为其位于项目之外。 - entpnerd