简体   繁体   English

在pom.xml中安排配置文件和插件

[英]Arranging Profiles and Plugins in pom.xml

I have these things in my pom.xml 我的pom.xml中有这些东西

  • profile1 profile1
  • profile2 profile2

These profiles are for separate build environment. 这些配置文件用于单独的构建环境。

I need to make these plugins as common to both profiles. 我需要使这两个配置文件通用的插件。

  • plugin1 插件1
  • plugin2 插件2
  • plugin3 插件3

Where should I place these common plugins? 这些通用插件应该放在哪里?

You can simply put them in the default build section. 您可以简单地将它们放在默认构建部分中。 Since the plugins are common to both profiles: this the best way to do it. 由于这两个配置文件都使用了插件,因此这是最好的方法。

Remark that if the configuration of plugins is slightly different for the different profiles you can use properties in the plugin configuration and define the values of those properties in the profile. 请注意,如果不同配置文件的插件配置略有不同,则可以在插件配置中使用属性,并在配置文件中定义这些属性的值。

    <build>
       <plugins>
          <plugin>
              <groupId>someGroup</groupId>
              <artifactId>plugin1</artifactId>
              ...
          </plugin>
          <plugin>
              <groupId>someGroup</groupId>
              <artifactId>plugin2</artifactId>
              ...
          </plugin>
          <plugin>
              <groupId>someGroup</groupId>
              <artifactId>plugin3</artifactId>
              ...
          </plugin>
       </plugins>
     </build>

EDIT 编辑

Note that this solution will enable the plugins even when no profiles are activated. 请注意,即使未激活任何配置文件,此解决方案也将启用插件。 Not sure this what you need. 不确定这是您所需要的。 (you maybe have a third build environment: for instance the developper computer where no profile are defined). (您可能有第三个构建环境:例如,未定义配置文件的开发人员计算机)。 In this case the solution of a third profile is the way to go. 在这种情况下,第三个配置文件的解决方案是必经之路。

 mvn clean install -Pprofile1,profile-common

or 要么

 mvn clean install -Pprofile2, profile-common

and your common plugins defined in profile-common 和您在profile-common中定义的常用插件

You can have multiple profiles active at any given point of time. 您可以在任何给定时间激活多个配置文件。 As such you can create a common profile( profile3) and keep the plugins there. 这样,您可以创建一个通用配置文件(profile3)并将插件保留在那里。 The plugins/config which are dependent on specific profiles, can be kept in specific profile1 and profile2. 取决于特定配置文件的插件/配置,可以保留在特定的profile1和profile2中。

-P profile-1,profile-3 -P profile-1,profile-3

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM