Hi there,
I’ve been reading up on tutorials from Gradle site. While the example in there seems to work fine, but I’m struggling to apply it in real world scenario. I will try to give as details as possible and I may have numerous questions. But I’d appreciate if you can help me understand what I’m doing wrong here.
First of all, here’s my directory structure
/TestSchedule – build.gradle – gradle.properties – settings.gradle – MergingProgram/ ---- build.gradle – ScheduleReader/ ---- build.gradle ---- gradle.properties
As you can see, I have 2 sub-directories under “TestSchedule”. I’m treating those as “sub-projects” but they’re not dependent on each other in order to perform their own tasks. I also want to use properties files separately that are relevant particular subprojects only. In my root project’s settings.gradle, here’s what I used.
include 'MergingProgram', 'ScheduleReader'
If I run the command “gradle” from root project, it evaluates both of these projects including the root project. However, if I run “gradle” from ScheduleReader directory, it evaluates the sibling project named MergingProgram as well. What is that the case? Isn’t it supposed to evaluate “down the hierarchy”?
I then altered settings.gradle in my root project as shown below.
includeFlat 'MergingProgram', 'ScheduleReader'
Now, if I run gradle from one of the subprojects, they don’t seem to evaluate other projects. Only the project directory I’m working from gets evaluated, which is what I was expecting initially.
Happily working on each of those subprojects’ build.gradle file to add necessary tasks and methods. I tested the tasks by running gradle from those subprojects directory and made sure they gave me the output I’m expecting.
I wanted to use root project’s build.gradle file to act like the executioner. The intent is to execute various tasks from sub-projects in certain order to complete the build activity. I am having problem at this stage and when I ran “gradle --info”, it seems the root project thinks sub-projects are using an “empty” build file, which obviously is not true. Is this because of “includeFlat” in the settings file?
So, why can I not run any tasks of the sub-projects from the root project? Am I approaching this the wrong way or did I misunderstood the concept? How am I supposed to handle this? If you have any questions from me for more clarification, please let me know. Thank you,