---
title: "ivy中文参考文档(16)-ant任务(4)-configure"
author: "skydream"
date: "2009-08-04T21:29:00Z"
tags: []
slug: "ivy-16-ant-4-configure"
draft: false
lastmod: "2009-09-02T21:25:35Z"
id: 453155
url: "https://skydream.iteye.com/blog/453155"
---

1\) configure

    configure任务用于通过xml设置文件来配置ivy。

    查阅设置文件来获取设置文件自身的细节。

    从2.0起 可以通过sttings声明来配置ivy。和这个任务的不同之处在于当使用settings声明时，ivy的配置在settings第一次需要时(例如当你做一次resolve)完成，而configure任务立即执行一次配置，这样如果有某些错误发生可以容易看到。

2\) 属性

属性 描述 必要  
settingsId The settings id useable in the settingsRef attributes of the ivy task that needs a setting. Note that the ivy tasks will search by default for the settings with the id "ivy.instance", which is the default value.  
settings id 用于需要设置的ivy任务的 settingsRef属性中。注意ivy任务会默认搜索id为"ivy.instance"的设置，这个是默认值 No, 默认为 "ivy.instance" file path to the settings file to use  
要使用的设置文件的路径  
No. 如果提供文件，则URL被忽略。如果都没有提供，则试图查找${ivy.settings.file}文件，而如果这个文件也没有，则使用[default默认设置文件](http://ant.apache.org/ivy/history/latest-milestone/samples/ivysettings-default.xml) url url of the settings file to use  
要使用的设置文件的URL  
override Specify what to do when another settings with the same id has already been loaded.  
指示当已经装载一个同样id的另一个设置时该怎么做

- true 当前设置将优先覆盖任何之前定义的使用这个id的设置
- false 当前设置将不覆盖之前定义的使用这个id的设置
- notallowed 如果已经有使用这个id的设置被定义，则报告错误

No, 默认为 "notallowed" host http authentication host No, 除非需要http认证。  
realm http authentication realm username http authentication user name passwd http authentication password

3\) HTTP 认证

    注意：HTTP认证只有当你的classpath下有commons-httpclient.jar时才能使用。如果任何你在ivy中使用的url(尤其在依赖解析时)需要http证，则你必须提供configure任务的host,realm,username和passwd属性。这些设置将在后面调用ivy任务使用。

4\) 示例

    1. 最简单的设置

&lt; ivy:configure  /&gt;

或者使用${ivy.settings.file}如果它存在，或者使用默认设置文件。

    2. 使用文件来配置

&lt;!--&lt;br /&gt; &lt;br /&gt; Code highlighting produced by Actipro CodeHighlighter (freeware)&lt;br /&gt; http://www.CodeHighlighter.com/&lt;br /&gt; &lt;br /&gt; --&gt;&lt; ivy:configure  file ="myconffile.xml"   /&gt;

    3. 使用url来配置

&lt; ivy:configure  url ="http://mysite.com/myconffile.xml"   /&gt;

    4. 配置多个需要认证的URL

&lt; ivy:configure  file ="path/to/my/ivysettings.xml" &gt;  
   &lt; credentials  host ="myhost.com"  realm ="My Realm"  username ="myuser"  passwd ="mypasswd"   /&gt;  
   &lt; credentials  host ="yourhost.com"  realm ="Your Realm"  username ="myuser"  passwd ="myotherpasswd"   /&gt;  
&lt;/ ivy:configure &gt;