peer
peer

Reputation: 4719

How to export dependencies whole?

I have a library B that depends on another library A. A third library C depends on B and A. I can satisfy C's dependencies with

dependencies {
    implementation files('/path/A.jar')
    implementation files('/path/B.jar')
}

but I would rather only declare B and build B.jar in such a way that it contains and exposes A as well. I know that with api files('/path/A.jar') B can expose the parts of A that it uses in interfaces, but (my experience is that) it doesn't let consuming projects import anything from A explicitly. How can B expose A completely?

Upvotes: 1

Views: 150

Answers (1)

PrasadU
PrasadU

Reputation: 2438

files() is only for local flat file use, there are 2 mechanisms to share transitive dependencies ...

project(':other')        (project dependency) 
'group:artifact:version' (maven repository dependency)

https://docs.gradle.org/current/userguide/declaring_repositories.html#sec:repository-types

if the source for B & A is available locally & can be built along with C ... then declaring like below is possible

implementation project(':A')
implementation project(':B')

else you go with proper maven repository artefact.

Upvotes: 1

Related Questions