maven伺服搭建_Maven私服搭建

本文档详细介绍了如何下载并配置Nexus来创建Android项目的私人Maven仓库,包括在`build.gradle`中配置仓库地址和认证信息,以及在`gradle.properties`中设置相关属性。同时,展示了如何在工程的`build.gradle`中添加maven plugin并编写上传脚本来发布aar包到Nexus仓库。
摘要由CSDN通过智能技术生成

1、下载配置nexus,创建对应仓库

2、Maven接入

在Android工程根目录build.gradle中配置

buildscript {

repositories {

google()

jcenter()

mavenCentral()

maven{

url 'http://localhost:8081/repository/imooc-releases/'

credentials{

username 'admin'

password 'admin123'

}

}

maven{

url 'http://localhost:8081/repository/imooc-snapshots/'

credentials{

username 'admin'

password 'admin123'

}

}

}

dependencies {

classpath 'com.android.tools.build:gradle:3.2.0'

// NOTE: Do not place your application dependencies here; they belong

// in the individual module build.gradle files

}

}

allprojects {

repositories {

google()

jcenter()

maven{

url 'http://localhost:8081/repository/imooc-releases/'

credentials{

username 'admin'

password 'admin123'

}

}

maven{

url 'http://localhost:8081/repository/imooc-snapshots/'

credentials{

username 'admin'

password 'admin123'

}

}

}

}

3、在gradle.properties中配置属性

NEXUS_REPOSITORY_URL=http://localhost:8081/repository/imooc-snapshots/

# maven仓库组织名

POM_GROUPID=com.imooc.android

POM_PACKAGING=aar

NEXUS_USERNAME=admin

NEXUS_PASSWORD=admin123

4、上传maven配置

在库工程build.gradle, 添加maven plugin,定义变量

apply plugin: 'maven'

def pomVersionName = '1.0.0-SNAPSHOT'

def pomName = this.getName()

def pomDescription = 'the audio library for all project'

def versionString = '1.0'

def versionNumber = 1

配置上传脚本

uploadArchives {

repositories {

mavenDeployer {

repository(url: NEXUS_REPOSITORY_URL) {

authentication(userName: NEXUS_USERNAME, password: NEXUS_PASSWORD)

}

pom.project {

name pomName

version pomVersionName

description pomDescription

artifactId pomVersionName

groupId POM_GROUPID

packaging POM_PACKAGING

}

}

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值