Hi,
I am running across an issue applying a build script from a separate lower level folder. I am not using the gradle multi-project functionality intentionally because of configuration ordering problems (namely one project has to run completely before the others can be configured). To work around this I am just using a shared folder with shared gradle scripts.
I have contrived an example to demonstrate the problem:
Directory structure: fixme/ fixme/myproject/ fixme/myproject/build.gradle fixme/shared/ fixme/shared/shared-build.gradle
build.gradle:
apply from: "../shared/shared-build.gradle"
shared-build.gradle:
buildscript {
println "Setup buildscript"
repositories { flatDir name: 'libs', dir: 'C:/gradle/gradle-2.2.1-all/gradle-2.2.1/samples/customPlugin/plugin/build/libs/' }
dependencies { classpath group: 'org.gradle', name: 'customPlugin', version: '1.0-SNAPSHOT' }
}
println "And now I'm here"
project.buildscript.configurations.classpath.each { println it }
buildscript.configurations.classpath.each { println it }
apply plugin: 'org.samples.greeting'
apply plugin: 'java'
Observe that if the code in shared-build.gradle is in build.gradle everything works fine. I am pulling in a built version of the sample plugin that comes with gradle 2.2.1. However, when build.gradle delegates some of its logic to shared-build.gradle I get this:
C:\view\mrichar2_apr\fixme\myproject>gradle -i build Starting Build Settings evaluated using empty settings script. Projects loaded. Root project using build file ‘C:\view\mrichar2_apr\fixme\myproject\build.gradle’. Included projects: [root project ‘myproject’] Evaluating root project ‘myproject’ using build file ‘C:\view\mrichar2_apr\fixme\myproject\build.gradle’. Compiling script ‘C:\view\mrichar2_apr\fixme\shared\shared-build.gradle’ using StatementExtractingScriptTransformer. Setup buildscript Compiling script ‘C:\view\mrichar2_apr\fixme\shared\shared-build.gradle’ using BuildScriptTransformer. And now I’m here C:\gradle\gradle-2.2.1-all\gradle-2.2.1\samples\customPlugin\plugin\build\libs\customPlugin-1.0-SNAPSHOT.jar
FAILURE: Build failed with an exception.
-
Where: Script ‘C:\view\mrichar2_apr\fixme\shared\shared-build.gradle’ line: 13
-
What went wrong: A problem occurred evaluating script. > Failed to apply plugin [id ‘org.samples.greeting’]
Plugin with id ‘org.samples.greeting’ not found.
- Try: Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.
If I instead change the buildscript to be project.buildscript it complains that “classpath” has already been configured and cannot be changed.