Hi Xuan, We at Prezi have a similar problem. We worked on a solution with Peter Niederwieser that solves grouping projects together and allowing them to resolve each other. The solution is in the prototype phase, but already used at Prezi. I put it out in the open now to make it easier to talk about it.
It still has quite a bit of prezi-related stuff that needs to be abstracted away, but it should be easy enough to try if you build it from source: https://github.com/prezi/pride -- Lorant On Monday 14 April 2014 at 08:10, 马旋(MA Xuan) wrote: > Hi guys, > > We have a kind of project which has a container folder at the top-level, and > some other real "projects" as sub folders in the container folder, but the > number of sub folders is not deterministic, and also there are multiple such > container projects. > > What I am trying to do is to dynamically include sub projects in > settings.gradle of the container project, I searched around, it seems that > only the settings.gradle in the root project will be loaded, and ones in the > subprojects (in my case, container projects) are just ignored. Gradle > documentation also suggests that. > > So I try to implement it. The idea is that after the root settings is > loaded, go through existing projects starting from root, and try to load the > corresponding settings for the project, get more new sub projects and add > them in the root settings project tree. > > It seems working. I have created a branch in github: > https://github.com/SuperMMX/gradle/tree/settings-per-project (with a very > simple test case). > Please look at the diff and give it a try. > > > I am a Java developer and don't know much > > about > > Gradle > > code > > (yet), > > so > > there are many hacks in > c > urrent implementation > > to just show the idea > . > Comments are appreciated. > > One thing I notice is the root project descriptor used in the settings.gradle > of sub project still represents the sub project directory, not the overall > root directory. > > Another breakage is that if gradle is executed in the sub project directory > and settings.gradle file exists for the sub project, if the subproject has a > dependency on another sub project, the dependency is not resolved, because > gradle will not look at the settings.gradle > > in > > the root directory. For example: > > Root > -- settings.gradle > -- sub1 > -- settings.gradle > -- build.gradle > -- sub2 > > sub1 depends on sub2, if execute gradle in sub1 directory, it will fail. But > it works previously. I > > t can be workarounded by executing gradle in the root directory. > > Any other considerations? > > > Thanks. > > Regards, > > Xuan MA