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

Reply via email to