Maven构建失败,因为`–settings`选项未被识别。

huangapple go评论57阅读模式
英文:

Maven build failing due to unrecognized `--settings` option

问题

在我的使用Maven构建的Java项目中,我有一个名为.mvn的目录,其中包含一个maven.config文件。该文件的内容如下:

--settings ./.mvn/local-settings.xml

local-settings.xml文件包含了用于从私有仓库拉取代码的身份验证凭据。

这个设置一直运作正常,直到昨天。现在,CI构建(使用maven:3-amazoncorretto-17)失败,并显示以下错误消息:

无法解析maven.config文件选项:未识别的选项:--settings ./.mvn/local-settings.xml

我正在使用的maven镜像是否发生了破坏性的更改?

英文:

In my Java projects building with maven, I have a a .mvn directory that contains a maven.config file. Content of that file is as follows:

--settings ./.mvn/local-settings.xml

The local-settings.xml holds authentication credentials for pulling from a private registry.
This setup worked fine up until yesterday. Now, the CI build (using maven:3-amazoncorretto-17) is failing with the following error message:

Unable to parse maven.config file options: Unrecognized option: --settings ./.mvn/local-settings.xml

Has there been a breaking change in the maven image I am using for building?

答案1

得分: 34

自从引入了maven 3.9,就有一个重大变更影响了maven.config文件的解析:
https://maven.apache.org/docs/3.9.0/release-notes.html#potentially-breaking-core-changes

.mvn/maven.config中的每一行现在被解释为一个单独的参数。也就是说,如果文件包含多个参数,现在必须将它们放在不同的行上,参见MNG-7684

正如评论中@khmarbaise所指出的,向maven.config添加一个换行符可以正常工作,甚至向下兼容。

--settings  
./.mvn/local-settings.xml  

**重要提示:**在--settings后面不能有空格。

英文:

With the introduction of maven 3.9, there was a BREAKING CHANGE that affects the parsing of the maven.config file:
https://maven.apache.org/docs/3.9.0/release-notes.html#potentially-breaking-core-changes

> Each line in .mvn/maven.config is now interpreted as a single argument. That is, if the file contains multiple arguments, these must now be placed on separate lines, see MNG-7684.

As pointed out by @khmarbaise in the comments, adding a newline in the maven.config works just fine and is even downwards compatible.

--settings
./.mvn/local-settings.xml

IMPORTANT NOTE: There must not be a whitespace after --settings

答案2

得分: 4

"-s./.mvn/settings.xml" 也可以工作,没有任何空格。

英文:

Also noticed that -s./.mvn/settings.xml works too without any space

huangapple
  • 本文由 发表于 2023年2月16日 16:32:00
  • 转载请务必保留本文链接:https://go.coder-hub.com/75469591.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定