如何使pom.xml使用特定于每个开发人员的本地环境的本地属性?

S.Y*_*ari 0 maven

我们的Subversion服务器上有一个Maven项目。pom.xml项目内部有一个。当我想将项目导入本地计算机并对其进行更改时,我必须相对于本地系统更改此行,pom.xml因为在提交之前,我需要在本地系统上部署项目以对其进行测试:

<plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-war-plugin</artifactId>
      <version>2.4</version>
      <configuration>
            <webappDirectory>/opt/JBoss_4.0.4.GA/server/default/deploy/agg-gateway.war</webappDirectory>
      </configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)

我的每个团队成员都应相对于其本地系统执行此操作。

但是这个设置在主项目上必须保持不变,我不必提交pom.xml给Subversion。如果我的团队成员之一更改了此文件,则每次更新项目时,都必须相对于本地系统再次更改它。

有什么方法可以使文件在Subversion上不可更改?我无法控制大家不提交pom.xmlsvn

小智 5

通过settings.xml注入POM属性

~/.m2/settings.xml其中使用特定于每个开发人员的自定义属性:

<profiles>
  <profile>
    <id>local-weblogic</id>
    <properties>
      <local.weblogic.deployment.directory>/opt/JBoss_4.0.4.GA/server/default/deploy/agg-gateway.war</local.weblogic.deployment.directory>
    </properties>
  </profile>
</profiles>

<activeProfiles>
  <activeProfile>local-weblogic</activeProfile>
</activeProfiles>
Run Code Online (Sandbox Code Playgroud)

并在您的 pom.xml

<plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-war-plugin</artifactId>
      <version>2.4</version>
      <configuration>
            <webappDirectory>${local.weblogic.deployment.directory}</webappDirectory>
      </configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)