cleankod
(Cleankod)
January 20, 2016, 12:26pm
1
How to convert the below Ivy dependencies into the Gradle ones?
<dependency org="joda" name="joda-time" rev="2.1" conf="build,webapp,test,spock->default" />
<dependency org="hibernate" name="hibernate" rev="3.2.6" conf="*->default,standalone;test,webapp->deserialization" />
ethankhall
(Ethan Hall)
January 20, 2016, 10:05pm
2
I can never parse the Ivy file’s configurations but if you want to depend on a specific configuration of a library you can use the following (assuming you want to depend on build)
dependencies {
compile group: 'org.hibernate', name: 'hibernate-core', version: '3.6.7.Final', configuration: 'build'
}
If you want to add a dependency to a specific configuration
//define foo configuration
configurations {
foo
}
dependencies {
foo group: 'org.hibernate', name: 'hibernate-core', version: '3.6.7.Final', configuration: 'build'
}
If you want some more help with this you can check out https://docs.gradle.org/current/userguide/artifact_dependencies_tutorial.html
cleankod
(Cleankod)
January 21, 2016, 6:31am
3
Yes, that I know so far. But the question really was - how to add a dependency in its multiple configurations?
ethankhall
(Ethan Hall)
January 22, 2016, 4:09pm
4
I think you would need to add multiple dependency declarations for each one. You could do something like
dependencies {
['build', 'webapp', 'test' , 'spock'].each { conf ->
compile group: 'joda', name: 'joda-time', version: '2.1', configuration: conf
}
If you want to make it easy to add / remove a configuration
2 Likes
RJR2
(Ricardo Amador)
November 28, 2017, 11:33pm
5
Ethan, thanks for this! You save me a ton of time. Worked like a charm!