一、Jfrog Artifactory簡(jiǎn)介
Jfrog Artifactory是一款二進(jìn)制存儲(chǔ)管理工具,用來管理構(gòu)建工具(如:maven、gradle)等所依賴的二進(jìn)制倉(cāng)庫(kù),以方便管理第三方庫(kù)和發(fā)布目標(biāo)版本庫(kù),從而提高軟件開發(fā)效率。它提供大量的插件以利于和不同工具之間的整合,內(nèi)部使用權(quán)限管理更加安全,并支持高并發(fā)等等特性。
二、Artifactory的構(gòu)建
搭建Artifactory私服的主要目的,是作為團(tuán)隊(duì)內(nèi)所使用公共組件模塊倉(cāng)庫(kù)。將Maven構(gòu)件(jar和pom)存儲(chǔ)到一個(gè)專門的Maven倉(cāng)庫(kù),使用時(shí)通過Gradle選擇版本,構(gòu)建應(yīng)用。
Artifactory軟件下載地址:
https://bintray.com/jfrog/artifactory/jfrog-artifactory-oss-zip/6.21.0
下載解壓到本地,打開bin目錄 執(zhí)行啟動(dòng)命令
sh artifactory.sh
瀏覽器打開管理頁(yè)面
http://localhost:8081/artifactory/
默認(rèn)登陸賬戶 admin 密碼 password

Artifactory 安裝包里集成了tomcat,所以不需要再單獨(dú)安裝。默認(rèn)的端口是8081,修改啟動(dòng)端口,可修改server.xml文件中的端口
/tomcat/conf/server.xml
默認(rèn)情況下Artifactory 是不允許匿名下載以及訪問的,使用maven庫(kù)時(shí),拉取pom文件出現(xiàn),
Received status code 401 from server: Unauthorized。
考慮到實(shí)際的情況,我們現(xiàn)在需要Artifactory 開啟匿名訪問權(quán)限。操作如下:
打開Artifactory后臺(tái),進(jìn)入設(shè)置界面,
Administration -> Security -> Security onfiguration
選中Allow Anonymous Access,然后點(diǎn)擊保存。如下圖


三、Artifatory 本地倉(cāng)庫(kù)創(chuàng)建
登陸到web服務(wù)臺(tái)后,就可以創(chuàng)建相關(guān)的倉(cāng)庫(kù)了。倉(cāng)庫(kù)分為,本地Local型,遠(yuǎn)程Remote型,以及虛擬型。
- 本地私有倉(cāng)庫(kù):用于內(nèi)部使用,上傳的組件不會(huì)向外部進(jìn)行同步。
- 遠(yuǎn)程倉(cāng)庫(kù):用于代理及緩存公共倉(cāng)庫(kù),不能向此類型的倉(cāng)庫(kù)上傳私有組件。
- 虛擬倉(cāng)庫(kù):不是真實(shí)在存儲(chǔ)上的倉(cāng)庫(kù),它用于組織本地倉(cāng)庫(kù)和遠(yuǎn)程倉(cāng)庫(kù)。
倉(cāng)庫(kù)創(chuàng)建可以在admin -> repository 下相應(yīng)的子類型中,輸入倉(cāng)庫(kù)名稱,添加倉(cāng)庫(kù)描述,即可完成創(chuàng)建。




四、倉(cāng)庫(kù)文件上傳
demo項(xiàng)目 https://github.com/jics/artifactorydemo
創(chuàng)建demo項(xiàng)目與相關(guān)library,配置相關(guān)文件,編譯完成aar文件上傳。
-
1、Project 中 gradle.properties 配置倉(cāng)庫(kù)地址與用戶信息
010.png
- 2、 Project 中 build.gradle中添加配置

- 3、library Moudle中配置發(fā)布腳本 詳見demo



- 4、編譯 library moudle并完成上傳
gradle assembleRelease artifactoryPublish
- 5、在Artifatory中查看發(fā)布的aar文件

五、gradle應(yīng)用倉(cāng)庫(kù)文件
- 1、 Project 中 build.gradle中添加配置

- 2、app Moudle中 build.gradle中添加配置

- 3、編譯工程,并驗(yàn)證。
六、第三方倉(cāng)庫(kù)引用注意點(diǎn):
- 1、保持所使用倉(cāng)庫(kù)版本最新可如下配置
compile 'com.tencent.bugly:nativecrashreport:latest.integration'
latest.integration resolves to latest snapshot or release, whichever is newer. There is no symbolic version for latest snapshot only (use 1.2.3-SNAPSHOT).
- 2、 maven緩存處理 :
Normally, Gradle will still cache changing modules for a 24 hour period. You can configure this cache timeout using something like:
configurations.all {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
resolutionStrategy.cacheDynamicVersionsFor 0, 'seconds'
}
七、擴(kuò)展補(bǔ)充內(nèi)容
- 1、https://blog.csdn.net/lu_xin_/article/details/51134849
- 2、 為什么選擇 artifactory https://jfrog.com/blog/artifactory-vs-nexus-integration-matrix/
- 3、https://yangbo.tech/2017/01/19/2017-01-19-distribute-android-library-to-local-jCenter/
- 4、http://blog.bugtags.com/2016/01/27/embrace-android-studio-maven-deploy/
- 5、http://blog.csdn.net/zhonggaorong/article/details/51601497
- 6、https://www.ibm.com/developerworks/cn/education/java/j-groovy/j-groovy.html
- 7、http://blog.csdn.net/zzulp/article/details/51385701
