Krease
Krease

Reputation: 16215

How can I add gradle project dependencies without modifying settings.gradle

Background

(Please keep in mind I've simplified the problem for purposes of discussion here)

What problem am I trying to solve

What I've done so far

Where I'm stuck

My question

What's a better way to do this, without duplicating information between settings.gradle and build.gradle? I want to make it so adding new dependencies is still just as easy as adding the compile reference in build.gradle, without touching settings.gradle...

I'm still rather new to groovy/gradle, so maybe I'm missing something that's obvious to the more experienced gradle master?

Upvotes: 1

Views: 976

Answers (1)

Michael Easter
Michael Easter

Reputation: 24468

I believe your use-case is the motivation for Composite Builds.

I have a demo here, which writes to a jars folder as a mock publishing of artifacts. Be sure to check-out the README.md as the demo is a mini-laboratory for trying out the use-case before and after composite builds.

In the demo mainBuild is appa; utils is libx. The key syntax in mainBuild/settings.gradle (here) is:

includeBuild '../utils'

This tells Gradle to use the local codebase instead of the published artifact. Of course, one would not commit this line to source-control.

Upvotes: 1

Related Questions