Maven series 1--settings.xml configuration details

 

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
 <!--Local repository. The value represents the path to the build system's local repository. Its default value is ~/.m2/repository. -->
 <localRepository>usr/local/maven</localRepository>
 <!--Whether Maven needs to interact with the user to get input. Set to true if Maven needs to interact with the user for input, false otherwise. Defaults to true. -->
 <interactiveMode>true</interactiveMode>
 <!--Whether Maven needs to use the plugin-registry.xml file to manage plugin versions. Set to true if you want Maven to use the file ~/.m2/plugin-registry.xml to manage plugin versions. Defaults to false. -->
 <usePluginRegistry>false</usePluginRegistry>
 <!-- Indicates whether Maven needs to run in offline mode. true if the build system needs to run in offline mode, defaults to false. This configuration is useful when the build server cannot connect to the remote repository due to network settings or security reasons. -->
 <offline>false</offline>
 <!--A list of organization IDs (groupId) for searching plugins when the plugin's organization ID (groupId) is not explicitly provided. This element contains a list of pluginGroup elements, each of which contains an organization ID (groupId). This list is used by Maven when we use a plugin and don't provide it with an organization ID (groupId) on the command line. By default this list includes org.apache.maven.plugins. -->
 <pluginGroups>
  <!--plugin's organization ID (groupId) -->
  <pluginGroup>org.codehaus.mojo</pluginGroup>
 </pluginGroups>
 <!--Used to configure different proxies, multi-agent profiles can cope with the working environment of laptops or mobile devices: it is easy to change the whole proxy configuration by simply setting the profile id. -->
 <proxies>
  <!--The proxy element contains the information needed to configure the proxy-->
  <proxy>
   <!--The unique definer of the proxy, used to distinguish different proxy elements. -->
   <id>myproxy</id>
   <!--Whether the agent is the active one. true to activate the proxy. This element can come in handy when we declare a set of proxies and only need to activate one proxy at a time. -->
   <active>true</active>
   <!--The protocol of the proxy. protocol://hostname:port, separated into discrete elements for easy configuration. -->
   <protocol>http</protocol>
   <!--The hostname of the proxy. protocol://hostname:port, separated into discrete elements for easy configuration. -->
   <host>proxy.somewhere.com</host>
   <!--The port of the proxy. protocol://hostname:port, separated into discrete elements for easy configuration. -->
   <port>8080</port>
   <!--The username of the proxy, the username and password represent the login name and password of the proxy server authentication. -->
   <username>proxyuser</username>
   <!--The password of the proxy, the username and password represent the login name and password of the proxy server authentication. -->
   <password>somepassword</password>
   <!--List of hostnames that should not be proxied. The delimiter for this list is specified by the proxy server; the pipe delimiter is used in the examples, but commas are also common. -->
   <nonProxyHosts>*.google.com|ibiblio.org</nonProxyHosts>
  </proxy>
 </proxies>
 <!--Configure some settings on the server. Some settings like security certificates should not be distributed with pom.xml. This type of information should exist in the settings.xml file on the build server. -->
 <servers>
  <!--The server element contains the information needed to configure the server-->
  <server>
   <!-- This is the id of the server (note that it is not the id of the user login), which matches the id of the repository element in distributionManagement. -->
   <id>server001</id>
   <!--Authentication username. The authentication user name and authentication password indicate the login name and password required for server authentication. -->
   <username>my_login</username>
   <!--Authentication password. The authentication user name and authentication password indicate the login name and password required for server authentication. -->
   <password>my_password</password>
   <!--The location of the private key used for authentication. Similar to the first two elements, the private key location and private key password specify a path to the private key (default is /home/hudson/.ssh/id_dsa) and a passphrase if needed. In the future the passphrase and password elements may be extracted externally, but currently they must be declared as plain text in the settings.xml file. -->
   <privateKey>${usr.home}/.ssh/id_dsa</privateKey>
   <!--The private key password used for authentication. -->
   <passphrase>some_passphrase</passphrase>
   <!--The permissions when the file was created. If a repository file or directory is created during deployment, permissions can be used at this time. The legal value of these two elements is a three-digit number, which corresponds to the permissions of the unix file system, such as 664, or 775. -->
   <filePermissions>664</filePermissions>
   <!--The permissions when the directory was created. -->
   <directoryPermissions>775</directoryPermissions>
   <!--Transport layer additional configuration items-->
   <configuration></configuration>
  </server>
 </servers>
 <!--The list of download mirrors configured for the repository list. -->
 <mirrors>
  <!--Download mirror for the given repository. -->
  <mirror>
   <!--A unique identifier for this image. id is used to distinguish different mirror elements. -->
   <id>planetmirror.com</id>
   <!--image name-->
   <name>PlanetMirror Australia</name>
   <!--The URL of this mirror. The build system will use this URL in preference to the default server URL. -->
   <url>http://downloads.planetmirror.com/pub/maven2</url>
   <!-- The id of the mirrored server. For example, if we want to set up a mirror of the Maven central repository (http://repo1.maven.org/maven2), we need to set this element to central. This must be exactly the same as the id central of the central repository. -->
   <mirrorOf>central</mirrorOf>
  </mirror>
 </mirrors>
 <!--Adjust a list of build configurations based on environment parameters. The profile element in settings.xml is a cropped version of the profile element in pom.xml. It contains id, activation, repositories, pluginRepositories and properties elements. The profile element here only contains these five sub-elements because we only care about the build system as a whole (this is the role of the settings.xml file), not individual project object model settings. If a profile in settings is activated, its value overrides any other profile with the same id defined in the POM or profile.xml. -->
 <profiles>
  <!--Configuration of components adjusted according to environment parameters-->
  <profile>
   <!--A unique identifier for this configuration. -->
   <id>test</id>
   <!--Automatically trigger the conditional logic of the profile. Activation is the key to opening the profile. Like the profile in the POM, the power of a profile comes from its ability to automatically use certain values ​​in certain contexts; these contexts are specified through the activation element. The activation element is not the only way to activate a profile. The activeProfile element in the settings.xml file can contain the id of the profile. Profiles can also be explicitly activated on the command line by using the -P flag and a comma-separated list (eg, -P test ). -->
   <activation>
    <!--Profile is activated by default or not-->
    <activeByDefault>false</activeByDefault>
    <!-- When a matching jdk is detected, the profile is activated. For example, 1.4 activates JDK1.4, 1.4.0_2, while !1.4 activates all versions of JDK not starting with 1.4. -->
    <jdk>1.5</jdk>
    <!--The profile is activated when a matching operating system attribute is detected. The os element can define some operating system-related properties. -->
    <os>
     <!--The name of the operating system that activates the profile-->
     <name>Windows XP</name>
     <!--The operating system that activates the profile belongs to the family (such as 'windows') -->
     <family>Windows</family>
     <!--The operating system architecture of the active profile-->
     <arch>x86</arch>
     <!--The operating system version that activates the profile-->
     <version>5.1.2600</version>
    </os>
    <!--If Maven detects a property (the value of which can be referenced in the POM via ${name}) with a corresponding name and value, the Profile will be activated. If the value field is empty, the presence of the attribute name field activates the profile, otherwise the attribute value field is matched case-sensitively -->
    <property>
     <!--Name of the attribute that activates the profile-->
     <name>mavenVersion</name>
     <!--The value of the attribute that activates the profile-->
     <value>2.0.3</value>
    </property>
    <!--Provide a filename to activate the profile by detecting its presence or absence. missing checks if the file exists, and activates the profile if it doesn't. On the other hand, exists will check if the file exists and activate the profile if it exists. -->
    <file>
     <!--If the specified file exists, the profile is activated. -->
     <exists>/usr/local/hudson/hudson-home/jobs/maven-guide-zh-to-production/workspace/</exists>
     <!--If the specified file does not exist, the profile is activated. -->
     <missing>/usr/local/hudson/hudson-home/jobs/maven-guide-zh-to-production/workspace/</missing>
    </file>
   </activation>
   <!--The list of extended attributes corresponding to the profile. Maven properties, like properties in Ant, can be used to store some value. These values ​​can be used anywhere in the POM using the tag ${X}, where X refers to the name of the property. Properties come in five different forms and are all accessible in the settings.xml file.
   1. env.X: Prefixing a variable with "env." will return a shell environment variable. For example, "env.PATH" refers to the $path environment variable (%PATH% on Windows).
   2. project.x: refers to the corresponding element value in the POM.
   3. settings.x: refers to the value of the corresponding element in settings.xml.
   4. Java System Properties: All properties that can be accessed through java.lang.System.getProperties() can be accessed in the POM using this form,
    Such as /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/jre.
   5. x: Set in the <properties/> element, or in an external file, in the form of ${someVar}. -->
   <properties>
    <user.install>/ebs1/build-machine/usr/local/hudson/hudson-home/jobs/maven-guide-</user.install>
   </properties>
   <!--Remote repository list, which is a set of remote projects used by Maven to populate the local repository of the build system. -->
   <repositories>
    <!--Contains information needed to connect to the remote repository-->
    <repository>
     <!--Unique ID of remote warehouse-->
     <id>codehausSnapshots</id>
     <!--Remote repository name-->
     <name>Codehaus Snapshots</name>
     <!--How to handle the download of the release version in the remote repository-->
     <releases>
      <!--true or false indicates whether the repository is enabled for downloading a certain type of component (release version, snapshot version). -->
      <enabled>false</enabled>
      <!--This element specifies how often updates occur. Maven compares the timestamps of the local POM and the remote POM. The options here are: always (always), daily (default, daily), interval: X (where X is the interval in minutes), or never (never). -->
      <updatePolicy>always</updatePolicy>
      <!--What to do when Maven fails to validate an artifact validation file - ignore (ignore), fail (fail), or warn (warn). -->
      <checksumPolicy>warn</checksumPolicy>
     </releases>
     <!--How to handle the download of snapshot versions in remote repositories. With the two sets of configurations releases and snapshots, POM can take a different strategy for each type of artifact in each individual repository. For example, someone might decide to turn on support for snapshot version downloads only for development purposes. See repositories/repository/releases element -->
     <snapshots>
      <enabled/><updatePolicy/><checksumPolicy/>
     </snapshots>
     <!--Remote warehouse URL, in the form of protocol://hostname/path-->
     <url>http://snapshots.maven.codehaus.org/maven2</url>
     <!--Repository layout type for positioning and ordering widgets - can be default (default) or legacy (legacy). Maven 2 provides a default layout for its repositories; however, Maven 1.x has a different layout. We can use this element to specify whether the layout is default or legacy. -->
     <layout>default</layout>
    </repository>
   </repositories>
   <!--List of remote repositories where plugins are found. The warehouse is home to two main components. The first type of component is used as a dependency of other components. This is the majority of the artifact types stored in the central repository. Another type of widget is a plugin. A Maven plugin is a special type of artifact. For this reason, the plugin repository is independent of other repositories. The structure of the pluginRepositories element is similar to the structure of the repositories element. Each pluginRepository element specifies a remote address that Maven can use to find new plugins. -->
   <pluginRepositories>
    <!--Contains the information needed to connect to the remote plugin repository. See the description of the profiles/profile/repositories/repository element-->
          <pluginRepository>           
     <releases>      
      <enabled/><updatePolicy/><checksumPolicy/>
     </releases>
     <snapshots>
      <enabled/><updatePolicy/><checksumPolicy/>
     </snapshots>
     <id/><name/><url/><layout/>
          </pluginRepository>
        </pluginRepositories>
        <!--List of manually activated profiles, define activeProfile in the order in which profiles are applied. This element contains a set of activeProfile elements, each activeProfile contains a profile id. Any profile id defined in activeProfile, regardless of environment settings, corresponds to
        profile will be activated. If there is no matching profile, nothing happens. For example, if env-test is an activeProfile, the profile corresponding to the id in pom.xml (or profile.xml) will be activated. If such a profile is not found during runtime, Maven will run as usual. -->
   <activeProfiles>
    <!-- -->
    <activeProfile>env-test</activeProfile>
   </activeProfiles>
  </profile>
 </profiles>
</settings>

 

 

Reprinted from:

 http://pengqb.iteye.com/blog/825401

 The Definitive Guide to Maven

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326386056&siteId=291194637