开发学院软件开发Java ivy教程(2)-快速开始 阅读

ivy教程(2)-快速开始

 2009-10-08 00:00:00 来源:WEB开发网   
核心提示: 如你所见,调用ivy来解析和获取依赖是非常简单的:如果ivy安装正确,ivy教程(2)-快速开始(3),你所需要做的只是在你的ant文件中定义一个xml的命名空间 (xmlns:ivy="antlib:org.apache.ivy.ant"),然后在这里命名空间中所有的ivy

如你所见,调用ivy来解析和获取依赖是非常简单的:如果ivy安装正确,你所需要做的只是在你的ant文件中定义一个xml的命名空间 (xmlns:ivy="antlib:org.apache.ivy.ant")。然后在这里命名空间中所有的ivy ant 任务都可用。

这里我们只使用了一个任务:retrieve 任务。没有任何属性,它将使用默认设置并查找名为ivy.xml的文件来获取依赖定义。这正是我们想要的,因此我们不需要做其他。

注意,在这案例中我们定义了一个"resolve" target 并调用了retrieve 任务。这听起来有点令人困惑,实际上retrieve任务会执行一次resolve(解析依赖并下载他们到本地缓存),然后再执行一次retrieve。查看How does it work ? 页面来得到关于这个的更多细节。

3) 运行项目

好,现在我们看到文件已经解析好了,让我们运行这个实例来看会发生什么。打开一个shell(或者命令行)窗口,并进入hello-ivy 实例目录。然后,在命令提示符下,运行"ant":

I:\hello-ivy>ant
Buildfile: src\example\hello-ivy\build.xml
resolve:
[ivy:retrieve] :: Ivy 2.0.0-beta1-local-20071104204849 - 20071104204849 :: http://ant.apache.org/ivy/ ::
[ivy:retrieve] No ivy:settings found for the default reference 'ivy.instance'.  A default instance will be used
[ivy:retrieve] no settings file found, using default....
[ivy:retrieve] :: loading settings :: url = jar:file:/c:/dev/data/opensource_workspace/ivy/build/artifact/ivy-core.jar!/org/apache/ivy/core/settings/ivysettings.xml
[ivy:retrieve] :: resolving dependencies :: [ org.apache | hello-ivy | working@BEN-ScokartG ]
[ivy:retrieve]     confs: [default]
[ivy:retrieve]     found [ commons-lang | commons-lang | 2.0 ] in public
[ivy:retrieve]     found [ commons-cli | commons-cli | 1.0 ] in public
[ivy:retrieve]     found [ commons-logging | commons-logging | 1.0 ] in public
[ivy:retrieve] downloading http://repo1.maven.org/maven2/commons-lang/commons-lang/2.0/commons-lang-2.0.jar ....
[ivy:retrieve] ........................................................................
[ivy:retrieve] ................................................ (165kB)
[ivy:retrieve] .. (0kB)
[ivy:retrieve]     [SUCCESSFUL ] [ commons-lang | commons-lang | 2.0 ]/commons-lang.jar[jar] (3335ms)
[ivy:retrieve] downloading http://repo1.maven.org/maven2/commons-cli/commons-cli/1.0/commons-cli-1.0.jar ....
[ivy:retrieve] .................................... (29kB)
[ivy:retrieve] .. (0kB)
[ivy:retrieve]     [SUCCESSFUL ] [ commons-cli | commons-cli | 1.0 ]/commons-cli.jar[jar] (2053ms)
[ivy:retrieve] downloading http://repo1.maven.org/maven2/commons-logging/commons-logging/1.0/commons-logging-1.0.jar ....
[ivy:retrieve] .......... (21kB)
[ivy:retrieve] .. (0kB)
[ivy:retrieve]     [SUCCESSFUL ] [ commons-logging | commons-logging | 1.0 ]/commons-logging.jar[jar] (1933ms)
[ivy:retrieve] :: resolution report ::
[ivy:retrieve]     :: evicted modules:
[ivy:retrieve]     [ commons-lang | commons-lang | 1.0 ] by [[ commons-lang | commons-lang | 2.0 ]] in [default]
    ---------------------------------------------------------------------
    |                  |            modules            ||   artifacts   |
    |       conf       | number| search|dwnlded|evicted|| number|dwnlded|
    ---------------------------------------------------------------------
    |      default     |   4   |   3   |   0   |   1   ||   3   |   3   |
    ---------------------------------------------------------------------
[ivy:retrieve] :: retrieving :: [ org.apache | hello-ivy ]
[ivy:retrieve]     confs: [default]
[ivy:retrieve]     3 artifacts copied, 0 already retrieved
run:
     [java] standard message : hello ivy !
     [java] capitalized by org.apache.commons.lang.WordUtils : Hello Ivy !
BUILD SUCCESSFUL
Total time: 14 seconds

上一页  1 2 3 4  下一页

Tags:ivy 教程 快速

编辑录入:爽爽 [复制链接] [打 印]
[]
  • 好
  • 好的评价 如果觉得好,就请您
      0%(0)
  • 差
  • 差的评价 如果觉得差,就请您
      0%(0)
赞助商链接