Question

So my Maven doesn't want to pickup the right profile, doesn't matter how I tell it:

mvn -Denv=dev tomcat7:deploy-only or mvn -P dev -Denv=dev tomcat7:deploy-only

I have two servers configured on my settings.xml and have my configuration below pointing to the correct ones.

Using mvn -X it seems that Maven is always picking up the last server in order it appears on the file, which means it's picking up the prod server.

Any clues anyone? Thank you!

Here's my <profiles>:

<profiles>
<profile>
  <id>dev</id>
  <activation>
    <property>
      <name>env</name>
      <value>dev</value>
    </property>
  </activation>
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.tomcat.maven</groupId>
        <artifactId>tomcat7-maven-plugin</artifactId>
        <version>2.0-beta-1</version>
        <configuration>
          <server>dev</server>
          <url>http://localhost:8080/manager/text</url>
          <username>tomcat</username>
          <password>tomcat</password>
          <path>/</path>
        </configuration>
      </plugin>
    </plugins>
  </build>
</profile>
<profile>
  <id>prod</id>
  <activation>
    <property>
      <name>env</name>
      <value>prod</value>
    </property>
    <jdk>1.6</jdk>
  </activation>
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.tomcat.maven</groupId>
        <artifactId>tomcat7-maven-plugin</artifactId>
        <version>2.0-beta-1</version>
        <configuration>
          <server>prod</server>
          <url>http://remote/manager/text</url>
          <username>usr</username>
          <password>pwd</password>
          <path>/</path>
        </configuration>
      </plugin>
    </plugins>
  </build>
</profile>
</profiles>
Was it helpful?

Solution

You have an extra "activation" of <jdk>1.6</jdk> in your prod profile. Activations are an "or", not an "and". I'm guessing you're running maven with jdk6, and so prod is always active. Being the last one in the pom, its settings will win--a general rule in maven.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top