Root level repository for subprojects

I have multiproject build and I have local repository within root project which contains jars. I want this repository to be populated to all my subprojects, so they can reference certain jar as needed. However, when I try to add local repository to subproject via flatDir, the path is relative to the subproject, not the root project. I cannot understand how do specify local repo for subprojects relative to the root project.

Its really hard to explain here, so I’ll try to show what I mean :slight_smile: :

My project structure:

> rootProj > - localRepo // <- this is my local repo with jars > - subProj1 > - subProjRoot > -- subProj2 > -- subProj3 >

The way I try to specify my local repo is:

allprojects {
    repositories {
        flatDir dirs:'' // <- this path is relative to each subproject, so I don't know what to put here

if I specify flatDir dirs:'localRepo' each project will get relative link to localRepo folder within subproject which doesn’t exist.

I could manually go into each of my subproject and specify relative path (something like flatDir dirs:'../../localRepo'), but I want to do this for all my subprojects at once from the root buildscript

How do I tell all my subprojects about local repo in the root project?

Just use a path relative to the root project directory.

flatDir dirs: "$rootDir/localRepo"

Hm, don’t know how i missed that. I tried slightly different approach:

flatDir dirs: "$rootProject.projectDir/localRepo"

But this way my build went crazy - my dex file overflowed for some reason, so I didn’t try $rootDir approach assuming this is the same as $rootProject.projectDir

Actually $rootDir/localRepo causes dex overflow as well. And when I specify dependency manually from subproject via flatDir dirs:'../../localRepo' - everything works fine. But I think this is my internal problem. Thanks!

Yes rootDir and rootProject.projectDir are synonymous. I’m not sure I understood your last post. If you hardcode a relative path to the repository in your subprojects it works fine?

Correct. Actually I’m balancing on the edge of infamous “65k dex methods limit” and for some reason when I hardcode relative path within my subproject (via compile files('../localRepo/someLib.jar'), I am not hitting 65k boundary. But once I specify my dependency via repo (compile ':someLib:'), my ProGuard start yelling at me that I reached 65k methods limit. Not sure why these 2 options differ. I’ll try to create some clean demo project to illustrate this…

Oh ok, so in one instance you are using a flat directory repository and the other a file dependency. They might be resolving to different jars. Try printing out the result of the ‘compile’ configuration between both and see if there is any difference.

configurations.compile.each { println it }