Android:一個專案提交多個module到JCenter
Google一圈,搜到的唯一一篇,提供瞭解決方案!
先貼上原文備案,翻譯有空了就做 ?。
GitHub 連結:https://github.com/quangctkm9207/multi-library-bintray
Distribute multiple-module library on Bintray for Java and Android developers
Scenario
Before jumping into technical stuffs, I would like to share our story.
We planned to build a world-class manga(漫畫) studio. Our software team firstly created a manga module which serves as a primary library and it is written purely in Java.
After that, we utilize it to produce concrete mangas. Our first masterpiece is Doraemon , and our partners would like to integrate it in their Android apps. So, we developed Android doraemon module which extends manga features.
After hard working hours, our products were ready to be delivered to our partners. Because Java and Android developers use Maven repository, so we decide to release all of mangas on jCenter (one of popular Maven repository hosts). The process is described as the following diagram.
Problem
It has been a while since I published an article about Android library distribution which introduces about Maven repository and necessary steps to distribute your library using Bintray platform. We can follow these steps described in that previous article.
However, our manga studio are growing quickly, and we plan to produce 2 mangas everyday. So,we need to find out how to distribute hundreds or thousands mangas in an easier and more effortless way.
And the last Gradle configuration fits with one module release only.
For awhile, I found that there are a lot of libraries out there in the same situation.
Let’s take Retrofit library as an example, you definitely saw multiple modules involved such as retrofit
, retrofit-adapters
, retrofit-converters
. From library user view, when integrating Retrofit in our apps, we must add its core module via Gradle dependence.
compile ‘com.squareup.retrofit2:retrofit:2.3.0’
Other modules are optional based on our need for specific apps.
// Adapters
com.squareup.retrofit2:adapter-rxjava2
com.squareup.retrofit2:adapter-guava
com.squareup.retrofit2:adapter-java8
// Converters
com.squareup.retrofit2:converter-gson
com.squareup.retrofit2:converter-moshi
….
All modules are put in the same project in development but released in different packages on Maven. You can check them out here core Retrofit, RxJava adapter, Gson converter, and so on.
Finally, we found our own way to achieve this goal. In the following part, I would like to introduce a simple way to distribute multiple-module library on Bintray with detailed explanation and fully source-code sample.
Steps
Please go through following steps if you would like to distribute your library.
- Grab Gradle’s files which help you to build and upload libraries on Bintray here. It is similar to Gradle files you saw in my previous article but small changes. Put them inside /jcenter/ folder as in the sample.
- We need a common configuration Gradle file I named
[release-bintray.gradle](https://github.com/quangctkm9207/multi-library-bintray/blob/master/release-bintray.gradle)
. - For each module, let’s create its own
[gradle.properties](https://github.com/quangctkm9207/multi-library-bintray/blob/master/manga/gradle.properties)
and declare its specific configuration details. - In module’s
build.gradle
file, put this line at the bottom to let Gradle know to run it when you call Bintray upload task.
apply from: rootProject.file(‘release-bintray.gradle’)
Sample file. - Almost done, make sure you put your Bintray account credentials inside
local.properties
file as following (this file is ignored by Git, not be uploaded on version control hosting).
bintray.user=your_username
bintray.apikey=your_api_key (i.e: adfasdf342342j34lba84a25f8c3)
bintray.gpg.password=your_gpg_password - Let’s run Gradle task with one command.
./gradlew bintrayUpload
- Tell other developers to integrate your new awesome library.
For full source codes, please check the sample on Github.
And our two modules are now successfully released into separate packages, manga and doraemon, on Bintray as expected.
Note: The story of building world-class manga studio is just in my imagination, therefore please don’t wait for any more-than-a-stupid-sample masterpiece coming out.
Thank you for reading this post. Find me at Github, Twitter, Facebook, or LinkedInif you would like to get in touch.
相關文章
- 【Android AAR】快速釋出 Android Library 專案到 JCenterAndroid
- Eclipse通過EGit外掛提交多個專案到同一個倉庫EclipseGit
- 在IDEA中通過Module管理多個專案Idea
- Android進階 一個專案,一個ToolbarAndroid
- goland 把多個專案視窗合併到一個視窗GoLand
- IDEA如何在一個專案空間下管理多個專案?Idea
- 多個excel檔案合併到一個檔案中的多個sheet表中Excel
- 教你一步步釋出一個開源庫到 JCenter
- android 一套程式碼多用 以及 多套程式碼用於一個專案Android
- SourceTree 提交專案到碼雲
- 匯出多個檔案到一個Excel中的不同sheetsExcel
- 如何建立依賴專案工程--android moduleAndroid
- 如何在github同一個倉庫上傳多個專案Github
- iOS 同一個workspace下建立多個專案程式設計iOS程式設計
- 多個springboot專案部署到tomcat,Error deploying web application archiveSpring BootTomcatErrorWebAPPHive
- 《從0到1搭建一個IM專案》專案初始化
- 一個表單同時提交多條記錄
- 搭建一個專案
- GitLab -IDEA整合gitlab(提交專案到gitlab)GitlabIdea
- 如何指定多個專案的 InternalsVisibleTo
- Nginx部署Vue前端專案,部署多個Vue專案NginxVue前端
- Mac如何將多個檔案快速歸類到一個資料夾裡Mac
- 分享一個完整的社群專案(Android端加後臺)Android
- 一個Tomcat 如何部署多個專案?附多種解決方案及詳細步驟!Tomcat
- 關於一個java專案呼叫另一個java專案的心得Java
- Git多分支平行發展(一個倉庫包含多個不同的專案)Git
- 同一個專案中的多個Spring Boot應用實現CQRS - itnextSpring Boot
- 搭建一個SSM專案SSM
- 第一個SpringBoot專案Spring Boot
- 開始一個專案
- 第一個activity專案
- git clone一個laravel的專案到本地並執行GitLaravel
- Apache配置多個專案公用80埠Apache
- 成功管理多專案的9個策略
- 從0系統學Android--1.3建立你的第一個 Android 專案Android
- Android主專案和Module中R類的區別Android
- 一個優秀的Android開源框架學習專案ForgetSkyWanAndroidAndroid框架NaN
- 多個 EXCEL 檔案如何合併成一個檔案Excel