Detailed profiles maven

settings.xml

This article mainly maven profiles interpreted in setting.xml

 

1. Declare specification

 

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" 
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">

2.localRepository

    <! - path to the local warehouse. The default value -> 
    <localRepository> / opt / Repository </ localRepository>

3.interactiveMode

    <-! Maven need for user interaction and to obtain input. If Maven requires user interaction and to obtain input, it is set to true, should conversely to false. The default is true. -> 
    <interactiveMode> to true </ interactiveMode>

4.usePluginRegistry

    <-! Maven plugin-registry.xml need to use file management plug-in version. If you need to use Maven to manage plug-in version of the file is set to true. The default is false. -> 
    <usePluginRegistry> to false </ usePluginRegistry>

5.offline

    <! - whether expressed Maven needs to run in offline mode. If the build system needs to run in offline mode, for the true, the default is false. Because when the network setting problem or safety factors built when the server can not connect to a remote repository, the configuration is very useful. -> 
    <Offline> to false </ Offline>

6.pluginGroups

    <! - when the tissue plug-Id (groupId) does not explicitly provide for a list of search plugins Organization Id (groupId) of. This element contains a list of elements pluginGroup, each sub-element contains a tissue Id (groupId). When we use a plug-in, and it does not provide tissue Id (groupId) in the command line, Maven will use the list. By default, the list contains org.apache.maven.plugins and org.codehaus.mojo -> 
    <pluginGroups> 
      <-! Plugin Organization Id (groupId) -> 
      <pluginGroup> org.codehaus.mojo </ pluginGroup> 
    </ pluginGroups>

7.proxies

    ! <- used to configure the different agents, multi-agent profiles can cope with workplace laptop or mobile device: through a simple setup profile id can easily replace the entire proxy configuration. -> 
    <Proxies> 
      <-! Information needed to configure the proxy comprising proxy element -> 
      <Proxy> 
       <-! Unique delimiter agents, agents used to distinguish one element. -> 
       <the above mentioned id> MyProxy </ the above mentioned id> 
       <-! Whether the agent is active in that. true then activate the agent. When we declare a group of agents, and sometime only need to activate a proxy when the element can be put to use. -> 
       <the Active> to true </ the Active> 
       <-! Agency agreement. Protocol: // hostname: port, separated into discrete elements to make configuration easier. -> 
       <Protocol> HTTP </ Protocol> 
       <-! Proxy host name. Protocol: // hostname: port, separated into discrete elements to make configuration easier. -> 
       <Host> proxy.somewhere.com </ Host> 
       <-! Proxy port. Protocol: // hostname: port, separated into discrete elements to make configuration easier. -> 
       <Port> 8080 </ Port> 
       <! - Proxy user name, user name and password represents the proxy server authentication login name and password. 
       -> <username> PROXYUSER </ username>
       <-! Proxy password, user name and password represents the proxy server authentication login name and password. -> 
       <password> somepassword </ password> 
       <-! Should not be a proxy list of host names. The list delimiter designated by the proxy server; examples use a pipe delimiter, separated by commas are also common. -> 
       <nonProxyHosts> * google.com |. Ibiblio.org </ nonProxyHosts> 
      </ Proxy> 
    </ Proxies>

8.servers

    <! - some of the settings to configure the service side. Some settings, such as security certificates and should not be distributed with pom.xml. This type of information should exist to build settings.xml file on the server. -> 
    <Servers> 
      <-! Required information element contains the server configuration server -> 
      <server> 
       <-! This is the server's id (note not a user login id), and the id of the repository elements distributionManagement the id to match. -> 
       <the above mentioned id> server001 </ the above mentioned id> 
       <-! Authentication user name. Authentication username and password authentication means that the server requires authentication login name and password. -> 
       <username> my_login </ username> 
       <-! Authentication password. Authentication username and password authentication means that the server requires authentication login name and password. Password encryption feature has been added to the 2.1.0 +. For more information visit the password encryption page -> 
       <password> my_password </ password> 
       <-! Private key position to use when authenticating. The first two elements, and the like, and the position of the private key password of a private key assigned path (default $ {user.home} /. Ssh / id_dsa) and, if desired, a passphrase. Future passphrase and password elements may be extracted to the outside, but they must be declared in the form of plain text in the settings.xml file. -> 
       <
       <-! Private key password to use when authenticating. -> 
       <passphrase> some_passphrase </ passphrase> 
       <-! Permissions when files are created. If you create a repository file or directory at deployment time, this time we can use permissions (permission). Legal values of these two elements is a three-digit number, which corresponds to the unix file system permissions, such as 664 or 775. -> 
       <filePermissions> 664 </ filePermissions> 
       <-! Permissions of the directory is created. -> 
       <directoryPermissions> 775 </ directoryPermissions> 
      </ Server> 
    </ Servers>

9.mirrors

    <-! Download mirror list configured for the repository list. Advanced Settings See Mirroring Settings page -> 
    <Mirrors> 
      <-! Given warehouse download mirrors. -> 
      <Mirror> 
       <-! Unique identifier for the image. id used to distinguish one mirror element. -> 
       <the above mentioned id> planetmirror.com </ the above mentioned id> 
       <-! Image name -> 
       <name> PlanetMirror Australia </ name> 
       <-! The mirror URL. Construction of the system will give priority to the use of the URL, rather than using the default server URL. -> 
       <URL> http://downloads.planetmirror.com/pub/maven2 </ URL> 
       <-! Mirrored server id. For example, if we want to set up a central Maven repository (http://repo.maven.apache.org/maven2/) of the image, you need to set the element to be central. This must be exactly the same id central central warehouse. -> 
       <mirrorOf> Central </ mirrorOf> 
      </ Mirror> 
    </ Mirrors>

10.profiles

    <! - to adjust the configuration to build a list based on environmental parameters. settings.xml profile element is cut version of the pom.xml profile element. It contains id, activation, repositories, pluginRepositories and properties of elements. Here the profile element contains only five sub-elements are concerned here only because this building (which is the Role of settings.xml file) overall system, rather than individual project object model settings. If the settings in a profile is activated, its value will override any other definition POM profile or with the same id in the profile.xml. -> 
    <Profiles> 
      <-! The environment parameter adjusting member is disposed -> 
      <Profile> 
       <-! Unique identifier of the configuration. -> 
       <ID> Test </ ID>

11.Activation

    <-! Automatic trigger profile of conditional logic. Activation is the key to the profile. The POM in the same profile, the profile automatically from its power use certain value in certain circumstances; these activation elements specified by the environment. activation element is not the only way to activate the profile. activeProfile elements in settings.xml file can contain the id profile. profile may be on the command line, using -P and comma-separated list of tags to explicitly activate (e.g., -P test). -> 
       <Activation> 
    <-! Profile default identifier is active -> 
        <activeByDefault> to false </ activeByDefault> 
    <-! Jdk when matching is detected, profile is activated. For example, 1.4 activation JDK1.4,1.4.0_2, and! 1.4 version is not activated all starts with the 1.4 JDK. -> 
        <JDK> for 1.5 </ JDK> 
    <-! Operating system when the matching attribute is detected, profile is activated. os element can define attributes associated with the operating system. -> 
        <os> 
    <-! Operating system activation profile name -> 
         <name> Windows XP </ name> 
    <-! Operating system belongs to the family of the activation profile (such as 'windows') ->
    <! - activation profile of the operating system architecture -> 
    <! - the activation profile of the operating system version -> 
         <Version> 5.1.2600 </ Version> 
        </ OS> 
    <! - if a detected Maven a property (which value can be referenced in {name} by $ POM), which has a corresponding name = value, Profile <br> is activated. If the value of the field is empty, then there is the attribute name field will activate the profile, or case-insensitive manner by matching attribute value field -> 
        <Property> 
    <-! Activation profile name of the property of -> 
         <name> mavenVersion </ name> 
    <-! value of the property profile of activation -> 
         <value> 2.0.3 </ value> 
        </ property> 
    <-! a file name, by detecting the presence or absence of the document to activation profile. check whether the missing file exists, if it does not exist activate profile. On the other hand, exists will check whether a file exists, if there is activated profile. -> 
        <File> 
    <-! If the specified file exists, the activation profile. -> 
         <EXISTS> 
    /file2.properties the basedir} {$ </ EXISTS> <-! If the specified file does not exist, the activation profile. ->
       </activation>

12.Repositories

    <Repository> 
               <the above mentioned id> Nexus </ the above mentioned id> 
               <name> local Private Nexus </ name> 
               <url> HTTP: // localhost: 8081 / Nexus / Content / Groups / public </ url> 
               <Releases> <Enabled> to true </ Enabled> </ Releases> 
                <snapshots> <Enabled> to true </ Enabled> </ snapshots> 
       </ Repository> 
    </ Repositories> 
    <-! remote repository list, which is used to fill Maven build system local warehouse a set of remote project use. -> 
    <Repositories> 
    <-! Contain information required to connect to a remote repository -> 
        <Repository> 
    <-! Remote repository that uniquely identifies -> 
         <the above mentioned id> codehausSnapshots </ the above mentioned id> 
    <-! Remote repository name ->
    <-! true or false indicating whether the warehouse for downloading some type of components (release, snapshots) open. -> 
          <Enabled> to false </ Enabled> 
    <-! This element specifies the update frequency occurs. Maven POM would be more local and remote timestamp of POM. The options here are: always (been), daily (default, daily), interval: X (where X is the time interval in minutes), or never (never). -> 
          <updatePolicy> Always </ updatePolicy> 
    <-! When Maven file failed checksum verification members how to do -ignore (ignored), fail (failure) or warn (warning). -> 
          <checksumPolicy> The warn </ checksumPolicy> 
         </ Releases> 
    <-! How to handle remote warehouse snapshot version of the download. With these two sets of releases and snapshots configuration, POM can be in each individual warehouse, adopt a different strategy for each type of component. For example, some people may decide to only open support for the snapshot version to download for development purposes. See repositories / repository / releases the element -> 
         <snapshots> 
          <Enabled /> <updatePolicy /> <checksumPolicy /> 
         </ snapshots>
         <URL> http://snapshots.maven.codehaus.org/maven2 </ URL> 
    <-! warehouse layout type for positioning and sorting member - may be default (default) or legacy (legacy). Maven 2 for warehouse provides a default layout; however, Maven 1.x had a different layout. We can use this element to specify the layout is the default (default) or legacy (legacy). -> 
         <layout> default </ layout> 
        </ Repository> 
       </ Repositories> 
    <-! Discover a remote repository list of plug-ins. Warehouse are the two main components of the home. The first dependent member is used as the other members. This is the most central component type warehouse stored. Another type plug member. Maven is a special type of plug member. For this reason, the plug-warehouse independently of the other warehouse. structure similar elements and repositories pluginRepositories element. Each pluginRepository element specifies a Maven can be used to find the remote address of the new plug-ins. -> 
       <pluginRepositories> 
     <-! Remote plugin repository contains information required to connect to see the profiles / profile / repositories / repository elements description -.> 
              <PluginRepository>            
         <Releases>       
         </ Releases> 
         <snapshots> 
          <
         </snapshots>
         <id/><name/><url/><layout/>
              </pluginRepository>
            </pluginRepositories>
      </profile>
     </profiles>

13.activeProfiles

    Default configuration: 
    <activeProfiles> 
        <activeProfile> dev </ activeProfile> 
        <- - <activeProfile> devitcast </ activeProfile>!> 
    </ ActiveProfiles> 
    Configuration Explanation: 
    <! - manual activation list of profiles, profile is applied in accordance with the order definition activeProfile. The element contains a set activeProfile elements, each activeProfile contains a profile id. Any profile id defined in the activeProfile, regardless of the environment setting, the corresponding profile will be activated. If no matching profile, then nothing will happen. For example, env-test is a activeProfile, corresponding to the id of the pom.xml profile is activated (or the profile.xml) in. If the process is running can not find such a profile, Maven will run as usual -> 
     <activeProfiles> 
        <-! -> 
        <activeProfile> env-the Test </ activeProfile> 
     </ activeProfiles> 
    </ Settings>

Configuration example:

Copy the code
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <!-- localRepository
   | The path to the local repository maven will use to store artifacts.
   |
   | Default: ${user.home}/.m2/repository
  <localRepository>/path/to/local/repo</localRepository>
  -->

  <localRepository>/opt/repository/maven</localRepository>
  <!-- interactiveMode
   | This will determine whether maven prompts you when it needs input. If set to false,
   | maven will use a sensible default value, perhaps based on some other setting, for
   | the parameter in question.
   |
   | Default: true
  <interactiveMode>true</interactiveMode>
  -->

  <!-- offline
   | Determines whether maven should attempt to connect to the network when executing a build.
   | This will have an effect on artifact downloads, artifact deployment, and others.
   |
   | Default: false
  <offline>false</offline>
  -->

  <!-- pluginGroups
   | This is a list of additional group identifiers that will be searched when resolving plugins by their prefix, i.e.
   | when invoking a command line like "mvn prefix:goal". Maven will automatically add the group identifiers
   | "org.apache.maven.plugins" and "org.codehaus.mojo" if these are not already contained in the list.
   |-->
  <pluginGroups>
    <!-- pluginGroup
     | Specifies a further group identifier to use for plugin lookup.
    <pluginGroup>com.your.plugins</pluginGroup>
    -->
  </pluginGroups>

  <!-- proxies
   | This is a list of proxies which can be used on this machine to connect to the network.
   | Unless otherwise specified (by system property or command-line switch), the first proxy
   | specification in this list marked as active will be used.
   |-->
  <proxies>
    <!-- proxy
     | Specification for one proxy, to be used in connecting to the network.
     |
    <proxy>
      <id>optional</id>
      <active>true</active>
      <protocol>http</protocol>
      <username>proxyuser</username>
      <password>proxypass</password>
      <host>proxy.host.net</host>
      <port>80</port>
      <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
    </proxy>
    -->
  </proxies>

  <!-- servers
   | This is a list of authentication profiles, keyed by the server-id used within the system.
   | Authentication profiles can be used whenever maven must make a connection to a remote server.
   |-->
  <servers>
    <!-- server
     | Specifies the authentication information to use when connecting to a particular server, identified by
     | a unique name within the system (referred to by the 'id' attribute below).
     |
     | NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are
     |       used together.
     |
    <server>
      <id>deploymentRepo</id>
      <username>repouser</username>
      <password>repopwd</password>
    </server>
    -->

    <!-- Another sample, using keys to authenticate.
    <server>
      <id>siteServer</id>
      <privateKey>/path/to/private/key</privateKey>
      <passphrase>optional; leave empty if not used.</passphrase>
    </server>
    -->
 <server>
        <id>nexus</id>
        <username>admin</username>
        <password>admin123</password>
    </server>
    <server>
        <id>releases</id>
        <username>admin</username>
        <password>anonymous123</password>
    </server>
    <server>
        <id>snapshots</id>
        <username>admin</username>
        <password>anonymous123</password>
    </server>
        <server>
            <id>thirdparty</id>
            <username>admin</username>
            <password>anonymous123</password>
        </server>
  </servers>

  <!-- mirrors
   | This is a list of mirrors to be used in downloading artifacts from remote repositories.
   |
   | It works like this: a POM may declare a repository to use in resolving certain artifacts.
   | However, this repository may have problems with heavy traffic at times, so people have mirrored
   | it to several places.
   |
   | That repository definition will have a unique id, so we can create a mirror reference for that
   | repository, to be used as an alternate download site. The mirror site will be the preferred
   | server for that repository.
   |-->
  <mirrors>
    <!-- mirror
     | Specifies a repository mirror site to use instead of a given repository. The repository that
     | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
     | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
     |
    <mirror>
      <id>mirrorId</id>
      <mirrorOf>repositoryId</mirrorOf>
      <name>Human Readable Name for this Mirror.</name>
      <url>http://my.repository.com/repo/path</url>
    </mirror>
     -->
        <mirror>
            <id>nexus</id>
            <name>internal nexus repository</name>
            <url>http://10.0.0.241:9999/repository/maven-public/</url> 
            <mirrorOf>*</mirrorOf> 
        </mirror> 
  </mirrors>

  <!-- profiles
   | This is a list of profiles which can be activated in a variety of ways, and which can modify
   | the build process. Profiles provided in the settings.xml are intended to provide local machine-
   | specific paths and repository locations which allow the build to work in the local environment.
   |
   | For example, if you have an integration testing plugin - like cactus - that needs to know where
   | your Tomcat instance is installed, you can provide a variable here such that the variable is
   | dereferenced during the build process to configure the cactus plugin.
   |
   | As noted above, profiles can be activated in a variety of ways. One way - the activeProfiles
   | section of this document (settings.xml) - will be discussed later. Another way essentially
   | relies on the detection of a system property, either matching a particular value for the property,
   | or merely testing its existence. Profiles can also be activated by JDK version prefix, where a
   | value of '1.4' might activate a profile when the build is executed on a JDK version of '1.4.2_07'.
   | Finally, the list of active profiles can be specified directly from the command line.
   |
   | NOTE: For profiles defined in the settings.xml, you are restricted to specifying only artifact
   |       repositories, plugin repositories, and free-form properties to be used as configuration
   |       variables for plugins in the POM.
   |
   |-->
  <profiles>
    <!-- profile
     | Specifies a set of introductions to the build process, to be activated using one or more of the
     | mechanisms described above. For inheritance purposes, and to activate profiles via <activatedProfiles/>
     | or the command line, profiles have to have an ID that is unique.
     |
     | An encouraged best practice for profile identification is to use a consistent naming convention
     | for profiles, such as 'env-dev', 'env-test', 'env-production', 'user-jdcasey', 'user-brett', etc.
     | This will make it more intuitive to understand what the set of introduced profiles is attempting
     | to accomplish, particularly when you only have a list of profile id's for debug.
     |
     | This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo.
    <profile>
      <id>jdk-1.4</id>

      <activation>
        <jdk>1.4</jdk>
      </activation>

      <repositories>
        <repository>
          <id>jdk14</id>
          <name>Repository for JDK 1.4 builds</name>
          <url>http://www.myhost.com/maven/jdk14</url>
          <layout>default</layout>
          <snapshotPolicy>always</snapshotPolicy>
        </repository>
      </repositories>
    </profile>
    -->

    <!--
     | Here is another profile, activated by the system property 'target-env' with a value of 'dev',
     | which provides a specific path to the Tomcat instance. To use this, your plugin configuration
     | might hypothetically look like:
     |
     | ...
     | <plugin>
     |   <groupId>org.myco.myplugins</groupId>
     |   <artifactId>myplugin</artifactId>
     |
     |   <configuration>
     |     <tomcatLocation>${tomcatPath}</tomcatLocation>
     |   </configuration>
     | </plugin>
     | ...
     |
     | NOTE: If you just wanted to inject this configuration whenever someone set 'target-env' to
     |       anything, you could just leave off the <value/> inside the activation-property.
     |
    <profile>
      <id>env-dev</id>

      <activation>
        <property>
          <name>target-env</name>
          <value>dev</value>
        </property>
      </activation>

      <properties>
        <tomcatPath>/path/to/tomcat/instance</tomcatPath>
      </properties>
    </profile>
    -->
<profile> 
<id>apatch</id> 
<repositories> 
<repository> 
<id>re-apatch</id> 
<name>remote apatch</name> 
<url>http://inno.starhubdev.com/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled> 
</snapshots>
</repository>
</repositories> 
</profile> 
<profile> 
<id>ibiblio</id> 
<repositories> 
<repository> 
<id>re-ibiblio</id> 
<name>remote ibiblio</name> 
<url>https://nexus.sourcesense.com/nexus/content/repositories/public/</url> 
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository> 
</repositories> 
</profile> 
<profile> 
<id>redev</id> 
<repositories> 
<repository> 
<id>re-nexus</id> 
<name>remote nexus</name> 
<url>http://repository.sonatype.org/content/groups/public/</url> 
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository> 
</repositories> 
</profile> 
<profile>
            <id>dev</id>
            <repositories>
                <repository>
                    <id>nexus</id>
                    <url>http://10.0.0.241:9999/nexus/content/groups/public</url>
                    <releases><enabled>true</enabled></releases>
                    <snapshots><enabled>true</enabled></snapshots>
                </repository>
            </repositories>
            <pluginRepositories>
                <pluginRepository>
                    <id>nexus</id>
                    <url>http://10.0.0.241:9999/nexus/content/groups/public</url>
                    <releases><enabled>true</enabled></releases>
                    <snapshots><enabled>true</enabled></snapshots>
                </pluginRepository>
            </pluginRepositories>
    </profile>
  </profiles>
  <!-- activeProfiles
   | List of profiles that are active for all builds.
   |
  <activeProfiles>
    <activeProfile>alwaysActiveProfile</activeProfile>
    <activeProfile>anotherAlwaysActiveProfile</activeProfile>
  </activeProfiles>
  -->
</settings>
Copy the code

 

Guess you like

Origin www.cnblogs.com/guohu/p/11334958.html