Gradle.properties are not available when applying external script in buildscript


(Levon Saldamli) #1

I tried this solution with an external script but I too get the error that my property is not defined:

buildscript.gradle:

dependencies {
    classpath "com.company.plugins:some-plugin:${pluginVersion}"
}

build.gradle:

buildscript { 
    apply from: "buildscript.gradle", to: buildscript
}

gradle.properties:

pluginVersion=5.6M6-SNAPSHOT

When running:

> gradle tasks

FAILURE: Build failed with an exception.

* Where:
Script '/Users/levsa/tmp/foo/buildscript.gradle' line: 2

* What went wrong:
A problem occurred evaluating script.
> Could not find property 'pluginVersion' on org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler_Decorated@24d3e83f.

Continuing the discussion from Inherit / inject buildscript dependencies into custom script within subproject:


(Val) #2

The example above (from Peter) does not work.