Reputation: 1739
I am trying to download a dependancy library mylibrary.aar
from my gitlab
repository via gradle
. I understand that we dont have any closures/methods in gradle to directly get files from a http
url.
Therefore am using ant
's getmethod to download the library from gitlab
.
Here is the code am using in my gradle
file to get the library.
task downloadlib {
ant.get(src: 'https://my-git-link/mylibrary.aar', dest: 'libs', verbose: 'on')
}
dependencies {
compile(name: 'mylibrary', ext: 'aar')
}
Problem :
The files which I download via the ant's get method seems to be corrupted/does not go through the download process properly. Not sure what goes wrong. The library does not get compiled and the dependencies cannot be resolved. When I try to extract the aar
it again extracts to cgpz
file in my mac.I havent tried in windows though.
However, if I manually download the same aar
file and reference it in the libs folder it works absolutely fine.
aar
file from a gitlab server apart from ant.get
?Any help on this is much appreciated.
Note : I cannot use a locally built dependancy as all my libraries are on different repo and the project requirement mandates the same.Also, the code cannot be posted in github and thats the reason I did not choose jitpack
The same problem occurs for jar
files as well.
Upvotes: 4
Views: 3247
Reputation: 1739
I dont think I have a direct solution for the problem as gradle
does not have an api for this. Instead what I did was, created my own maven repository using jfrog
's artifactory
and hosted the libraries there so that all the developers can refer to the libraries from the internal artifactory.
The artifactory OSS version can be downloaded from here
I chose artifactory
because it was much simpler and had a great UI. Most of all it did not require setting up a separate github
repository for this purpose as the code cannot be shared outside the organization.
After setting up, your libraries can be accessed as below.
http://localhost:8081/artifactory.
A brief description of setting up an artifactory is provided here
After the libraries are hosted in your artifactory
which can be located anywhere in your network, u or any other developer in your organization may access your libraries using the maven dependency manager in android.
I hope this helps.
Upvotes: 2
Reputation: 899
Do it like this example:
implementation 'com.quickblox:quickblox-android-sdk-core:2.5.2@aar'
implementation('com.quickblox:quickblox-android-sdk-chat:2.5.2@aar') {
transitive = true
}
Upvotes: 0