A brief description of profiles in Maven

Source: Internet
Author: User

Profiles is a key term for Maven: profile is used to define some of the environmental variations that are used in build lifecycle, Profile can be set to activate different profiles in different environments (for example: Different OS activates different profiles, different JVMs activate different profiles, different dabase activate different profiles, etc.).

Define Profiles

You can define the profiles in 4 places:

%m2_home%/conf/settings.xml, this is the profiles for all user of the computer, global profiles, which affects all MAVEN project builds

<your-home-directory>/.m2/settings.xml, which is profiles for per user, is a user-level profiles that affects all MAVEN project for the current user Build

Defined in the Pom.xml file, which is profiles for this project only, and is a project-level profiles

Profiles.xml, it and Pom.xml in the same directory, is also a project-level profiles, the purpose of using Profiles.xml is to want to profiles settings from the Pom.xml out of the set.

Defined in the profiles of these 4 places, the narrower profiles covers the wider profiles. Namely: the definition in Pom.xml profiles will cover Profiles.xml, Profiles.xml will cover <your-home-directory>/.m2/settings.xml, <your- The Home-directory>/.m2/settings.xml will cover the%m2_home%/conf/settings.xml.

However, please note: The Profiles set in Pom.xml is the most recommended, because Pom.xml will be deploy to Repository, so pom.xml profiles will available for subsequent Builds originating from the repository or as transitive dependencies. While the profiles defined in Settings.xml and profiles.xml are not deploy to Repository, there are a number of limitations, so only the following profiles can be defined in Settings.xml and profiles.xml:

Repositories

Pluginrepositories

Properties

Other types of profiles must be defined in Pom.xml (above 3 profiles can also be defined in Pom.xml).

The profiles that Pom.xml can define include:

<repositories>
<pluginRepositories>
<dependencies>
<plugins>
<properties> (not actually available in the main POM, but used behind the scenes)
<modules>
<reporting>
<dependencyManagement>
<distributionManagement>
a subset of the <build> element, which consists of:
<defaultGoal>
<resources>
<testResources>
<finalName>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.