Setting override on an Ivy dependency

I’m using a local Ivy repository to manage dependencies. In Eclipse we are using the IvyDE plugin so each project has an ivy.xml file. In ivy you can specify an ‘override’ element when declaring a dependency, for example if you wish to use a different version of a JAR than the one declared in the list of dependencies in Ivy.

Here’s an example ivy.xml file. I can see examples in the documentation on excluding dependencies, but how can I specify the override’s in Gradle? If there is not a Gradle way to do this, would it be easier to import my ivy.xml files and use them?

<?xml version="1.0" encoding="ISO-8859-1"?>
   Licensed to the Apache Software Foundation (ASF) under one
   or more contributor license agreements.
See the NOTICE file
   distributed with this work for additional information
   regarding copyright ownership.
The ASF licenses this file
   to you under the Apache License, Version 2.0 (the
   "License"); you may not use this file except in compliance
   with the License.
You may obtain a copy of the License at
     Unless required by applicable law or agreed to in writing,
   software distributed under the License is distributed on an
   KIND, either express or implied.
See the License for the
   specific language governing permissions and limitations
   under the License.
<ivy-module version="2.0" xmlns:xsi=""
          <info organisation="ois" module="uwm" status="integration"/>
  <conf name="default" visibility="public" description="...." extends="runtime"/>
  <conf name="compile" visibility="public" description="...." />
  <conf name="runtime" visibility="public" description="...." extends="compile"/>
            <dependency org="org.mockito" name="mockito-all" rev="1.8.2" />
c3po is an optional dependancy on hibernate, but getting separately to avoid getting a load
     of other JAR's which are optional dependencies which we don't need -->
           <dependency org="jboss" name="jboss-archive-browsing" rev="2.0.2.alpha" />
  <dependency org="cglib" name="cglib-nodep" rev="2.1_3" />
                           <!-- Should pull in dependencies on hibernate, hibernate-annotations,
     hibernate-commons-annotations & hibernate-validator -->
     <dependency org="org.hibernate" name="hibernate-entitymanager" rev="" conf="default->compile, master(*)">
   <!-- we don't use persistence-api -->
      <exclude org="javax.persistence" module="persistence-api"/>
           <!-- we don't use jboss-common-core, we are using jboss-archive-browsing instead - the JARs seem similar (with a few differences)
         a dependancy on jboss-archive-browsing has been declared separately -->
   <exclude org="jboss" module="jboss-common-core"/>
             <!-- version conflict - we have a different version of jta.jar (although not sure what version we have
         out version appears to have an extra interface (i've decompiled and compared) -->
    <exclude org="javax.transaction" module="jta"/>
Hibernate has a dependancy on cglib, but Spring has a dependancy on cglib-nodep
      out project has always used the cglib-nodep version (don't know why) so I'm excluding the
       cglib version -->
   <exclude org="cglib" module="cglib"/>
                     <dependency org="junit" name="junit" rev="4.9" conf="default->master"/>
        <dependency org="com.healthmarketscience.rmiio" name="rmiio" rev="2.0.2" conf="default->master"/>
                           <dependency org="log4j" name="log4j" rev="1.2.16" conf="default"/>
     <!-- don't get the optional dependencies for acegi-security, version 1.0.6 has
        dependencies on an old version of Spring (1.2.9).
The 'master' configuration of
        acegi-security should just get the acegi-security jar -->
  <dependency org="org.acegisecurity" name="acegi-security" rev="1.0.6" conf="default->master"/>
      <dependency org="org.apache.lucene" name="lucene-core" rev="3.4.0" />
      <dependency org="c3p0" name="c3p0" rev="" />
  <dependency org="ois" name="serverUtils" rev="1.0" conf="default"/>
        <!-- some of the Hibernate dependencies are on older versions of JAR's than we are currently using, so
        overriding here - this means any transitive dependencies will be forced to use our overriden versions -->
     <override org="jboss" module="javassist" rev=""/>
    <override org="net.sf.ehcache" module="ehcache" rev="1.6.0-beta2"/>
  <override org="commons-logging" module="commons-logging" rev="1.1.1"/>
      <override org="commons-collections" module="commons-collections" rev="3.2"/>
  <!-- hibernate-entitymanager has a dependancy on an older verison of hibenernate - overriding to our version -->
  <override org="org.hibernate" module="hibernate" rev=""/>

I think the closest you can come right now is:

dependencies {

compile(“”) { force = true } }

One drawback of this approach is that it introduces a direct dependency on the library (javassist in this case). As far as I know, a better solution is in the works right now.

We don’t support importing Ivy files at this time, but might support it in the future.

Thanks that seems to do the equivalent of the ivy override.

It would be good to use ivy.xml files from Gradle to save maintaining depenencies in two places. Is there any chance GRADLE-197 will be part of the 1.0 release? I’ve seen it mentioned in several theads in the gradle-user mail list.

The preferred Gradle way would be to manage dependencies in Gradle, but I agree that importing ivy.xml can make sense as well. However, this is unlikely to make it into 1.0.