S.Yavari
S.Yavari

Reputation: 876

How can I make a pom.xml use local properties specific to each developer's local environment?

We have a maven project on our subversion server. There is a pom.xml inside the project. When I want to import project to my local computer and make my changes on it, I have to change this lines relative to my local system inside the pom.xml because I need to deploy project on my local system to test it before submit:

<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>

Each of my team members should do that relative to their local systems.

But this settings must be unchanged on main project an I have not to submit pom.xml to subversion. If one of my team members changes this file, every time I update the project, I have to change it again relative to my local system.

Is there any way to make a file unchangeable on subversion? I can not control everybody to not to submit pom.xml to svn.

Upvotes: 0

Views: 2329

Answers (1)

user177800
user177800

Reputation:

Injecting POM Properties via settings.xml:

Use a custom property in your ~/.m2/settings.xml which is specific to each developer:

<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>

and use a reference to the property in your 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>

Upvotes: 6

Related Questions