简体   繁体   English

NetBeans中的Apache Ivy解决导入问题

[英]Apache Ivy inside NetBeans to resolve imports

I would like to use Apache Ivy to resolve some dependencies(imports) inside my project in Java. 我想使用Apache Ivy在Java项目中解析某些依赖项(导入)。 I'm using NetBeans 7.1.2 (Java EE version). 我正在使用NetBeans 7.1.2(Java EE版本)。 I've installed IvyBeans plugin (version 1.2). 我已经安装了IvyBeans插件(1.2版)。 Then I built my project and Ivy has created IvyFiles and IvyLibraries folder inside my project folder (both of them are empty). 然后,我构建了项目,Ivy在项目文件夹中创建了IvyFiles和IvyLibraries文件夹(它们均为空)。 The problem is that no libraries are resolved. 问题是没有库被解析。 I obtain following message from builder: 我从构建器获得以下消息:

[PATH_TO_PROJECT]\nbproject\ivy-impl.xml:92: settings file does not exist: [PATH_TO_PROJECT]\${ivy.settings.location}

This is the ivy-resolve output : 这是ivy-resolve输出

Resolving COMPILE scope ...
:: loading settings :: url = jar:file:/C:/Users/jakub/.netbeans/7.1.2/modules/ext/ivy-2.1.0.jar!/org/apache/ivy/core/settings/ivysettings.xml
:: resolving dependencies :: IvyThriftApp#IvyThriftApp;1.0
    confs: [compile]
:: resolution report :: resolve 6ms :: artifacts dl 0ms
    ---------------------------------------------------------------------
    |                  |            modules            ||   artifacts   |
    |       conf       | number| search|dwnlded|evicted|| number|dwnlded|
    ---------------------------------------------------------------------
    |      compile     |   0   |   0   |   0   |   0   ||   0   |   0   |
    ---------------------------------------------------------------------
Resolving PROCESSOR scope ...
:: loading settings :: url = jar:file:/C:/Users/jakub/.netbeans/7.1.2/modules/ext/ivy-2.1.0.jar!/org/apache/ivy/core/settings/ivysettings.xml
:: resolving dependencies :: IvyThriftApp#IvyThriftApp;1.0
    confs: [compile]
:: resolution report :: resolve 3ms :: artifacts dl 0ms
    ---------------------------------------------------------------------
    |                  |            modules            ||   artifacts   |
    |       conf       | number| search|dwnlded|evicted|| number|dwnlded|
    ---------------------------------------------------------------------
    |      compile     |   0   |   0   |   0   |   0   ||   0   |   0   |
    ---------------------------------------------------------------------
Resolving RUNTIME scope ...
:: loading settings :: url = jar:file:/C:/Users/jakub/.netbeans/7.1.2/modules/ext/ivy-2.1.0.jar!/org/apache/ivy/core/settings/ivysettings.xml
:: resolving dependencies :: IvyThriftApp#IvyThriftApp;1.0
    confs: [compile, runtime]
:: resolution report :: resolve 3ms :: artifacts dl 0ms
    ---------------------------------------------------------------------
    |                  |            modules            ||   artifacts   |
    |       conf       | number| search|dwnlded|evicted|| number|dwnlded|
    ---------------------------------------------------------------------
    |      compile     |   0   |   0   |   0   |   0   ||   0   |   0   |
    |      runtime     |   0   |   0   |   0   |   0   ||   0   |   0   |
    ---------------------------------------------------------------------
Resolving COMPILE_TEST scope ...
:: loading settings :: url = jar:file:/C:/Users/jakub/.netbeans/7.1.2/modules/ext/ivy-2.1.0.jar!/org/apache/ivy/core/settings/ivysettings.xml
:: resolving dependencies :: IvyThriftApp#IvyThriftApp;1.0
    confs: [compile, compile-test]
:: resolution report :: resolve 4ms :: artifacts dl 0ms
    ---------------------------------------------------------------------
    |                  |            modules            ||   artifacts   |
    |       conf       | number| search|dwnlded|evicted|| number|dwnlded|
    ---------------------------------------------------------------------
    |      compile     |   0   |   0   |   0   |   0   ||   0   |   0   |
    |   compile-test   |   0   |   0   |   0   |   0   ||   0   |   0   |
    ---------------------------------------------------------------------
Resolving RUNTIME_TEST scope ...
:: loading settings :: url = jar:file:/C:/Users/jakub/.netbeans/7.1.2/modules/ext/ivy-2.1.0.jar!/org/apache/ivy/core/settings/ivysettings.xml
:: resolving dependencies :: IvyThriftApp#IvyThriftApp;1.0
    confs: [compile, compile-test, runtime, runtime-test]
:: resolution report :: resolve 4ms :: artifacts dl 0ms
    ---------------------------------------------------------------------
    |                  |            modules            ||   artifacts   |
    |       conf       | number| search|dwnlded|evicted|| number|dwnlded|
    ---------------------------------------------------------------------
    |      compile     |   0   |   0   |   0   |   0   ||   0   |   0   |
    |   compile-test   |   0   |   0   |   0   |   0   ||   0   |   0   |
    |      runtime     |   0   |   0   |   0   |   0   ||   0   |   0   |
    |   runtime-test   |   0   |   0   |   0   |   0   ||   0   |   0   |
    ---------------------------------------------------------------------

Is there some misunderstanding from my side of how Apache Ivy works under NetBeans or at all? 在我看来,Apache Ivy在NetBeans下的工作方式是否存在误解? My vision was that I use some dependencies inside my project - then I build it and Ivy automatically gets the dependencies from the Internet and I dont have to care about adding all external libraries into my project. 我的愿景是我在项目中使用一些依赖项-然后构建它,然后Ivy会自动从Internet获得依赖项,而不必担心将所有外部库添加到我的项目中。

Any suggestions how to resolve this problem ? 有什么建议可以解决这个问题吗?

Thank you very much for help or any recommendations :) 非常感谢您的帮助或任何建议:)

Looks like your ivy resolve is working fine. 看起来您的常春藤决心很好。 Within your build file how are using using the resolved jars to populate your ANT project's classpath? 在构建文件中,如何使用已解析的jar来填充ANT项目的类路径?

One popular option is to call the ivy retrieve task to populate a local lib directory: 一种流行的选择是调用常春藤检索任务以填充本地lib目录:

   <ivy:retrieve/>
   <path id="build.path">
      <fileset dir="lib" includes="**/*.jar"/>
   </path>

My preference and recommendation is to use ivy's cachepath task: 我的偏爱和建议是使用常春藤的cachepath任务:

   <ivy:cachepath pathid="build.path"/>

A more complete example (using ivy configurations) is given here: 这里给出了一个更完整的示例(使用常春藤配置):

Ant script to choose between multiple version of classpaths 在多个版本的类路径之间进行选择的Ant脚本

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM