I tear my hair off of it. I canceled my scripts directly to the code presented on the pages of the Gradle tutorial, since I think that I am either doing something fundamentally wrong or misunderstood how it is supposed that a multi-project application should be structured using gradle.
I have three java projects in eclipse, with all three containing a build.gradle script and only one containing settings.gradle script. The structure is as follows:
Scripts -- build.gradle -- settings.gradle Database -- build.gradle Services -- build.gradle
I am trying to build a "Database" and "Services" project using the script construct in the "Scripts" project. To create a project tree, I have the following code in settings.gradle:
include 'Services', 'Database' project (':Services').projectDir = new File(settingsDir, "../Services") project (':Database').projectDir = new File(settingsDir, "../Database")
By replicating the code in a multi-project tutorial (gradle docs), I try to get each build script to print some text so that everything is set up correctly. My ultimate goal is to build dependencies correctly when the "eclipseClasspath" runs so that all projects compile correctly in eclipse. However, the text does not print as I expected!
Below is what is contained in the three build scripts:
Build.gradle scripts
allprojects { task hello << { task -> println "I'm $task.project.name" } } subprojects { hello << {println "- I depend on Scripts"} }
Build.gradle database
hello.doLast { println "- I'm inside database" }
Build.gradle services
hello.doLast { println "- I'm inside services" }
In the Scripts project, when I run gradle -q hello, I get the following results:
I'm Scripts I'm AnprDatabase - I depend on Scripts I'm Database - I depend on Scripts
Why doesn't the text “I'm inside the database” and “I'm inside the services” appear? I am a little puzzled by this. I can only guess that this has something to do with my project structure. Can anyone confirm this? If not, what is the problem? As already mentioned, I canceled my scripts with this simple example, since I could not get the dependencies to run a build script in every project using the same structure.
Thanks so much for any help offered.