创建一个摇篮依赖从混帐进口 [英] Create a gradle dependency to import from git

查看:94
本文介绍了创建一个摇篮依赖从混帐进口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是怎样的进口依赖于Android的工作室。在这种情况下okhttp:

This is how import dependencies in Android Studio. In this case okhttp:

dependencies {
    compile 'com.squareup.okhttp:okhttp:2.5.0'
} 

我想进口由我自己创建的依赖。例如:

I would like to import a dependency created by myself. For example:

dependencies {
    compile 'my_library:1.0.0'
}

在这一点上,如果我学会了如何创建一个依赖进口的Andr​​oid的Studio项目就足够了。

At this point if I learn how to create a dependency and import in Android Studio project would be enough.

不过,我想主办我的图书馆的Git(github上)存储库如果可能的话。这将是真棒。

But I would like host my library on a git(github) repository if possible. This would be awesome.

推荐答案

要实现它,你有一些方式:

To achieve it you have some ways:

  1. 发布库(神器)在中央Maven或jcenter。

  1. publish your library (artifact) in central maven or jcenter.

使用GitHub的回购和 jitpack 插件

use a github repo and the jitpack plugin

发布AAR在本地Maven回购(本地Ø私人)

publish the aar in a local maven repo (local o private)

点2。是很简单的。只要把你的codeIN github上和修改要使用该项目的摇篮脚本。

The point 2. is very simple. Just push your codein github and modify the gradle script in the project where you want to use it.

只需添加这回购TP你的 build.gradle

Just add this repo tp your build.gradle

repositories {
        // ...
        maven { url "https://jitpack.io" }
    }

和相关性:

dependencies {
        compile 'com.github.User:Repo:Tag'
    }

要发布在中央Maven或JCenter库,这是很长的答案来解释。 Hovewer你可以阅读这些文章:

To publish a library in Central Maven or JCenter, it is very long to explain in an answer. Hovewer you can read these posts:

  • 发布的<一href="http://inthecheesefactory.com/blog/how-to-upload-library-to-jcenter-maven-central-as-dependency/en"相对=nofollow> JCenter

发表于中心Maven的

这篇关于创建一个摇篮依赖从混帐进口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆