最近使用alipay的sdk,发现他只提供了aar的下载而没有提供gradle导入的方式。这将导致主工程引入我的module的时候必须要把我的module的lib也导入,很麻烦,所以就打算搭建一个本地maven仓库将他放上去。
开始~

先下载Nexus3

Nexus3搭建本地maven仓库

因为我是windows,所以就选了windows。
 

下载后解压

Nexus3搭建本地maven仓库

进入这个目录  cmd输入nexus.exe/install  就可以安装了

安装后输入nexus.exe/start  就启动了nexus3的服务

可以输入nexus.exe/status 查看状态

Nexus3搭建本地maven仓库

打开浏览器  输入localhost:8081 进入页面

Nexus3搭建本地maven仓库

点击sign in    管理员账号admin  密码admin123   这个后面可以自己创建账号  但是因为在内网使用  所以我就直接用这个了

点击

Nexus3搭建本地maven仓库

在点击Repositories  Create repository

Nexus3搭建本地maven仓库

选择

Nexus3搭建本地maven仓库

输入仓库名字  随便你

Nexus3搭建本地maven仓库

点击

Nexus3搭建本地maven仓库

仓库就创建成功了

点击

Nexus3搭建本地maven仓库

 

选中你的仓库点击> 然后点击Save

Nexus3搭建本地maven仓库

回到

Nexus3搭建本地maven仓库

点击copy 查看你的仓库地址

Nexus3搭建本地maven仓库

这个地址到时候要加入你项目的maven路径

点击

Nexus3搭建本地maven仓库

再点击Browse 再点击你的仓库

Nexus3搭建本地maven仓库

再点击Upload component  手动上传你的aar包 

Nexus3搭建本地maven仓库

Nexus3搭建本地maven仓库

点击upload  然后回到Browse 你的仓库

Nexus3搭建本地maven仓库

这样你的aar包就上传成功了

打开你项目的build.gradle  将你的maven仓库路径加进去

Nexus3搭建本地maven仓库

然后在要用这个包的module的build.gradle中导入你的包就可以成功的引用了

Nexus3搭建本地maven仓库

这上面是直接上传aar包的方式

如果你想直接将你的module上传到仓库

只需要在你的的module中的build.gradle中添加

apply plugin: 'maven'
uploadArchives {
    repositories.mavenDeployer {
        repository(url:"http://localhost:8081/repository/alipay/") {
            authentication(userName:"admin", password:"admin123")
        }        // 以com.android.support:appcompat-v7:28.0.0为对比
        pom.groupId="com.xqf.mavenlibrary" // com.android.support
        pom.artifactId="mavenTest" // 对应 appcompat-v7
        pom.version="1.0.0" // 对应版本号 28.0.0
    }
}

Nexus3搭建本地maven仓库

然后点击右边gradle   找到你的module中的uploadArchives 双击运行即可

Nexus3搭建本地maven仓库

这时候你的仓库里就能看到刚才上传的项目了

Nexus3搭建本地maven仓库

导入的方式 与之前上传的一样

Nexus3搭建本地maven仓库

 

就这样~

结束~

 

相关文章:

  • 2021-06-02
  • 2022-12-23
  • 2021-07-14
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-08
  • 2022-12-23
  • 2022-12-23
  • 2021-04-02
  • 2021-10-08
  • 2021-11-28
相关资源
相似解决方案