Hi I'm having 2 projects with files as below:
project1
\- build.gradle
project2
\- build.gradle
\- build.properties
project1: build.gradle
apply from: '/home/project2/build.gradle
test/test2/build.gradle'
task test1 {
println "Running task test 1"
}
test1.dependsOn test2
project2: build.gradle
task test2 {
println "Running task test 2"
Properties props = new Properties()
props.load(new FileInputStream("build.properties"))
}
When i execute test1 task from project1, i'm getting following error:
Running task test 2
FAILURE: Build failed with an exception.
Where: Script '/home/project2/build.gradle' line: 4
What went wrong: A problem occurred evaluating script. build.properties (No such file or directory)
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 5.779 secs
As gradle is working with relative path, it tries to search for build.properties file in project1 directory which is actually present in project2 directory. I can also move that file into project1 directory but that is what i don't wants to do.
I can also use absolute path in build.gradle but is that only solution?
I wants to run project2:test2
task from project1:test1
task without much modification in project2:build.gradle as i'm referring multiple file in this file.