2017-05-09 33 views
0

我有一個項目可能根據所選配置文件採用不同的來源/資源。一些配置文件是相互排斥的,有些應該是組合的,例如在片段下面定義應該是組合具有多個活動配置文件的buid-helper插件

<profiles> 
    <profile> 
     <id>local</id> 
     <build> 
      <pluginManagement> 
       <plugins> 
        <plugin> 
         <groupId>org.codehaus.mojo</groupId> 
         <artifactId>build-helper-maven-plugin</artifactId> 
         <inherited>true</inherited> 
         <executions> 
          <execution> 
           <id>add-sources</id> 
           <phase>generate-sources</phase> 
           <goals> 
            <goal>add-source</goal> 
           </goals> 
           <configuration> 
            <sources> 
             <source>profiles/local/src/main/java</source> 
            </sources> 
           </configuration> 
          </execution> 
          <execution> 
           <phase>generate-resources</phase> 
           <goals> 
            <goal>add-resource</goal> 
           </goals> 
           <configuration> 
            <resources> 
             <resource> 
              <directory>profiles/local/src/main/resources</directory> 
              <filtering>true</filtering> 
             </resource> 
            </resources> 
           </configuration> 
          </execution> 
         </executions> 
        </plugin> 
       </plugins> 
      </pluginManagement> 
     </build> 
    </profile> 

    <profile> 
     <id>wildfly</id> 
     <build> 
      <pluginManagement> 
       <plugins> 
        <plugin> 
         <groupId>org.codehaus.mojo</groupId> 
         <artifactId>build-helper-maven-plugin</artifactId> 
         <inherited>true</inherited> 
         <executions> 
          <execution> 
           <id>add-sources</id> 
           <phase>generate-sources</phase> 
           <goals> 
            <goal>add-source</goal> 
           </goals> 
           <configuration> 
            <sources> 
             <source>profiles/wildfly/src/main/java</source> 
            </sources> 
           </configuration> 
          </execution> 
          <execution> 
           <phase>generate-resources</phase> 
           <goals> 
            <goal>add-resource</goal> 
           </goals> 
           <configuration> 
            <resources> 
             <resource> 
              <directory>profiles/wildfly/src/main/resources</directory> 
              <filtering>true</filtering> 
             </resource> 
            </resources> 
           </configuration> 
          </execution> 
         </executions> 
        </plugin> 
       </plugins> 
      </pluginManagement> 
     </build> 
    </profile> 
</profiles> 

型材localwildfly如果我這樣做eclipse下我注意到,只有後者實際應用 - 我僅查看wildfly配置文件中定義的來源/資源。

另外,在得到的完整POM我注意到,只有後者(wildfly)配置文件的配置被應用,從而消除了源和在local配置文件定義的資源。

這是插件應該工作的方式,還是我錯過了什麼?

+0

本地運行和生產之間是否存在真正的源代碼差異?這應該由屬性等處理,但不在代碼中處理。 – khmarbaise

+0

@khmarbaise有點OT,但fyi:不行,這就是配置文件需要組合的原因。就像大多數應用程序服務器一樣,蜻蜓也有它自己的怪癖(在我的情況下,它是一個設置JMS消息以延遲傳遞的屬性)。此代碼非常專用於處理不同應用服務器上的這些特性,而所有其他代碼都是嚴格標準的。 –

+0

基於一個基本的原則,我會爲具體代碼製作單獨的maven項目,並在那裏爲不同的模塊生成不同的戰爭/耳朵... – khmarbaise

回答

0

好吧....只是我。

我給了執行者一個相同的名字,因此他們被覆蓋。我的錯。

此版本可能會被版主關閉/刪除。

相關問題