I am currently trying to migrate a Maven
project to Gradle
In my Maven
version I have the dependency versions all listed out like this in my parent pom:
<properties>
<spring.version>4.2.3.RELEASE</spring.version>
<spring.boot.version>1.3.3.RELEASE</spring.boot.version>
...
</properties>
And then I can define a dependency like this in any of my sub-modules:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
I am attempting to do the same thing on Gradle
, because some of my modules share dependency versions like this, and I wouldn't like to modify more then one place if I want to upgrade Spring or do a similar operation.
The closest I have gotten to it is this:
dependencies {
ext.springVersion = '4.2.3.RELEASE'
compile "org.springframework:spring-jdbc:$springVersion"
}
Yet that still doesn't work. What is the recommended way to achieve this in Gradle? Or does Gradle treat this differently? Perhaps my mind is still too much on Maven to see another solution.
Please keep in mind that that attempt on Gradle isn't exactly what I want yet. I would like to be able to define the dependencies in a separate file, not directly on the file that will use it.