Maven私服搭建及使用

2018-04-28  本文已影响245人  Mr_不靠谱_先森

涉及到Maven私有部署搭建的一般都为公司开发的项目比较多,各项目之间有共同的功能部分,比如一些工具类,统一的导航栏及网络请求框架等,可以整体提升团队开发效率及代码维护成本,旨为项目模块组件化开发做准备


Nexus 环境搭建

Nexus下载地址:https://blog.sonatype.com/
分不同的系统版本
windows版本:https://www.sonatype.com/oss-thank-you-win64.zip

Nexus 安装及环境变量配置

  1. 解压下载的.zip文件
  2. 配置Nexus路径
    将nexus-3.11.0-01目录下的bin添加到环境变量的path中
  3. 编辑nexus.vmoptions
    打开bin文件夹下的nexus.vmoptions,配置Dkaraf.data和Djava.io.tmpdir两项,图中N:/nexus-3.9.0-01-win64/sonatype-work/nexus3是我的zip解压路径,注意斜杠方向。
-Xms1200M
-Xmx1200M
-XX:MaxDirectMemorySize=2G
-XX:+UnlockDiagnosticVMOptions
-XX:+UnsyncloadClass
-XX:+LogVMOutput 
-XX:LogFile=../sonatype-work/nexus3/log/jvm.log
-XX:-OmitStackTraceInFastThrow
-Djava.net.preferIPv4Stack=true
-Dkaraf.home=.
-Dkaraf.base=.
-Dkaraf.etc=etc/karaf
-Djava.util.logging.config.file=etc/karaf/java.util.logging.properties
-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
-Dkaraf.startLocalConsole=false
  1. 编辑nexus-default.properties
    另外在文件夹N:\nexus-3.9.0-01-win64\nexus-3.9.0-01\etc下还有一个配置文件nexus-default.properties,有需要的也可以自行修改nexus-context-path这个参数,这个是nexus启动时的根路径,默认是“/”。
## DO NOT EDIT - CUSTOMIZATIONS BELONG IN $data-dir/etc/nexus.properties
##
# Jetty section
application-port=8081
application-host=0.0.0.0
nexus-args=${jetty.etc}/jetty.xml,${jetty.etc}/jetty-http.xml,${jetty.etc}/jetty-requestlog.xml
nexus-context-path=/

# Nexus section
nexus-edition=nexus-pro-edition
nexus-features=\
nexus-pro-feature
  1. 启动
    打开CMD,接下来执行命令:nexus.exe /run。 如果打印Started Sonatype Nexus OSS 3.9.0-01[不同版本Nexus的版本号不同],说明启动成功

  2. 查看网站
    启动成功后,访问:localhost:8081。
    默认的用户名和密码:admin/admin123


    image.png

Maven 使用

仓库创建
image.png
maven-central:maven中央库,默认从https://repo1.maven.org/maven2/拉取jar
maven-releases:私库发行版jar
maven-snapshots:私库快照(调试版本)jar
maven-public:仓库分组,把上面三个仓库组合在一起对外提供服务,在本地maven基础配置settings.xml中使用。
hosted:类型的仓库,内部项目的发布仓库
releases:内部的模块中release模块的发布仓库
snapshots:发布内部的SNAPSHOT模块的仓库
3rd party:第三方依赖的仓库,这个数据通常是由内部人员自行下载之后发布上去
proxy:类型的仓库,从远程中央仓库中寻找数据的仓库
创建步骤
image.png
image.png

新建group仓库过程


image.png image.png

Android Studio 中发布aar 到 Maven

image.png
image.png
image.png
image.png
image.png
image.png
image.png image.png

参考文档:

上一篇 下一篇

猜你喜欢

热点阅读