2010-11-22 46 views
1

我在下面的子模塊分離的Java EE項目:在Maven中,我如何定製生命週期階段?

  • 項目戰
  • 項目的EJB
  • 項目耳
  • 項目測試

我也有包含上述模塊的root pom。由於我在一個單獨的項目中進行了測試,因此沒有必要在3個第一個模塊中運行測試階段,因爲沒有必要編譯或打包最後一個模塊,因爲它只包含其他3個模塊的測試。我的問題是:如何從前3個模塊中刪除測試階段,以及如何從測試項目中刪除其他階段?

回答

2

你可以做,通過設置不同的配置文件:http://maven.apache.org/guides/introduction/introduction-to-profiles.html

EXP:

<profile> 
     <id>deploywar</id> 
     <build> 
      <plugins> 
       <plugin> 
        <groupId>net.fpic</groupId> 
        <artifactId>tomcat-deployer-plugin</artifactId> 
        <version>1.0-SNAPSHOT</version> 
        <executions> 
         <execution> 
          <id>pos</id> 
          <phase>install</phase> 
          <goals> 
           <goal>deploy</goal> 
          </goals> 
          <configuration> 
           <host>${deploymentManagerRestHost}</host> 
           <port>${deploymentManagerRestPort}</port> 
           <username>${deploymentManagerRestUsername}</username> 
           <password>${deploymentManagerRestPassword}</password> 
           <artifactSource> 
            address/target/addressservice.war 
           </artifactSource> 
          </configuration> 
         </execution> 
        </executions> 
       </plugin> 
      </plugins> 
     </build> 
    </profile> 

    <!-- Defines the QA deployment information --> 
    <profile> 
     <id>qa</id> 
     <activation> 
      <property> 
       <name>env</name> 
       <value>qa</value> 
      </property> 
     </activation> 
     <properties> 
      <deploymentManagerRestHost>10.50.50.50</deploymentManagerRestHost> 
      <deploymentManagerRestPort>58090</deploymentManagerRestPort> 
      <deploymentManagerRestUsername> 
       myotherusername 
      </deploymentManagerRestUsername> 
      <deploymentManagerRestPassword> 
       myotherpassword 
      </deploymentManagerRestPassword> 
     </properties> 
    </profile> 

,你將與mvn -Pdeploywar -Denv=dev clean install

+0

一件事叫deploywar輪廓在CLI要注意的是就我所知,該配置文件將在maven 3中消失。 – CoolBeans 2010-11-22 22:17:43

相關問題