简体   繁体   中英

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?

A simple solution would be to publish your library with JitPack . You just would need to create a GitHub release and have a build file in your repository.

JitPack is a maven repository that pulls in packages from GitHub repositories. It checks out your code and builds it.

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'
        }
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM