Maven: Set the settings.xml location in the pom.xml?

百般思念 提交于 2019-12-01 03:51:34

问题


Is it possible to set the location of the settings.xml file inside the pom.xml file.

I know you can do it from the command line typing mvn -s location/of/settings.xml, but I wanted to know if I can set that within the pom.xml so I don't have to keep typing through command line.


回答1:


No. And that's probably a horrible idea, from a security standpoint. It'd allow the creator of a pom to bypass all your settings.xml settings. If you do the mvn -s location/of/settings.xml you will at least know it happened. But if you just randomly build a project, who knows how malicious that project's creator was.




回答2:


No, but you can set what you need from the settings.xml file into the pom.xml and it will override what's in settings.xml




回答3:


Something that may help you get what you want are profiles:

A profile in Maven is an alternative set of configuration values which set or override default values. Using a profile, you can customize a build for different environments. Profiles are configured in the pom.xml and are given an identifier. Then you can run Maven with a command-line flag that tells Maven to execute goals in a specific profile. The following pom.xml uses a production profile to override the default settings of the Compiler plugin.

Source: http://maven.apache.org/pom.html#Profiles



来源:https://stackoverflow.com/questions/14654350/maven-set-the-settings-xml-location-in-the-pom-xml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!