【问题标题】:Apache IVY Unable to resolve dependencies for MAVEN ProjectsApache IVY 无法解析 MAVEN 项目的依赖关系
【发布时间】:2015-09-01 11:58:00
【问题描述】:

我有一个 Apache Ivy(版本 2.4.0)和 Netbeans IDE(8.0.2)的设置。我无法解决成熟 maven 项目的依赖关系(例如:org.glassfish.jersey)。 Apache Ivy 成功解决了更多特定模块的依赖关系,例如 (org.glassfish.jersey.core)。

无效示例:

<dependency org="org.glassfish.jersey" name="project" rev="2.13" conf="solrj->*"/>

工作示例:

<dependency org="org.apache.solr" name="solr-solrj" rev="5.0.0" conf="solrj->default"/>
<dependency org="org.glassfish.jersey.core" name="jersey-server" rev="2.13" conf="JerseyCore-2.13->default,optional"/>
<dependency org="org.glassfish.jersey.core" name="jersey-client" rev="2.13" conf="JerseyCore-2.13->default,optional"/>
<dependency org="org.glassfish.jersey.core" name="jersey-common" rev="2.13" conf="JerseyCore-2.13->default,optional"/>

ivy.xml

<ivy-module version="2.0">
<info organisation="org.sonatype.nexus.examples" module="simple-project" revision="1.0.0-SNAPSHOT"/>

<configurations>
    <conf name="solrj" description="Jars from the SOLRJ Library Collection"/>        
</configurations>

<dependencies>
    <dependency org="org.glassfish.jersey" name="project" rev="2.13" conf="solrj->*"/>

    <dependency org="org.apache.solr" name="solr-solrj" rev="5.0.0" conf="solrj->default"/>
</dependencies>

ivysettings.xml

<ivysettings>
<settings defaultResolver="ibiblio"/>
<resolvers>     
    <ibiblio name="ibiblio" m2compatible="true"/>
</resolvers>

build.xml(只是 IVY 部分)。

<!-- Resolve all the dependencies that we declared in the build.xml file.
Resolving means that ivy will download the jar file from the MAVEN 2 Repository
and put them under the directory that you specify in the build.xml file.
In my case this is where all the jar files will be downloaded "C:\Users\ajalgaon\Accurev\solrj\lib" -->
<target name="init">  
    <ivy:settings file="ivysettings.xml" />
    <ivy:resolve/>
    <ivy:report todir="prebuilt/ivy-report" graph="false"/>
    <ivy:retrieve conf="solrj" pattern="prebuilt/jars/solrj-lib/[artifact].[ext]"/>

</target>

Apache IVY 成功解决了 solr-solrj 模块的依赖关系。但它不能解决“org.glassfish.jersey”的依赖关系。 Apache IVY 不解析 ivy.xml 文件中具有属性 name="project" 的任何内容的依赖关系。如果我需要在这里发布更多信息,请告诉我。提前非常感谢。

【问题讨论】:

    标签: netbeans build maven-2 ivy nexus


    【解决方案1】:

    无法重现您的问题。

    示例

    ├── build.xml
    ├── ivy.xml
    └── target
        ├── ivy-reports
        │   ├── ivy-report.css
        │   └── org.sonatype.nexus.examples-simple-project-solrj.html
        └── jars
            ├── commons-io.jar
            ├── httpclient.jar
            ├── httpcore.jar
            ├── httpmime.jar
            ├── noggit.jar
            ├── slf4j-api.jar
            ├── solr-solrj.jar
            ├── stax2-api.jar
            ├── woodstox-core-asl.jar
            └── zookeeper.jar
    

    ivy.xml

    <ivy-module version="2.0">
      <info organisation="org.sonatype.nexus.examples" module="simple-project" revision="1.0.0-SNAPSHOT"/>
    
      <configurations>
        <conf name="solrj" description="Jars from the SOLRJ Library Collection"/>        
      </configurations>
    
      <dependencies>
        <dependency org="org.glassfish.jersey" name="project" rev="2.13" conf="solrj->*"/>
    
        <dependency org="org.apache.solr" name="solr-solrj" rev="5.0.0" conf="solrj->default"/>
      </dependencies>
    
    </ivy-module>
    

    build.xml

    <project name="demo" default="resolve" xmlns:ivy="antlib:org.apache.ivy.ant">
    
        <property name="build.dir" location="target"/>
    
        <available classname="org.apache.ivy.Main" property="ivy.installed"/> 
    
        <target name="resolve" depends="install-ivy" description="Use ivy to resolve classpaths">
            <ivy:resolve/>
    
            <ivy:report todir='${build.dir}/ivy-reports' graph='false' xml='false'/>
    
            <ivy:retrieve conf="solrj" pattern="${build.dir}/jars/[artifact].[ext]"/>
        </target>
    
        <target name="install-ivy" description="Install ivy" unless="ivy.installed">
            <mkdir dir="${user.home}/.ant/lib"/>
            <get dest="${user.home}/.ant/lib/ivy.jar" src="http://search.maven.org/remotecontent?filepath=org/apache/ivy/ivy/2.4.0/ivy-2.4.0.jar"/>
            <fail message="Ivy has been installed. Run the build again"/>
        </target>
    
        <target name="clean" description="Cleanup build files">
            <delete dir="${build.dir}"/>
        </target>
    
        <target name="clean-all" depends="clean" description="Additionally purge ivy cache">
            <ivy:cleancache/>
        </target>
    
    </project>
    

    【讨论】:

    • 您好,谢谢您的回复。看起来您能够解决 solrj 库的依赖关系。这也适用于我。但后来我无法解决 org.glassfish.jersey 模块的依赖关系。这是预期的行为吗?我希望 Apache IVY 能够基于其 POM 解决“org.glassfish.jersey”的所有依赖关系。我注意到的另一件事是“search.maven.org/#search%7Cga%7C1%7Corg.glassfish.jersey”只允许我下载“org.glassfish.jersey”的 POM。这是否与我面临的问题有关?
    • 是的,这就是你的问题。查看 POM 文件的详细信息:search.maven.org/… 它没有依赖关系,这解释了为什么没有下载文件。我怀疑它被设计为由子构建导入,而不是用于实际构建工件。这是 Maven 的事情,不要出汗。所以...声明您对具有实际工件的 Maven 模块的依赖可能是故事的寓意。希望这会有所帮助。
    • 听起来不错。这和我预料的一样。非常感谢您的回复。欣赏!!!
    猜你喜欢
    • 2020-09-09
    • 2022-01-23
    • 2017-03-16
    • 2015-06-04
    • 2021-04-03
    • 2015-01-14
    • 2014-09-05
    • 2021-08-24
    • 1970-01-01
    相关资源
    最近更新 更多