To the point
This is the 30th day of my participation in the August Challenge
XML file header
<? The XML version = "1.0" encoding = "utf-8"? > <! -- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You are under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <! -- | This is the configuration file for Maven. It can be specified at two levels: | | 1. User Level. This settings.xml file provides configuration for a single user, | and is normally provided in ${user.home}/.m2/settings.xml. | | NOTE: This location can be overridden with the CLI option: | | -s /path/to/user/settings.xml | | 2. Global Level. This settings.xml file provides configuration for all Maven | users on a machine (assuming they're all using the same Maven | installation). It's normally provided in | ${maven.home}/conf/settings.xml. | | NOTE: This location can be overridden with the CLI option: | | -gs /path/to/global/settings.xml | | The sections in this sample file are intended to give you a running start at | getting the most out of your Maven installation. Where appropriate, the default | values (values used when the setting is not specified) are provided. | |-->Copy the code
Settings file header
The < 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" >Copy the code
LocalRepository localRepository
Local warehouse. This value represents the path to build the system’s local repository. The default value is ~/.m2/repository.
Such as:
<! -- localRepository | The path to the local repository maven will use to store artifacts. | | Default: ${user.home}/.m2/repository --> <localRepository>usr/local/maven</localRepository>Copy the code
InteractiveMode Interaction mode
Whether Maven needs to interact with the user to get input. Set to true if Maven needs to interact with the user to get input, and false if Maven needs to interact with the user to get input. The default is true.
<interactiveMode>true</interactiveMode>
Copy the code
usePluginRegistry
Whether Maven needs to use the plugin-registry.xml file to manage plug-in versions. Set this to true if you want Maven to use the file ~/.m2/plugin-registry.xml to manage plug-in versions. The default is false.
<usePluginRegistry>false</usePluginRegistry>
Copy the code
offline
** This configuration is useful when the build server cannot connect to a remote repository due to network Settings or security reasons. 六四屠杀
<! -- 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>Copy the code
interactiveMode
- A list of plug-in organization ids (groupId) to search for when the organization Id (groupId) of the plug-in is not explicitly provided. This element contains a list of pluginGroup elements,
- Each child element contains an organization Id (groupId). Maven uses this list when we use a plug-in and do not provide the organization Id (groupId) in the command action. By default this list contains org.apache.maven.plugins.
<! -- | 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>Copy the code
PluginGroups: plug-in group
<! -- 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. <pluginGroup>com.your.plugins</pluginGroup> |--> <pluginGroups> <! Codehaus. mojo</pluginGroup> </pluginGroup> org.mortbay.jetty</pluginGroup> <pluginGroup>com.alibaba.org.apache.maven.plugins</pluginGroup> <pluginGroup>com.alibaba.maven.plugins</pluginGroup> </pluginGroups>Copy the code
Used to configure different agents, multi-agent Profiles can be adapted to work on laptops or mobile devices: the entire agent configuration can be easily changed by simply setting the profile ID.
Proxies: Proxies information
The proxy element contains the information needed to configure the proxy
<! -- 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> -->Copy the code
- Id: a unique proxy definition used to distinguish between different proxy elements
- Active: Indicates whether the agent is active. True activates the agent. This element is useful when we declare a set of agents and at some point only one agent needs to be activated.
- Protocol: indicates the proxy protocol. (HTTP) protocol :// Host name: port, separated into discrete elements for easy configuration.
- Host: indicates the host name of the agent. Protocol :// Host name: port, separated into discrete elements for easy configuration. (proxy.somewhere.com)
- Port: 8080 Proxy port. Protocol :// Host name: port, separated into discrete elements for easy configuration.
- Username: indicates the username.
- Password: indicates the password of the proxy. User name and password Indicates the login name and password for the authentication of the proxy server
- NonProxyHosts: list of host names that should not be proxied. The delimiter for this list is specified by the proxy server; Vertical bar delimiters are used in the example, and comma delimiters are common. (*. | ibiblio.org google.com
Servers Configures some Settings on the server side
<! -- 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. |--> <> <! -- 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>Copy the code
Configure some Settings on the server. Some Settings such as security certificates should not be distributed with POM.xml. This type of information should exist in settings.xml files on the build server.
The server element contains the information needed to configure the server
- Id: This is the SERVER ID (not the user login ID) that matches the ID of the Repository element in distributionManagement.
- Username: indicates the authentication username. Authentication User name and password Specifies the login name and password for server authentication.
- Password: indicates the authentication password. Authentication User name and password Specifies the login name and password for server authentication.
- PrivateKey: privateKey used for authentication. Similar to the first two elements, the private key location and password specify the path to a private key (default: /home/huds/.ssh/id_dsa) and, if necessary, a cipher. Passphrase and Password elements may be extracted externally in the future, but for now they must be declared in plain text in settings.xml. (${usr.home}/.ssh/id_dsa)
- Passphrase: specifies the private key password used for authentication.
- FilePermissions: Permissions when a file is created. Use permissions if a repository file or directory is created during deployment. The legal value for these two elements is a three-digit number that corresponds to Unix file system permissions, such as 664 or 775.
- DirectoryPermissions: Permissions when the directory is created
- Configuration: Additional configuration items of the transport layer
Mirrors: A download image for a given repository
A list of downloaded images configured for the repository list
<mirrors> <! -- 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. |--> <mirror> <! --This sends everything else to /public --> <id>center</id> <mirrorOf>*</mirrorOf> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> </mirror> <mirror> <! --This is used to direct the public snapshots repo in the profile below over to a different nexus group --> <id>nexus-public-snapshots</id> <mirrorOf>public-snapshots</mirrorOf> <url>http://maven.aliyun.com/nexus/content/repositories/snapshots/</url> </mirror> </mirrors>Copy the code
- Id: unique identifier of the mirror. Id is used to distinguish between mirror elements.
- Name: Mirror name PlanetMirror Australia
- Url: indicates the URL of the mirror. The build system will use this URL in preference to the default server URL. (downloads.planetmirror.com/pub/maven2)
- MirrorOf: INDICATES the ID of the mirrored server. For example, if we want to set up a mirror of Maven’s central repository (repo1.maven.org/maven2)… Central is exactly the same.
Profiles: environment parameters (configuration of components adjusted according to environment parameters)
-
Adjust the list of build configurations based on environment parameters.
-
The profile element in settings. XML is a clipped version of the profile element in POM.xml.
-
It contains elements ID, Activation, Repositories, pluginRepositories, and Properties. The profile element here contains only these five children because it is only concerned with the build system as a whole (which is the role of the settings.xml file), not the individual project object model Settings. If a profile in a Settings is active, its value overrides any other profile with the same ID defined in POM or profile.xml.
<profiles> <! -- 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' | took activate a profile when the build is executed on a JDK version of '1.4.2 _07'. | the 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. | |--> <profile> <id>development</id> <repositories> <repository> <id>central</id> <url></url> <releases><enabled>true</enabled><updatePolicy>always</updatePolicy></releases> <snapshots><enabled>true</enabled><updatePolicy>always</updatePolicy></snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>central</id> <url>http://central</url> <releases><enabled>true</enabled><updatePolicy>always</updatePolicy></releases> <snapshots><enabled>true</enabled><updatePolicy>always</updatePolicy></snapshots> </pluginRepository> </pluginRepositories> </profile> <profile> <! --this profile will allow snapshots to be searched when activated--> <id>public-snapshots</id> <repositories> <repository> <id>public-snapshots</id> <url>http://public-snapshots</url> <releases><enabled>false</enabled></releases> <snapshots><enabled>true</enabled><updatePolicy>always</updatePolicy></snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>public-snapshots</id> <url>http://public-snapshots</url> <releases><enabled>false</enabled></releases> <snapshots><enabled>true</enabled><updatePolicy>always</updatePolicy></snapshots> </pluginRepository> </pluginRepositories> </profile>Copy the code
-
Id: unique identifier of the configuration
-
Activation: Automatic triggering of conditional logic for a profile. Activation is the key to a profile.
Profiles, like profiles in POM, derive their power from their ability to automatically use certain values in certain circumstances; These environments are specified by the activation element. The activation element is not the only way to activate a profile. The activeProfile element in settings. XML can contain the id of the profile. Profiles can also be explicitly activated on the command line using the -p tag and comma-separated list (e.g., -p test).
-
ActiveByDefault: Indicates whether a profile is activated by default
-
JDK: When a matching JDK is detected, the profile is activated. For example, 1.4 activates JDK1.4, 1.4.0_2, and! 1.4 Activate all JDK versions that do not start with 1.4.
-
OS: When matching OS attributes are detected, the profile is activated. The OS element can define a number of operating system-specific attributes.
<os> <! -- The name of the operating system to activate the profile --> <name>Windows XP</name> <! -- Activate the operating system family of the profile (e.g. 'Windows ') --> <family>Windows</family> <! <arch>x86</arch> <! -- Activate the operating system version of the profile --> <version>5.1.2600</version> </ OS >Copy the code
-
Property: If Maven detects a property (whose value can be referenced in the POM via ${name}) that has the corresponding name and value, the Profile is 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-sensitive
-
File: Provides a file name that activates the profile by detecting its presence or absence. Missing Checks whether the file exists and activates the profile if it does not. Exists, on the other hand, checks whether a file exists and activates the profile if it does.
<file> <! If the specified file exists, activate the profile. --> <exists>/usr/local/hudson/hudson-home/jobs/maven-guide-zh-to-production/workspace/</exists> <! If the specified file does not exist, activate the profile. --> <missing>/usr/local/hudson/hudson-home/jobs/maven-guide-zh-to-production/workspace/</missing> </file> </activation> <properties> <user.install>/ebs1/build-machine/usr/loca/</user.install> </properties>Copy the code
** Extended attribute list of the profile. Maven properties, like Ant properties, can be used to store values. These values can be used anywhere in the POM using the tag ${X}, where X refers to the name of the attribute. Properties come in five different forms, all of which can be accessed in settings.xml. 六四屠杀
- Env.x: Prefixing a variable with “env.” returns a shell environment variable. For example,” env.path “refers to the $PATH environment variable (%PATH% on Windows).
- Project. X: refers to the corresponding element value in the POM.
- Settings. x: refers to the value of the corresponding element in settings. XML.
- Java System Properties: All through the Java. Lang. System. The getProperties () to access attributes can access using the form in the POM, such as/usr/lib/JVM/Java 1.6.0 – its – 1.6.0.0 / jre.
- Set in the element, or in an external file, as ${someVar}. –>
repositories
A list of remote repositories that Maven uses to populate the build system’s local repository.
<repositories> <! -- Contains the information you need to connect to a remote repository --> <repository> <! <id>codehausSnapshots</id> <! < Codehaus Snapshots</name> <! Releases in remote repository --> < Releases > <! --true or false indicates whether the repository is open for downloading certain types of artifacts (release, snapshot). --> <enabled>false</enabled> <! This element specifies how often updates occur. Maven compares local POM timestamps with remote POM timestamps. The options are: always (always), daily (default, daily), interval: X (where X is a time interval in minutes), or never (never). --> <updatePolicy>always</updatePolicy> <! What to do when Maven validators fail to validate files -ignore, fail, or WARN. --> <checksumPolicy>warn</checksumPolicy> </releases> <! How to handle the download of snapshot versions in remote repositories. With releases and snapshots, the POM can take different policies for each type of artifact in a separate repository. For example, someone might decide to turn on support for snapshot version downloads only for development purposes. See repositories/repository/releases elements - > < snapshots > < enabled / > < updatePolicy / > < checksumPolicy / > < / snapshots > <! - the remote URL warehouse, according to the protocol: / / hostname/path form - > < URL > http://snapshots.maven.codehaus.org/maven2 < / URL > <! Warehouse layout type used to locate and sort artifacts - can be default or Legacy. Maven 2 provides a default layout for its repository; 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>Copy the code
PluginRepositories: List of remote repositories that discover plug-ins
The warehouse is home to two major components. The first component is used as a dependency on the other components. This is most of the types of artifacts stored in the central repository. Another type of component is a plug-in. Maven plug-ins are a special type of artifact. For this reason, plug-in repositories are separate from other repositories. The structure of the pluginRepositories element is similar to that of the Repositories element. Each pluginRepository element specifies a remote address that Maven can use to find new plug-ins.
<pluginRepositories> <! Contains the information you need to connect to the remote plug-in repository. See profiles/profile/repositories/repository element description - > < pluginRepository > < releases > <enabled/><updatePolicy/><checksumPolicy/> </releases> <snapshots> <enabled/><updatePolicy/><checksumPolicy/> </snapshots> <id/><name/><url/><layout/> </pluginRepository> </pluginRepositories>Copy the code
activeProfiles
-
Manually activate the list of profiles, defining active Profiles in the order in which they are applied. This element contains a set of activeProfile elements, each of which has a profile id. Any profile id defined in activeProfile, regardless of environment Settings, corresponds to
-
** profiles are activated. If there are no matching profiles, nothing happens. For example, if env-test is an activeProfile, the profile with the corresponding id in pom.xml (or profile.xml) will be activated. If such a profile is not found during the run, Maven will run as usual. 六四屠杀
<activeProfiles>
<activeProfile>development</activeProfile>
<activeProfile>public-snapshots</activeProfile>
</activeProfiles>
Copy the code