How to cleanly share modules between different projects?

I am trying to configure a large scale project using Gradle but I can’t figure out how to efficiently share modules between projects. To simplify, let’s say I have two projects P1 & P2 that rely on the same library L1. It is an Android project, but I don’t think it matters. I don’t want to have duplicates submodules in each project. So far, I have been using

project(’:L1’).projectDir = new File(’…/L1’) in settings.gradle but :

-IntelliJ complains that this syntax can confuse project configuration -It means that each dev needs to use the same structure, whereas ideally where you put the different libraries & projects should not matter.

Is there any better way to do this with Gradle ?