How to serve AAR files using jitpack
Asked Answered
F

1

8

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.

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?

Any help would be appreciated.

Flyaway answered 23/2, 2019 at 5:43 Comment(5)
Not a accurate answer of question, but I recommand using jFrog Artifactory instead Jitpack. You can install Artifactory in your VPS using docker in 30 minutes.Avenue
Was hoping to get this done without using a VPS. And the cloud hosted version of jFrog Artificatory is paid.Flyaway
@TabishImran Did you get any solution?Constituency
@AnoojKrishnanG , ended up getting jitpack's paid subscription.Flyaway
@TabishImran Why would the paid one help? Isn't the paid one just making it private?Nealon
N
5

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

The steps:

  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.

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

  3. 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. Another is 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>

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. On Github, create a new release, go to Jitpack, paste the URL there (example here of what I did), wait a bit for the release to appear, and press "GET" button.

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

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

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

  2. 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 tried to follow all the possible tips and guidelines, but still failed to use it properly. Wrote about this here.

  3. 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?

  4. 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.

Nealon answered 14/3, 2021 at 8:37 Comment(5)
the second issue is critical for me too waiting for responseNapoleon
@Napoleon I think it is related to pom file, but not sure how to fill itNealon
I followed that article too and followed the exact same steps, but Jitpack is stuck loading the build logs like if the build never ended, and I can't even see any part of those logs. Did any of you experience a similar issue on Jitpack?Centripetal
@Centripetal I think it's best for you to contact their support.Nealon
Thank you, you saved my life day, I tried about 20 different release on my Github (follow by that tutorial), but no luck. In my case there was a problem (the formatting error as you mentioned above!) with jitpack.yml.Riba

© 2022 - 2024 — McMap. All rights reserved.