- Как настроить settings xml maven
- Configuring Maven
- Configuring your Local Repository
- Configuring a Proxy
- Configuring Parallel Artifact Resolution
- Security and Deployment Settings
- Using Mirrors for Repositories
- Profiles
- Optional configuration
- Settings
- Security
- Toolchains
- Как настроить settings xml maven
- settings
- proxy
- server
- mirror
- profile
- activation
- property
- repository
- releases
- snapshots
- pluginRepository
Как настроить settings xml maven
Configuring Maven
Maven configuration occurs at 3 levels:
- Project — most static configuration occurs in pom.xml
- Installation — this is configuration added once for a Maven installation
- User — this is configuration specific to a particular user
The separation is quite clear — the project defines information that applies to the project, no matter who is building it, while the others both define settings for the current environment.
Note: the installation and user configuration cannot be used to add shared project information — for example, setting or company-wide.
For this, you should have your projects inherit from a company-wide parent pom.xml .
You can specify your user configuration in $
Configuring your Local Repository
The location of your local repository can be changed in your user configuration. The default value is $
Note: The local repository must be an absolute path.
Configuring a Proxy
Proxy configuration can also be specified in the settings file.
For more information, see the Guide to using a Proxy.
Configuring Parallel Artifact Resolution
By default, Maven 2.1.0+ will download up to 5 artifacts (from different groups) at once. To change the size of the thread pool, start Maven using -Dmaven.artifact.threads . For example, to only download single artifacts at a time:
You may wish to set this option permanently, in which case you can use the MAVEN_OPTS environment variable. For example:
Security and Deployment Settings
Repositories to deploy to are defined in a project in the section. However, you cannot put your username, password, or other security settings in that project. For that reason, you should add a server definition to your own settings with an id that matches that of the deployment repository in the project.
In addition, some repositories may require authorization to download from, so the corresponding settings can be specified in a server element in the same way.
Which settings are required will depend on the type of repository you are deploying to. As of the first release, only SCP deployments and file deployments are supported by default, so only the following SCP configuration is needed:
To encrypt passwords in these sections, refer to Encryption Settings.
Using Mirrors for Repositories
Repositories can be declared inside a project, which means that if you have your own custom repositories, those sharing your project easily get the right settings out of the box. However, you may want to use an alternative mirror for a particular repository without changing the project files. Refer to Guide to Mirror Settings for more details.
Profiles
Repository configuration can also be put into a profile. You can have multiple profiles, with one set to active so that you can easily switch environments. Read more about profiles in Introduction to Build Profiles.
Optional configuration
Maven will work for most tasks with the above configuration, however if you have any environmental specific configuration outside of individual projects then you will need to configure settings. The following sections refer to what is available.
Settings
Maven has a settings file located in the Maven installation and/or user home directory that configure environmental specifics such as:
- HTTP proxy server
- repository manager location
- server authentication and passwords
- other configuration properties
For information on this file, see the Settings reference
Security
As of Maven 2.1.0+, you can encrypt passwords in your settings file, however you must first configure a master password. For more information on both server passwords and the master password, see the Guide to Password Encryption.
Toolchains
As of Maven 2.0.9+, you can build a project using a specific version of JDK independent from the one Maven is running with. For more information, see the Guide to Using Toolchains.
Источник
Как настроить settings xml maven
This is a reference for the user-specific configuration for Maven.
Includes things that should not be distributed with the pom.xml file, such as developer identity, along with local settings, like proxy information.
The default location for the settings file is
settings
Root element of the user configuration file.
| Element | Type | Description |
|---|---|---|
| localRepository | String | The local repository. Default value is: $ |
| interactiveMode | boolean | Whether Maven should attempt to interact with the user for input. Default value is: true. |
| usePluginRegistry | boolean | Whether Maven should use the plugin-registry.xml file to manage plugin versions. Default value is: false. |
| offline | boolean | Indicate whether maven should operate in offline mode full-time. Default value is: false. |
| proxies/proxy* | List | (Many) Configuration for different proxy profiles. Multiple proxy profiles might come in handy for anyone working from a notebook or other mobile platform, to enable easy switching of entire proxy configurations by simply specifying the profile id, again either from the command line or from the defaults section below. |
| servers/server* | List | (Many) Configuration of server-specific settings, mainly authentication method. This allows configuration of authentication on a per-server basis. |
| mirrors/mirror* | List | (Many) Configuration of download mirrors for repositories. |
| profiles/profile* | List | (Many) Configuration of build profiles for adjusting the build according to environmental parameters. |
| activeProfiles/activeProfile* | List | (Many) List of manually-activated build profiles, specified in the order in which they should be applied. |
| pluginGroups/pluginGroup* | List | (Many) List of groupIds to search for a plugin when that plugin groupId is not explicitly provided. |
proxy
element contains informations required to a proxy settings.
| Element | Type | Description |
|---|---|---|
| active | boolean | Whether this proxy configuration is the active one. Default value is: true. |
| protocol | String | The proxy protocol. Default value is: http. |
| username | String | The proxy user. |
| password | String | The proxy password. |
| port | int | The proxy port. Default value is: 8080. |
| host | String | The proxy host. |
| nonProxyHosts | String | The list of non-proxied hosts (delimited by |). |
| id | String | No description. Default value is: default. |
server
The element contains informations required to a server settings.
| Element | Type | Description |
|---|---|---|
| username | String | The username used to authenticate. |
| password | String | The password used in conjunction with the username to authenticate. |
| privateKey | String | The private key location used to authenticate. |
| passphrase | String | The passphrase used in conjunction with the privateKey to authenticate. |
| filePermissions | String | The permissions for files when they are created. |
| directoryPermissions | String | The permissions for directories when they are created. |
| configuration | DOM | Extra configuration for the transport layer. |
| id | String | No description. Default value is: default. |
mirror
A download mirror for a given repository.
| Element | Type | Description |
|---|---|---|
| mirrorOf | String | The server ID of the repository being mirrored, e.g., "central". This MUST NOT match the mirror id. |
| name | String | The optional name that describes the mirror. |
| url | String | The URL of the mirror repository. |
| layout | String | The layout of the mirror repository. Since Maven 3. Default value is: default. |
| mirrorOfLayouts | String | The layouts of repositories being mirrored. This value can be used to restrict the usage of the mirror to repositories with a matching layout (apart from a matching id). Since Maven 3. Default value is: default,legacy. |
| id | String | No description. Default value is: default. |
profile
Modifications to the build process which is keyed on some sort of environmental parameter.
| Element | Type | Description |
|---|---|---|
| activation | Activation | The conditional logic which will automatically trigger the inclusion of this profile. |
| properties/key=value* | Properties | (Many) Extended configuration specific to this profile goes here. Contents take the form of |
| repositories/repository* | List | (Many) The lists of the remote repositories. |
| pluginRepositories/pluginRepository* | List | (Many) The lists of the remote repositories for discovering plugins. |
| id | String | No description. Default value is: default. |
activation
The conditions within the build runtime environment which will trigger the automatic inclusion of the parent build profile.
| Element | Type | Description |
|---|---|---|
| activeByDefault | boolean | Flag specifying whether this profile is active as a default. Default value is: false. |
| jdk | String | Specifies that this profile will be activated when a matching JDK is detected. |
| os | ActivationOS | Specifies that this profile will be activated when matching OS attributes are detected. |
| property | ActivationProperty | Specifies that this profile will be activated when this System property is specified. |
| file | ActivationFile | Specifies that this profile will be activated based on existence of a file. |
This is an activator which will detect an operating system's attributes in order to activate its profile.
| Element | Type | Description |
|---|---|---|
| name | String | The name of the OS to be used to activate a profile. |
| family | String | The general family of the OS to be used to activate a profile (e.g. 'windows') |
| arch | String | The architecture of the OS to be used to activate a profile. |
| version | String | The version of the OS to be used to activate a profile. |
property
This is the property specification used to activate a profile. If the value field is empty, then the existence of the named property will activate the profile, otherwise it does a case-sensitive match against the property value as well.
| Element | Type | Description |
|---|---|---|
| name | String | The name of the property to be used to activate a profile. |
| value | String | The value of the property to be used to activate a profile. |
This is the file specification used to activate a profile. The missing value will be a the location of a file that needs to exist, and if it doesn't the profile must run. On the other hand exists will test for the existence of the file and if it is there will run the profile.
| Element | Type | Description |
|---|---|---|
| missing | String | The name of the file that should be missing to activate a profile. |
| exists | String | The name of the file that should exist to activate a profile. |
repository
Repository contains the information needed for establishing connections with remote repository
| Element | Type | Description |
|---|---|---|
| releases | RepositoryPolicy | How to handle downloading of releases from this repository |
| snapshots | RepositoryPolicy | How to handle downloading of snapshots from this repository |
| id | String | A unique identifier for a repository. |
| name | String | Human readable name of the repository. |
| url | String | The url of the repository. |
| layout | String | The type of layout this repository uses for locating and storing artifacts - can be "legacy" or "default". Default value is: default. |
releases
| Element | Type | Description |
|---|---|---|
| enabled | boolean | Whether to use this repository for downloading this type of artifact. Default value is: true. |
| updatePolicy | String | The frequency for downloading updates - can be "always", "daily" (default), "interval:XXX" (in minutes) or "never" (only if it doesn't exist locally). |
| checksumPolicy | String | What to do when verification of an artifact checksum fails - warn, fail, etc. Valid values are "fail" or "warn". |
snapshots
| Element | Type | Description |
|---|---|---|
| enabled | boolean | Whether to use this repository for downloading this type of artifact. Default value is: true. |
| updatePolicy | String | The frequency for downloading updates - can be "always", "daily" (default), "interval:XXX" (in minutes) or "never" (only if it doesn't exist locally). |
| checksumPolicy | String | What to do when verification of an artifact checksum fails - warn, fail, etc. Valid values are "fail" or "warn". |
pluginRepository
Repository contains the information needed for establishing connections with remote repository
| Element | Type | Description |
|---|---|---|
| releases | RepositoryPolicy | How to handle downloading of releases from this repository |
| snapshots | RepositoryPolicy | How to handle downloading of snapshots from this repository |
| id | String | A unique identifier for a repository. |
| name | String | Human readable name of the repository. |
| url | String | The url of the repository. |
| layout | String | The type of layout this repository uses for locating and storing artifacts - can be "legacy" or "default". Default value is: default. |
Copyright ©2001–2019 The Apache Software Foundation. All rights reserved.
Источник