Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Gradle dependency on a forked GitHub project

I've pulled in a third party custom ListView library into my Android Gradle project. I initially added the project as a gradle library dependency from the jcenter repo. But now I forked the GitHub project and I'm making changes to it.

The original project is no longer maintained, so submitting a pull request is not going to work, I really need my own fork.

What would be a nice way to set this dependency up using Gradle?

I thought of putting the ListView library under the same GitHub repo as my project, but that seems messy, I do want to keep my fork as a separate library.

Another thing I thought about was checking them both out at the same level, and using ".." in my Gradle config to get to the library from my app. This means that if I have a collaborator (and I may soon) they either need to tweak the config to suit them or check things out in the same way I did.

Or I could publish to a repo like mavenCentral or jcenter, but I'm still working on it, so that doesn't sound good either.

Is there a cleaner option that I'm missing?

like image 866
kos Avatar asked Oct 04 '14 22:10

kos


People also ask

Is it possible to declare Git repository as dependency in Android gradle?

If you store your code on GitHub then you can use GitHub Packages, it is also available for private repositories, the main downside of this service is a storage limit. Once published it becomes very easy to use the library by adding it as a regular Gradle dependency.

How do I fork a project in Android Studio?

Forking the repository You'll need to fork it first and push the branch to your fork. To do this, go to the GitHub repository and press fork. You'll need the URL of your repository in the next step, as we'll push the branch to it.


1 Answers

Another option is Gradle Source Dependencies. Basically you declare a dependency on a Git repository:

sourceControl {
    gitRepository("https://github.com/gradle/native-samples-cpp-library.git") {
        producesModule("org.gradle.cpp-samples:utilities")
    }
}

and Gradle will clone and build that project. Then you can add it as a dependency:

dependencies {
    implementation('org.gradle.cpp-samples:utilities') {
        version {
            branch = 'release'
        }
    }
}
like image 174
Andrejs Avatar answered Nov 07 '22 21:11

Andrejs