简体   繁体   English

Gradle如何生成外部库?

[英]Gradle how to generate external library?

In gradle (in Android Studio) you can import external libraries simply by defining an url, eg:在 gradle(在 Android Studio 中)中,您可以通过定义一个 url 来导入外部库,例如:

dependencies {
    compile 'com.makeramen:roundedimageview:2.2.0'
    compile 'com.isseiaoki:simplecropview:1.0.10'
}

I know that you can link local libraries.我知道您可以链接本地库。 But that's not wanted, since we want to share a common library in a team.但这不是我们想要的,因为我们希望在团队中共享一个公共库。 I wonder how to setup such a URL for an own library?我想知道如何为自己的图书馆设置这样的 URL? Is it also possible to make it not public accessible?是否也可以使其不可公开访问?

If you use a Private Git SCM like Github or Bitbucket , you can easily turn it as a Maven repository and host your private library there.如果您使用像GithubBitbucket这样的私有Git SCM,您可以轻松地将其转换为 Maven 存储库并在那里托管您的私有库。 This can be used to refer libraries as dependencies in your projects just like you do with public libraries hosted on MavenCentral, JCenter or others.这可用于将库作为项目中的依赖项引用,就像您对托管在 MavenCentral、JCenter 或其他平台上的公共库所做的一样。

You can get the detailed description for the same here: Publish with Gradle on Bitbucket您可以在此处获得相同的详细说明: 在 Bitbucket 上使用 Gradle 发布

Also you can refer this link to publish your library privately using JitPack.您也可以参考此链接使用 JitPack 私下发布您的库。 JitPack supports building and installing from private Git repositories. JitPack 支持从私有 Git 存储库构建和安装。 Build artifacts are also kept private and you can only download them if you have access to the Git repository itself.构建工件也是保密的,只有在您有权访问 Git 存储库本身的情况下才能下载它们。

You can also share your build artifacts (jar, aar) publicly while keeping the source code private.您还可以公开共享您的构建工件(jar、aar),同时保持源代码的私密性。 For example, you can easily distribute your library to your users without giving them access to code.例如,您可以轻松地将您的库分发给您的用户,而无需让他们访问代码。

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

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