I'm using gradle 2.12 and I have a multi-module java gradle project structured in the following manner -
parentProject
|__module1
|__src
|__build.gradle
|__module2
|_src
|__build.gradle
|__build.gradle
The settings.gradle is defined as -
include "module1"
project(":module1").projectDir = file("path/to/module1")
include "module2"
project(":module2").projectDir = file("path/to/module2")
module2 depends on module1 and the dependency is required in the buildscript. I followed this example which shows a workaround as gradle doesn't allow classpath dependencies of projects in the buildscript. What I did in module2's build.gradle is -
buildscript {
repositories {
mavenLocal()
}
project.getTasks().add([name: "module1", type: GradleBuild]) {
buildFile = '../module1/build.gradle'
tasks = ['pluginJar']
}.execute()
}
apply plugin: java
dependencies {
// project specific dependencies
}
I started getting the following error -
Error:(13, 0) Could not find method add() for arguments [{name=module1, type=class org.gradle.api.tasks.GradleBuild}, build_c3cjs9wfepa1xdklituv2tk9i$_run_closure1$_closure3@51bcefbf] on task set.
I searched for similar errors and found this solution, but it didn't help me.
This is how my project structure is, and I cannot change it to make module1 an independent build.
Please advice. Appreciate your help!
Thanks