【发布时间】:2023-03-24 00:40:01
【问题描述】:
我们有一个 Maven 项目,每个开发人员都需要使用他们的本地项目设置。由于它们不应存储在 Git 存储库中,因此我们无法在 pom.xml 文件中指定它们。
我们曾考虑使用 ~/.m2/settings.xml 文件,但由于此文件存储属性用户范围而不是每个项目,它们会干扰每个其他。例如:
<profiles>
<profile>
<id>project1</id>
<properties>
<sftp-endpoint>10.201.50.14</sftp-endpoint>
<sftp-password>secretpass</sftp-password>
</properties>
</profile>
<profile>
<id>project2</id>
<properties>
<sftp-endpoint>12.34.56.78</sftp-endpoint>
<sftp-password>pencil</sftp-password>
</properties>
</profile>
</profiles>
<activeProfiles>
<activeProfile>project1</activeProfile>
<activeProfile>project2</activeProfile>
</activeProfiles>
如果我尝试使用这个文件,当我在 project1 上工作时,我也会从 project2 获取本地属性。它们必须具有相同的名称,因为很多都依赖于它们。
有什么方法可以在 Maven 中为每个项目设置本地属性?
【问题讨论】:
-
拥有 2 个 poms 怎么样?适合 git 的那个和自定义的只有本地的?
-
@AnthonyAccioly 这看起来很有希望。会试试看。
-
为什么在 Maven 项目中需要 sftp 访问权限?
标签: maven properties-file