如何修复Apache Ivy中的驱逐模块问题



我正在尝试将Apache Ivy与使用Apache Ant的现有Java EE项目集成。我创建了ivy.xml, ivysettings.xml(在mvnrepo中添加一个不存在的repo),并对现有的build.xml进行了更改。

当我运行Ivy Resolve时,我得到了以下结果:

[ivy:resolve] :: resolution report :: resolve 2642ms :: artifacts dl 49ms
[ivy:resolve]   :: evicted modules:
[ivy:resolve]   xml-apis#xml-apis;1.0.b2 by [xml-apis#xml-apis;1.3.04] in [default]
[ivy:resolve]   commons-logging#commons-logging;1.1.1 by [commons-logging#commons-logging;1.2] in [default]
[ivy:resolve]   commons-codec#commons-codec;1.6 by [commons-codec#commons-codec;1.8] in [default]
[ivy:resolve]   commons-logging#commons-logging;1.1.3 by [commons-logging#commons-logging;1.2] in [default]
[ivy:resolve]   org.slf4j#slf4j-api;1.6.1 by [org.slf4j#slf4j-api;1.7.7] in [default]
[ivy:resolve]   xml-apis#xml-apis;1.3.04 by [xml-apis#xml-apis;1.4.01] in [default]
    ---------------------------------------------------------------------
    |                  |            modules            ||   artifacts   |
    |       conf       | number| search|dwnlded|evicted|| number|dwnlded|
    ---------------------------------------------------------------------
    |      default     |  108  |   0   |   0   |   6   ||  102  |   0   |
    ---------------------------------------------------------------------

如何解决这个问题?xml中没有直接提到这些模块。这是我第一次用Ivy做实验,任何帮助都将是非常感谢的。

ivysettings.xml

<ivysettings>
    <settings defaultResolver="central"/>
    <resolvers>
        <ibiblio name="central" m2compatible="true"/>
        <ibiblio name="primefaces-themes-old" m2compatible="true" root="http://repository.primefaces.org"/>
    </resolvers>
    <modules>
        <module organisation="org.primefaces.themes" resolver="primefaces-themes-old"/>
    </modules>
</ivysettings>

<?xml version="1.0" encoding="ISO-8859-1"?>
<ivy-module version="2.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd">
    <info organisation="Fetching Life" module="WebApp" status="integration">
    </info>
    <dependencies>
        <dependency org="commons-collections" name="commons-collections" rev="3.2.2" conf="default"/>
        <dependency org="mysql" name="mysql-connector-java" rev="5.1.40" conf="default"/>
        <dependency org="com.googlecode.flyway" name="flyway-core" rev="2.3.1" conf="default"/>
        <dependency org="com.googlecode.flyway" name="flyway-ant" rev="2.3.1" conf="default"/>
        <dependency org="org.hibernate" name="hibernate-core" rev="5.0.11.Final" conf="default"/>
        <dependency org="org.springframework" name="spring-core" rev="4.2.8.RELEASE" conf="default"/>
        <dependency org="org.springframework" name="spring-web" rev="4.2.8.RELEASE" conf="default"/>
        <dependency org="org.springframework" name="spring-orm" rev="4.2.8.RELEASE" conf="default"/>
        <dependency org="org.springframework" name="spring-context" rev="4.2.8.RELEASE" conf="default"/>
        <dependency org="org.springframework" name="spring-context-support" rev="4.2.8.RELEASE" conf="default"/>
        <dependency org="org.springframework" name="spring-test" rev="4.2.8.RELEASE" conf="default"/>
        <dependency org="org.springframework" name="spring-oxm" rev="4.2.8.RELEASE" conf="default"/>
        <dependency org="org.springframework" name="spring-webmvc" rev="4.2.8.RELEASE" conf="default"/>
        <dependency org="org.springframework" name="spring-webmvc-portlet" rev="4.2.8.RELEASE" conf="default"/>
        <dependency org="org.springframework" name="spring-aspects" rev="4.2.8.RELEASE" conf="default"/>
        <dependency org="org.primefaces" name="primefaces" rev="5.1" conf="default"/>
        <dependency org="com.sun.faces" name="jsf-api" rev="2.1.29" conf="default"/>
        <dependency org="com.sun.faces" name="jsf-impl" rev="2.1.29" conf="default"/>
        <dependency org="joda-time" name="joda-time" rev="2.8.2" conf="default"/>
        <dependency org="org.apache.shiro" name="shiro-all" rev="1.2.6" conf="default"/>
        <dependency org="com.google.apis" name="google-api-services-calendar" rev="v3-rev179-1.19.1" conf="default"/>
        <dependency org="com.google.code.gson" name="gson" rev="2.3.1" conf="default"/>
        <dependency org="org.mnode.ical4j" name="ical4j" rev="1.0.7" conf="default"/>
        <dependency org="net.sourceforge.jexcelapi" name="jxl" rev="2.6.12" conf="default"/>
        <dependency org="javax.el" name="javax.el-api" rev="2.2.5" conf="default"/>
        <dependency org="com.ocpsoft" name="prettyfaces-jsf2" rev="3.3.3" conf="default"/>
        <dependency org="org.mindrot" name="jbcrypt" rev="0.3m" conf="default"/>
        <dependency org="javax.jdo" name="jdo-api" rev="3.0.1" conf="default"/>
        <dependency org="org.quartz-scheduler" name="quartz" rev="2.2.3" conf="default"/>
        <dependency org="org.omnifaces" name="omnifaces" rev="1.6.3" conf="default"/>
        <dependency org="javax.servlet.jsp.jstl" name="jstl-api" rev="1.2" conf="default"/>
        <dependency org="antlr" name="antlr" rev="2.7.7" conf="default"/>
        <dependency org="org.apache.james" name="apache-mime4j" rev="0.6.1" conf="default"/>
        <dependency org="org.atmosphere" name="atmosphere-runtime" rev="2.2.9" conf="default"/>
        <dependency org="bsh" name="bsh" rev="1.3.0" conf="default"/>
        <dependency org="junit" name="junit" rev="4.12" conf="default"/>
        <dependency org="org.mockito" name="mockito-all" rev="1.10.19" conf="default"/>
        <dependency org="commons-fileupload" name="commons-fileupload" rev="1.2.2" conf="default"/>
        <dependency org="org.apache.commons" name="commons-exec" rev="1.3" conf="default"/>
        <dependency org="commons-io" name="commons-io" rev="2.4" conf="default"/>
        <dependency org="commons-jxpath" name="commons-jxpath" rev="1.3" conf="default"/>
        <dependency org="net.sf.ehcache" name="ehcache" rev="2.10.0" conf="default"/>
        <dependency org="org.glassfish.web" name="el-impl" rev="2.2" conf="default"/>
        <dependency org="net.sf.jsr107cache" name="jsr107cache" rev="1.1" conf="default"/>
        <dependency org="javax.mail" name="mail" rev="1.4.7" conf="default"/>
        <dependency org="io.netty" name="netty" rev="3.5.13.Final" conf="default"/>
        <dependency org="org.objenesis" name="objenesis" rev="2.1" conf="default"/>
        <dependency org="com.google.protobuf" name="protobuf-java" rev="2.4.1" conf="default"/>
        <dependency org="xalan" name="serializer" rev="2.7.2" conf="default"/>
        <dependency org="xalan" name="xalan" rev="2.7.2" conf="default"/>
        <dependency org="xerces" name="xercesImpl" rev="2.11.0" conf="default"/>
        <dependency org="org.primefaces.themes" name="casablanca" rev="1.0.10" conf="default"/>
        <dependency org="net.sourceforge.cssparser" name="cssparser" rev="0.9.20" conf="default"/>
        <dependency org="dom4j" name="dom4j" rev="1.6.1" conf="default"/>
        <dependency org="org.ini4j" name="ini4j" rev="0.5.4" conf="default"/>
        <dependency org="org.eclipse.jetty" name="jetty-websocket" rev="8.1.22.v20160922" conf="default"/>
        <dependency org="org.w3c.css" name="sac" rev="1.3" conf="default"/>
    </dependencies>
</ivy-module>

build . xml

<project name="SampleApp" default="usage" basedir="." xmlns:flyway="antlib:com.googlecode.flyway.ant" xmlns:ivy="antlib:org.apache.ivy.ant">
<property name="lib.dir" value="${basedir}/${web.dir}/WEB-INF/lib/"></property>
<target name="resolve" description="resolve dependencies with ivy">
        <ivy:resolve conf="default"/>
    </target>
    <target name="cleancache" description="Purge ivy cache">
        <ivy:cleancache/>
    </target>
    <target name="dependencytree" depends="resolve" description="Show dependency tree">
        <ivy:dependencytree />
    </target>
    <target name="retrieve" depends="resolve" description="Resolve and Retrieve with ivy">
        <ivy:retrieve conf="default" sync="true" type="jar,bundle" pattern="${lib.dir}[artifact]-[revision].[ext]"/>
        <!-- <ivy:cachepath pathid="default.classpath" /> -->
    </target>
</project>

如果您在关闭依赖项标记之前添加<conflict manager="all"/>行,则不会有任何驱逐模块。就像

    <conflict manager="all"/>
</dependencies>

从这里引用内置冲突管理器all:

这个冲突管理器通过选择所有的修订来解决冲突。

我必须把conflict放在最后,否则它将不起作用。就像爬山虎里的虫子。

只要确定这是你想要的。引用自这里:

在冲突解决过程中有两件事是优化的:下载工件和ivy文件的下载。第一个总是由Ivy,即被驱逐模块的工件将永远不会被下载。的其次是不那么简单的处理,因为要知道是什么冲突ivy需要知道依赖关系图,并且要知道依赖图,需要下载ivy文件。但是常春藤在此基础上也进行了优化,并尝试尽快退出模块可能的。这就是为什么依赖关系的顺序很重要下载的优化。实际上,ivy遍历依赖关系图在ivy文件中声明依赖项的顺序,以及每次遇到对模块的依赖时,它首先检查是否存在在这个模块上存在冲突,如果是这种情况,它会询问冲突管理器解决冲突。如果模块是被驱逐后,它不下载它的ivy文件,整个分支都下载无需遍历,可以节省大量时间。

只是为了添加一些东西。

冲突部分工作得很好。

<conflict manager="all"/>

无论如何,要找到关于它的信息并不容易,知道它的使用可以限制在单个依赖项中或者使用通配符来选择其中的一个子集可能是有用的。在我的例子中,我是这样使用它的:

<conflict manager="all" module="module_1" org="org_1"/>

此外,还可以选择使用不同的管理器选择不同的策略,更多信息请访问:http://ant.apache.org/ivy/history/2.0.0/settings/conflict-managers.html

相关内容

  • 没有找到相关文章