Using a map to store dependency versions


(Daniel) #1

Hi,

I’d like to have a versions.gradle file containing:

ext {
VERSION[:]
// gradle dependency versions
VERSION['gradle-versions-plugin'] = '0.17.0'
VERSION['spotless-plugin-gradle'] = '3.9.0'
}

And then in build.gradle:

buildscript {
  repositories {
    jcenter()
  }
  dependencies {
    classpath group: 'com.github.ben-manes',  name: 'gradle-versions-plugin', version: VERSION['gradle-versions-plugin']
    classpath group: 'com.diffplug.spotless', name: 'spotless-plugin-gradle', version: VERSION['spotless-plugin-gradle']
  }
}

But gradle says:
Could not get unknown property ‘VERSION’ for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler

Any hints?