We want to share dependency versions across projects and repositories because we have two teams and one shared repository.
I created a dependencies.gradle file where I define a map of versions for the project, I got this from stackoverflow: http://stackoverflow.com/a/9547593/2166900. This works within the root project and its subprojects, but I also want to use this file in other projects. I need to be able to package this file and publish it to artifactory.
dependencies.gradle:
ext.libraries = [
spring_core: "org.springframework:spring-core:3.1",
junit: "junit:junit:4.10"
]
I tried to create a plugin that I can publish to Artifactory that wraps this file and applies it to the project.
Unfortunately I can’t find the right syntax to apply the file.
class DependencyPlugin implements Plugin<Project> {
void apply(Project project) {
project.apply(getClass().getResource("/dependencies.groovy").toURI().toURL());
}
}
Applying this plugin results in:
Could not find method apply() for arguments [jar:file:/C:/Users/.../.m2/repository/....jar!/dependencies.groovy] on root project 'company-parent'
I also looked at the Groovy ConfigSlurper, but I don’t know how to apply these properties as Gradle ExtraProperties.
Can someone help me with my plugin or learn me a better way to do this?