BoD
BoD

Reputation: 11035

How to use an Android gradle library in several projects without having to deploy it to a server?

I have a utility library, that I'd like to use in several app projects. I'd like to be able to work on it without having to deploy to a server every time I change something. I need a way to test it in my app before publishing the changes anywhere.

The way I would normally do this is to install the lib to my local maven repository (by local I mean on my dev machine's hard drive), in order to make it visible to the app projects.

Unfortunately, it seems that gradle install doesn't work on Android projects (see this SO question).

So my question is, what's the recommended way to do this and how do most people do? This seems to me as a fairly common use case!

Upvotes: 0

Views: 76

Answers (2)

bidyut
bidyut

Reputation: 93

If you are already deploying to the maven local, then you can just add that as a repo source for gradle. At least that's what we did:

repositories {
  mavenLocal()
}

Upvotes: 1

vRallev
vRallev

Reputation: 5040

I describe my current workflow. Maybe it helps you, too.

If I develop a library, which targets a special app, I upload a Snapshot build to my local maven repo (upload works). In my app project I reference the Snapshot build. Each time you build the app project Gradle checks for a new Snapshot release. So you definitely use the most current version of your library.

If the library is finished, I upload a finished (no Snapshot) build with a fixed version to my local repository. Later, if I want to extend the library, I increase the version of the library and add the snapshot suffix again.

I'm pretty happy with this workflow. You may want to take a look at one of my build files. In order to upload a Snapshot build, you only need to add the suffix '-SNAPSHOT' to the version string.

Upvotes: 1

Related Questions