I have a multimodule project like below
ProjectA
{
interface IInterfaceA
{
api1();
api2();
}
}
ProjectB
{
class ClassB implements IInterfaceA
{
api1();
api2();
someStaticFunction();
}
}
implementation (':ProjectA')
ProjectC
{
class ClassC
{
ClassB.someStaticFunction(); ---> compile error, cannot access IInterfaceA
}
}
implementation (':ProjectB')
//implementation (':ProjectA') ---> if I add this here, it works
Why though ? since project C is not depending directly on any implemetation of ProjectA, why does it still have to add ":ProjectA" as a direct dependency ?
That's because you probably defined
ProjectA
as a dependency ofProjectB
usingimplementation
. This leads toProjectA
being accessible inProjectB
, but not in any modules depending on B.Taken from this baeldung article which outlines the different configuration types of gradle.