简体   繁体   中英

Android library maven dependency from gitlab local server's private repository

We have a Gitlab local server with private repositories. It's only accesible inside our network.

We want a way to distribute our Android libraries as maven dependencies, instead of copying modules, aar/jar etc...

An example of what we want to achieve. We have an Android project A, and an Android library B, both in our Gitlab local server, A has B as dependency. This would be our A's app build gradle file:

dependencies {
    ...
    implementation '...B'
}

From our understanding jitpack only supports public Gitlab servers for self hosted gits. https://jitpack.io/docs/PRIVATE/#self-hosted-git

I ended up using JFrog's Artifactory OSS (open source). A repository where you will store your libraries. In my case through gradle, there are more solutions like maven, nugget etc, gradle is free, the others require to pay.

What you'll have to make this works:

  • A server for the Artifacotry OSS.
  • A .gitlab-ci.yml file in your Android's project root directory.
  • A publishing gradle task in your Android's library gradle file .
  • Access to your GitLab's library repository to define variables.

In the .gitlab-ci.yml is specified which GitLab's branch to listen to, so every time you make a push in that branch a pipeline will execute with the docker settings specified in .gitlab-ci.yml . This will download everything necessary in the docker to execute the gradle publishing task in your Android's library gradle file .

Artifactory OSS documentation

GitLab CI documentation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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