Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
486 views
in Technique[技术] by (71.8m points)

java - How do I invoke two different profiles in one maven command?

I have two profiles for different environments in pom.xml, I have to run mvn -PTest1 install and mvn -PTest2 install command to get these profiles in use. Can we integrate two separate maven commands in a single one (like mvn clean install)?

Here is my Pom entry

<profiles>
  <profile>
  <id>Test1</id>
  <activation>
    <activeByDefault>true</activeByDefault>
    <jdk>1.5</jdk>
    <os>
       <name>Windows XP</name>
       <family>Windows</family>
       <arch>x86</arch>
       <version>5.1.2600</version>
    </os>
    <property>
       <name>sparrow-type</name>
       <value>African</value>
    </property>
  </activation>
  <dependencies>
    <dependency>
      <groupId>
      com.endeca
      </groupId>
      <artifactId>
      endeca_navigation_Test1
      </artifactId>
     <version>
     6.1
     </version>
     <!--<version>stable</version> -->
    <scope>
    compile
    </scope>
  </dependency>
  </profile>

  <profile>
    <id>Test2</id>
    <activation>
      <activeByDefault>false</activeByDefault>
      <jdk>1.5</jdk>
      <os>
        <name>Windows XP</name>
        <family>Windows</family>
        <arch>x86</arch>
        <version>5.1.2600</version>
      </os>
      <property>
        <name>sparrow-type</name>
        <value>African</value>
      </property>
    </activation>
    <dependencies>
      <dependency>
        <groupId>
        com.endeca
        </groupId>
        <artifactId>
        endeca_navigation_Test2
        </artifactId>
        <version>
        6.1
        </version>
        <!--<version>stable</version> -->
        <scope>
        compile
        </scope>
      </dependency>
    </dependencies>
  </profile>
</profiles>

It will helpfull to manage hudson job using single command

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Based on the documentation and discussion here, try separating profile names with a comma:

mvn install -P Test1,Test2

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.9k users

...