如何使用jitpack提供AAR文件 [英] How to serve AAR files using jitpack

查看:131
本文介绍了如何使用jitpack提供AAR文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想发布一个我一直在使用jitpack进行工作的android库.但是我想这样做而不发布源代码.我不希望jitpack构建它,我将构建的输出(AAR文件)上传到github,并且我想要jitpack仅提供这些文件.

I want to publish an android library I've been working on using jitpack. But I want to do it without publishing the source-code. I don't want jitpack to build it, I uploaded the output from the builds ( the AAR files ) to github and I want to jitpack to just serve those files.

https://jitpack.io/docs/PRIVATE/#artifact-分享不适用于用户界面,因为UI不再具有允许共享工件的设置选项卡.

The instructions at https://jitpack.io/docs/PRIVATE/#artifact-sharing aren't applicable as the UI no longer has a settings tab to permit sharing the artifacts.

还有,这样做有更好的方法吗?

Also, is there a better way of doing this?

任何帮助将不胜感激.

推荐答案

我最近实际上解决了这个问题(示例 此处 ),主要通过教程 此处 .

I actually solved this recently (sample here), mainly via a tutorial here.

步骤:

  1. 准备aar文件.您可以使用"assembleRelease"gradle任务.您也应该考虑添加Proguard规则. 此处 示例,您可能想要添加一些规则.

  1. Prepare the aar file. This you can do using the "assembleRelease" gradle task. You should consider adding Proguard rules too. Example here of some rules that you might want to add.

创建一个新的Github存储库,并将aar文件上传到那里.

Create a new Github repository, and upload the aar file there.

在存储库中放入2个新文件.一个是 jitpack.yml (非常重要的一点是,-"之前必须有2个空格,而不是该文章上写的内容):

Put 2 new files in the repository. One is jitpack.yml (very important to have 2 spaces before the "-", as opposed to what's written on the article) :

install: 
  - FILE="-Dfile=mylibrary-release.aar" 
  - mvn install:install-file $FILE -DgroupId=com.lb.sdktest -DartifactId=test -Dversion=1.0 -Dpackaging=aar -DgeneratePom=true

  1. 另一个是 pom.xml :

<?xml version="1.0" encoding="iso-8859-1"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
             http://maven.apache.org/maven-v4_0_0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <groupId>com.lb.sdktest</groupId>
   <artifactId>test</artifactId>
   <version>1.0</version>
</project>

您应更改"com.lb.sdktest"和测试"根据您的意愿,但是我认为它还是会被忽略,因为它会根据它的存在位置在Jitpack上自动更改(在我的示例中,它更改为 implementation'com.github.AndroidDeveloperLB:SdkTest:7')

You should change the "com.lb.sdktest" and "test" according to what you wish, but I think it gets ignored anyway as it's changed automatically on Jitpack according to where it exists (in my case of the sample it changed to implementation 'com.github.AndroidDeveloperLB:SdkTest:7' )

  1. 在Github上,创建一个新版本,转到Jitpack,在其中粘贴URL(例如> ,然后稍等片刻,然后按"GET"按钮.

就是这样.您将为SDK用户获得有关如何使用新依赖项的新说明!

That's it. You will get the new instructions for SDK-users of how to use your new dependency!

尽管此方法工作正常,但我发现了一些重要的问题,如果有人知道如何解决,将不胜感激:

while this is working fine, I've found some important issues that if someone knows how to fix, it will be very appreciated:

  1. 这些多余的文件是什么意思?为什么似乎那里的值被忽略了?

  1. What's the meaning of those extra files? Why does it seem the values there are ignored?

我注意到,SDK用户将必须添加aar正在使用的所有依赖项.怎么会?我在某处阅读过有关maven插件的信息,它是生成pom文件的文件,它也添加了依赖项.但是如何在Jitpack中正确使用它?我尝试使用它,实际上它生成了一个似乎具有依赖性的POM文件.我希望它能正常工作.但是,我看不到它还会添加 packagingOptions 配置.这可以在那儿处理吗?

I've noticed that the SDK-user will have to add all dependencies the aar is using. How come? I've read somewhere that for maven plugin, it is the one that generates the pom file, which adds dependencies too. But how can I use it properly for Jitpack? I tried to use it, and indeed it generated a POM file which seem to have the dependencies. I hope it will work fine. However, I don't see that it also adds packagingOptions configurations. Is this something that can be handled there?

即使我添加了许多KotlinDocs(JavaDocs,但对于Kotlin也是如此),但在生成AAR文件的过程中,它们却被完全删除了.我不知道如何以任何方式保存它们.选择手动生成它(通过IDE有一种生成JavaDocs的方法),它没有成功,因为它说没有Java文件.我该如何生成它们并使它们可供SDK用户使用?

Even though I've added many KotlinDocs (JavaDocs but for Kotlin), those get completely removed on the way to generate the AAR file. I have no idea how to preserve them in any way. Choosing to generate it manually (via the IDE there is a way to generate JavaDocs), it didn't succeed as it said there are no Java files. How can I generate those and make them available for SDK-users?

当变得混乱时,我注意到了一件奇怪的事情:它删除了我制作的Retrofit类的一些重要部分.我已经写过有关 此处 的文章,我只是想知道这是否是解决问题的最佳方法还是有更好的方法.

As it became obfuscated, I've noticed a weird thing: It removed some important parts of Retrofit classes that I've made. I've written about this here, and I just wonder if that's the best way to solve it, or there is a better way.

这篇关于如何使用jitpack提供AAR文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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