title: How do I define a variable for the dependency version in Gradle
body: <p>I am currently trying to migrate a <code>Maven</code> project to <code>Gradle</code></p>
  
  <p>In my <code>Maven</code> version I have the dependency versions all listed out like this in my <strong>parent</strong> pom:</p>
  
  <pre><code>&lt;properties&gt;
      &lt;spring.version&gt;4.2.3.RELEASE&lt;/spring.version&gt;
      &lt;spring.boot.version&gt;1.3.3.RELEASE&lt;/spring.boot.version&gt;
      ...
  &lt;/properties&gt;
  </code></pre>
  
  <p>And then I can define a dependency like this in any of my sub-modules:</p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;org.springframework&lt;/groupId&gt;
      &lt;artifactId&gt;spring-jdbc&lt;/artifactId&gt;
      &lt;version&gt;${spring.version}&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>I am attempting to do the same thing on <code>Gradle</code>, 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.</p>
  
  <p>The closest  I have gotten to it is this:</p>
  
  <pre><code>dependencies {
      ext.springVersion = '4.2.3.RELEASE'
      compile "org.springframework:spring-jdbc:$springVersion"
  }
  </code></pre>
  
  <p>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.</p>
  
  <p>Please keep in mind that that attempt on Gradle isn't <em>exactly</em>  what I want yet. I would like to be able to define the dependencies in a <strong>separate</strong> file, not directly on the file that will use it.</p>