I have multiple project gradle build and I am trying to externalize dependencies version via gradle.properties. Unfortunately child project can not find properties in parent gradle.properties
So in parent gradle.properties I have :
SPRING_VERSION=3.2.0.RELEASE
in parent build.gradle I have
dependencies {
compile "org.springframework:spring-webmvc:$SPRING_VERSION"
...
and this works fine. But in the child project same thing cause error :
Could not resolve all dependencies for configuration
Could not find org.springframework:spring-context-support:$SPRING_VERSION.
If I hardcode the version project builds fine.
also in parent file I have settings.gradle which specifies :
include 'projectA','projectB','projectC'
project structure
root
|
\ buildSRC
\ projectA
|
\ build.gradle
\ projectB (build script in parent build.gradle)
\ projectC (build script in parent build.gradle)
|
|
\ build.gradle
\ gradle.properties
\ settings.gradle
thanks for help
w
In Groovy, double-quoted Strings support String interpolation, whereas single-quoted Strings don't. Apparently, you mistakenly used a single-quoted String in the subproject. As a result, Gradle went searching for a version that is literally named
$SPRING_VERSION
, which of course it didn't find.Verify if inside your child project you have settings.gradle and if it's there, remove.
Unfortunately neither of the other options worked out for me. I had had success referencing the variables in this file using the following.
Maybe this will help someone else.
In projectA-build.gradle you should reference the variables in main gradle.properties with this code: