从POM文件激活一个settings.xml定义的Maven配置文件 [英] Activating a settings.xml Defined Maven Profile From POM File
问题描述
我们的企业团队维护一个 settings.xml
文件,该文件定义了开发项目可以使用Maven构建其工件并将其安装在存储库中的各种配置文件。期望的是,Jenkins中的每个项目都将定义一个-P参数,并指定所需的配置文件。
这是我的问题:我需要使用的配置文件指定一个存储库通常对我的项目(分期版本存储库)不可见,因此,该存储库中的任何内容都不会依赖于该项目,而该配置文件是无效的。我需要一种方法来激活我项目的 pom.xml
文件中 settings.xml
中定义的配置文件。否则,当在Eclipse中查看我的项目时,错误将显示在 pom.xml
中,因为无法解析该依赖关系,因为该配置文件未处于活动状态才能使存储库可见。 / p>
有没有办法在 pom.xml中激活
文件?或者,有没有办法告诉Eclipse总是激活特定项目的配置文件? settings.xml
定义的配置文件
经过更多的研究,我发现在Eclipse中的一个项目特定的Maven属性,我可以设置活动的配置文件。您可以通过右键单击项目来设置,选择属性,然后选择Maven。您将看到Active Maven Profiles(逗号分隔)的文本输入框:。
这解决了我的问题。
我正在寻找一个更全面的Eclipse解决方案,而不是在项目级别。但这似乎是有效的。
Our enterprise team maintains a settings.xml
file that defines various profiles that development projects can use with Maven to build their artifacts and install them in a repository. The expectation is that each project in Jenkins would define a -P parameter with the desired profile specified.
Here is my issue: The profile I need to use specifies a repository that is normally not visible to my project (a staged release repository), so anything in that repository cannot be depended upon without that profile being active. I need a way to activate that profile defined in settings.xml
in my project's pom.xml
file. Otherwise, when looking at my project in Eclipse, errors are shown in the pom.xml
that dependencies cannot be resolved because the profile isn't active to make the repository visible.
Is there a way to activate a settings.xml
defined profile in a pom.xml
file? Alternatively, is there a way to tell Eclipse to always activate a profile for a particular project?
After more research, I found a project specific Maven property in Eclipse where I can set the active profiles. You can set this by right-clicking on the project, select "Properties", and select "Maven". You are presented with a text entry box for "Active Maven Profiles (comma separated):".
That solved my problem.
I was looking for a more global solution in Eclipse rather than at the project level. But this seems to work.
这篇关于从POM文件激活一个settings.xml定义的Maven配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!