Search code examples
gradleivy

Convert Ivy to Gradle - Dependency Syntax


I am trying to convert an Ivy project to a Gradle project and have a question about Ivy configurations. This dependency is in the ivy.xml of a project:

<dependencies defaultconf="default">
    <dependency org="org/apache" name="commons-lang" rev="2.6" conf="default,api->default" />
</dependencies>

From what I've read here, I beleive I can use "api" dependencies in the build.gradle, but is this Ivy syntax saying commons-lang is a dependency for both default and api configurations?

If yes, does that mean they need to be listed separately in Gradle? For example, and possible incorrect syntax:

compile group:"org/apache" name="commons-lang" version:"2.6"
api group:"org/apache" name="commons-lang" version:"2.6"

Solution

  • The answer to both your questions are "yes". It does mean that commons-lang is a dependency for both default and api configurations. Also, you are correct that you have to declare them separately in Gradle file.

    I had written a Groovy based Gradle file to convert Ivy xml to Gradle. Based on your question, I modified that to include multiple source config scenario. If you wish, it can be referred in my Github page