美文网首页
android 搭建maven 私服 简化依赖配置并优化代码复用

android 搭建maven 私服 简化依赖配置并优化代码复用

作者: AaronLee0704 | 来源:发表于2019-04-24 16:41 被阅读0次

一、Nexus的环境搭建

1.Nexus下载

     Nexus  官网 :https://www.sonatype.com/

     免费版官网Download Nexus Repository OSS  url(推荐)  (自行下载对应操作系统的最新版本,并安装,自己动手丰衣足食哈哈)

   (收费版/企业版) Nexus Repository Pro  


2.安装(以windows 安装为例)

      将下载后的bin 目录添加到系统PATH环境变量(不懂请搜 windows 环境变量配置)

        官方下载安装指引请看 :Lesson 1: Installing and Starting Nexus Repository Manager

        (包括下载,安装,运行环境,登录账号等信息指引)

3.编辑nexus 的路径映射文件:  nexus.vmoptions 

    找到解压目录下  如:F:\mysoftware\nexus-3.16.1-02-win64\nexus-3.16.1-02\bin

    打开文件并编辑文件nexus.vmoptions,将如下两行映射为自己的具体路径

        -Dkaraf.data=N:/nexus-3.9.0-01-win64/sonatype-work/nexus3

        -Djava.io.tmpdir=N:/nexus-3.9.0-01-win64/sonatype-work/nexus3/tmp

4.启动cmd 运行nexus 命令

    复制或键入命令:   nexus.exe  /run

     运行成功后打开浏览器 键入网址 http://localhost:8081/可看到操作界面

    (defualt账号密码:admin/admin123 )

5.maven repository 相关知识储备

    5.1有必要花3小时以上看完感兴趣的官网user guide视频&文档:

        连接如下:Sonatype Nexus Repository Manager and IQ Server Courses

    5.2 创建maven proxy repository 

        更具体的官方文档了解一下: Lesson 2: Proxy and Hosted Maven Repositories

6.具体的中文搭建过程,请参考作者

Maven 仓库使用与私有仓库搭建


                     动手小实验(以上环境搭建好之后)

1.android studio 创建host repository (本地仓库) 并上传

hosted作用,本地仓库,通常我们会部署自己的构件到这一类型的仓库。比如公司的第二方库

可以部署到公司服务器,实现代码复用。

    1.1 module  的build.gradle  配置上传本地库代码

android 的app 或者 module 的 gradle中写入如下打包上传代码

            uploadArchives {

                    configuration = configurations.archives

                    repositories {

                            mavenDeployer {  // 私有仓库的地址,以及账户

                                repository(url: 'http://127.0.0.1:8081/repository/localT/') {//从

                                authentication(userName: 'admin', password: 'admin123')

                            }

                        pom.project {  // Library的配置

                    version libVerName

                    artifactId 'printer'

                    groupId 'com.lee'

                    packaging 'aar'

                    description 'test util to say hello'

                }}}}

1.2 在app 的 build.gradle 中添加引用 

        dependencies {

                implementation'com.android.support.constraint:constraint-layout:1.1.3'

                androidTestImplementation'com.android.support.test.espresso:espresso-core:3.0.2'

                implementation   'com.lee:printer:1.0@aar'

          }


2  创建proxy repository 代理仓库            

    2.1 看图

        测试步骤一 打开如下,点击maven2 proxy

官方步骤 点击:URL

官方步骤摘要:

相关文章

网友评论

      本文标题:android 搭建maven 私服 简化依赖配置并优化代码复用

      本文链接:https://www.haomeiwen.com/subject/yagmgqtx.html