Get source on demand

I have a very large project, with lots and lots of sub-projects organized into a tree. The dependencies go all over the place from ancestors to descendants, across siblings, to any other random sub-project.

Retrieving all the code from SVN takes a long time.

What I like to do is only retrieve the source code for a sub-project if it is a dependency.
For example if I have

/ROOT

  • A
    – A1
    – A2
    -B
    –B1
    – B2
    – -- B2a
    – -- B2b

With A1 depending on A2 and B2, and B2 depending on B2a, when working on sub-project A1 I would like the gradle files to retrieve from SVN the source code for only A1, A2, B2, and B2a,

Working means any task that examines the source code such as compiling.

Having all the build.gradle projects on disk before hand is OK.

Does anybody have any ideas on how this can be done?