Search code examples
javaantivy

How to fix Evicted Modules issue in Apache Ivy


I'm trying to integrate Apache Ivy with an existing Java EE project which uses Apache Ant. I created ivy.xml, ivysettings.xml(to add an non-existent repo in mvnrepo) and made changes to the existing build.xml.

I got the following when I ran the 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   |
    ---------------------------------------------------------------------

How can I fix this issue? These modules are not directly mentioned in the ivy.xml. This is my first experiment with Ivy and any help would be highly appreciated.

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>

ivy.xml

<?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>

Solution

  • If you add the line <conflict manager="all"/> before closing the dependencies tag you won't have any evicted modules. Like so

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

    Quoting from here for the built-in conflict manager all:

    this conflicts manager resolve conflicts by selecting all revisions. Also called the NoConflictManager, it doesn't evict any modules.

    I had to put the conflict at the end, otherwise it won't work. Seems like a bug in ivy.

    Just be sure that this is what you want. Quoting from here:

    There are two things optimized during conflict resolution: download of artifacts and download of ivy files. The first is always ensured by ivy, i.e. artifacts of a module evicted will never be downloaded. The second is not as simple to handle because to know what are the conflicts ivy needs to know the dependency graph, and to know the dependency graph, it has to download ivy files. But ivy is highly optimized on this too, and it tries to evict modules as soon as possible. That's why the order of dependencies is important for download optimization. Indeed ivy traverses the dependency graph in the order in which dependencies are declared in the ivy files, and each time it encounters a dependency on a module, it first check if there is a conflict on this module, and if this is the case, it asks the conflict manager to resolve the conflict. Then if the module is evicted, it does not download its ivy file, and the whole branch is not traversed, which can saves a lot of time.