Maven-Settings

Maven - Settings.xml

settings.xml定义了许多配置用来控制maven的执行。但并不绑定与任何独立的项目。

有两个路径放置settings.xml

Maven 默认配置: ${maven.home}/conf/settings.xml

User默认配置:${user.home}/.m2/settings.xml

User配置优先级高于Maven

settings.xml可配置项:


     
     
     
     
     
     
     
     
     
   

环境变量或者系统参数可以被引用到settings.xml。 eg: ${user.home} ${env.HOME}

配置项详情

localRepository

本地仓库, 远程下载下来的jar包会放置于该目录

interactiveMode

交互模式,该配置会决定当maven需要输入的时候是否会提示用户,若设置为false,则会使用合理的默认值。

offline

当构建系统需要在离线模式的时候,该配置会起到作用。

Plugin groups

该元素包含一系列pluginGroup元素, 每个包含groupid。当一个插件被使用且没提供相应的groupid的时候,该项的元素会被使用到。这个列表默认包含org.apache.maven.plugins org.codehaus.mojo


   org.eclipse.jetty
 

mvn jetty:run

Servers

下载jar包的仓库用户名和密码被存储在该项。


   
     server001
     my_login
     my_password
     ${user.home}/.ssh/id_dsa
     some_passphrase
     664
     775
     
   
 

id: 与server中的id相对应

username,password: 服务器的登录账号和密码

privateKey,passphrase:密钥相关

filePermissions,directoryPermissions:文件及文件夹权限

Mirrors

镜像定义


   
     planetmirror.com
     PlanetMirror Australia
     http://downloads.planetmirror.com/pub/maven2
     central
   
 

id,name: 镜像的唯一标识符和友好名字, id和Servers节点对应。

url: 镜像的URL。通过该地址访问仓库

mirrorOf: 是镜像中仓库的id。

Proxy


   
     myproxy
     true
     http
     proxy.somewhere.com
     8080
     proxyuser
     somepassword
     *.google.com|ibiblio.org
   
 

id: proxy的唯一标识符

active: 该代理是否激活

protocol,host,port: 代理的协议、地址、端口

username,password: 用户名以及密码

nonProxyHosts:不需要被代理的地址列表

Profiles

profile元素是pom.xml profile的缩略版。若profile在settings中是激活的,它的值会在POM中被替代。

Activation

定义了profile被激活的条件


   
     test
     
       false
       1.5
       
         Windows XP
         Windows
         x86
         5.1.2600
       
       
         mavenVersion
         2.0.3
       
       
         ${basedir}/file2.properties
         ${basedir}/file1.properties
       
     
    ...
   
 

Properties

proerties是占位符,使用${}来获取。总共有5种形式

  • env.x 表示环境变量
  • project.x 表示project元素下的值
  • settings.x 表示settings中的配置
  • ${java.x} java系统变量
  • x 定义在下的属性

Repositories

定义仓库相关信息


       
         codehausSnapshots
         Codehaus Snapshots
         
           false
           always
           warn
         
         
           true
           never
           fail
         
         http://snapshots.maven.codehaus.org/maven2
         default
       
     
     
       
         myPluginRepo
         My Plugins repo
         
           true
         
         
           false
         
         https://maven-central-eu....com/maven2/
       
     

releases,snapshots分别表示不同的版本

checksumpolicy: 校验和策略 ignore fail warn

Active Profile

指定激活的profile


   env-test
 

与profile的id对应

发表评论
留言与评论(共有 0 条评论) “”
   
验证码:

相关文章

推荐文章