Ekans
Ekans

Reputation: 1067

Ivy : dependency between 2 dependencies

I am looking for a way to declare "a dependency between 2 dependencies".

For instance, in my module, I have in ivy.xml the following lines :

<dependencies>
    <dependency org="org.slf4j" name="slf4j-api" rev="${slf4japiversion}"/>
    <dependency org="ch.qos.logback" name="logback-classic" rev="1.0.13" conf="test->default"/>
</dependencies>

My problem is that logback-classic 1.0.13 depends on slf4j-api 1.7.5 and my module depends on 1.6.6 (value of slf4japiversion).

I can't change slf4japiversion but in the future it could be upgraded by someone else.

Is there a way to declare the dependency on logback to retrieve the version compatible with my slf4j-api version ?

Upvotes: 0

Views: 199

Answers (1)

Mark O&#39;Connor
Mark O&#39;Connor

Reputation: 78021

You can specify an override directive to force resolution to a particular version of a dependency:

   <dependencies>
      <dependency org="org.slf4j" name="slf4j-api" rev="1.6.6" conf="compile->default"/>
      <dependency org="ch.qos.logback" name="logback-classic" rev="1.0.13" conf="runtime->default"/>

      <override org="org.slf4j" module="slf4j-api" rev="1.6.6"/>
   </dependencies>

A word of warning, when downgrading dependencies. If logback uses a feature only supported by version 1.7.5 then the solution will not work. It's far more likely a library is backwardly compatible.

Upvotes: 1

Related Questions