我们有一个Maven项目,每个开发人员都需要使用他们的本地项目设置。由于不应将它们存储在Git存储库中,因此我们无法在pom.xml文件中对其进行具体化。
我们已经考虑过使用〜/ .m2 / settings.xml文件,但是由于此文件存储属性user-wide而不是每个项目,因此它们会相互干扰。例如:
<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中每个项目有什么方法可以拥有本地属性吗?
环境变量您可以针对每个环境使用环境脚本,该脚本定义了sftp-endpoint
和sftp-password
之类的环境变量。然后将这些文件添加到.gitignore
,并手动分发给开发团队。然后,您可以在pom中使用这些属性,例如${env.VARIABLE_NAME}
或${env}.VARIABLE_NAME
密码加密使用内置的Maven password encryption