2017-05-09 74 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

好吧....只是我。

我给了执行者一个相同的名字,因此他们被覆盖。我的错。

此版本可能会被版主关闭/删除。

相关问题