Maven configuring setting XML details -- profiles, activation

Chen Bucheng I 2022-06-24 07:44:16 阅读数:647



effect : Adjust the list of build configurations based on the environment parameters . settings.xml Medium profile The element is pom.xml in profile The cut version of the element . It contains id、activation、repositories、pluginRepositories and properties Elements . there profile The element only contains these five sub elements because it only cares about building the system as a whole ( That's exactly what it is. settings.xml Role orientation of documents ), Instead of setting up a separate project object model . If one settings.xml Medium profile To be activated , Its value will override any other definition in pom.xml With the same id Of profile.

<settings xmlns="" xmlns:xsi=""
<!-- profile Unique identification of -->
<!-- Automatic triggering profile The conditional logic of -->
<activation />
<!-- Extended attribute list -->
<properties />
<!-- Remote warehouse list -->
<repositories />
<!-- Plug in repository list -->
<pluginRepositories />


effect : Automatic triggering profile The conditional logic of . Such as pom.xml Medium profile equally ,profile It can automatically use certain values in certain environments ; These environments pass through activation Element designation . activation The element is not activated profile The only way .settings.xml In the document activeProfile Elements can contain profile Of id.profile It can also be done on the command line , Use -P Tag and comma separated list to explicitly activate ( Such as ,-P test)

<!--profile Whether the default activation of the logo -->
<!-- When it matches jdk Detected ,profile To be activated . for example ,1.4 Activate JDK1.4,1.4.0_2, and !1.4 Activating all versions is not to 1.4 At the beginning JDK. -->
<!-- When a matching operating system property is detected ,profile To be activated .os Element can define some operating system related properties . -->
<!-- Activate profile The name of the operating system -->
<name>Windows XP</name>
<!-- Activate profile The operating system family of ( Such as 'windows') -->
<!-- Activate profile The operating system architecture of -->
<!-- Activate profile The operating system version of -->
<!-- If Maven An attribute was detected ( Its value can be in POM Pass through ${name} quote ), It has a corresponding name = value ,Profile Will be activated . If the value field is empty , Then the existence of the attribute name field will activate profile, Otherwise, match the property value fields in case sensitive way -->
<!-- Activate profile The name of the property of -->
<!-- Activate profile The value of the property -->
<!-- Provide a filename , Activate... By detecting whether the file exists or does not exist profile.missing Check if the file exists , Activate if not present profile. On the other hand ,exists It will check if the file exists , Activate... If present profile. -->
<!-- If the specified file exists , Then activate profile. -->
<!-- If the specified file does not exist , Then activate profile. -->
copyright:author[Chen Bucheng I],Please bring the original link to reprint, thank you.