简体   繁体   English

Android Gradle依赖于分叉的GitHub项目

[英]Android Gradle dependency on a forked GitHub project

I've pulled in a third party custom ListView library into my Android Gradle project. 我已将第三方自定义ListView库插入到我的Android Gradle项目中。 I initially added the project as a gradle library dependency from the jcenter repo. 我最初将项目添加为jcenter repo中的gradle库依赖项。 But now I forked the GitHub project and I'm making changes to it. 但现在我分叉了GitHub项目,我正在对它进行更改。

The original project is no longer maintained, so submitting a pull request is not going to work, I really need my own fork. 原始项目不再维护,因此提交拉取请求不起作用,我真的需要自己的fork。

What would be a nice way to set this dependency up using Gradle? 使用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. 我想把ListView库放在与我的项目相同的GitHub仓库下,但这看起来很乱,我确实想把我的fork作为一个单独的库。

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. 我想到的另一件事是在同一级别检查它们,并在我的Gradle配置中使用“..”从我的应用程序进入库。 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. 或者我可以发布像mavenCentral或jcenter这样的回购,但我还在努力,所以听起来也不好。

Is there a cleaner option that I'm missing? 我缺少一个更清洁的选择吗?

A simple solution would be to publish your library with JitPack . 一个简单的解决方案是使用JitPack发布您的库。 You just would need to create a GitHub release and have a build file in your repository. 您只需要创建一个GitHub版本并在您的存储库中有一个构建文件。

JitPack is a maven repository that pulls in packages from GitHub repositories. JitPack是一个maven存储库,它从GitHub存储库中提取包。 It checks out your code and builds it. 它检查你的代码并构建它。

Another option is Gradle Source Dependencies . 另一个选项是Gradle Source Dependencies Basically you declare a dependency on a Git repository: 基本上你声明了对Git存储库的依赖:

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. Gradle将克隆并构建该项目。 Then you can add it as a dependency: 然后您可以将其添加为依赖项:

dependencies {
    implementation('org.gradle.cpp-samples:utilities') {
        version {
            branch = 'release'
        }
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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