上传时:
apply plugin: 'maven-publish' afterEvaluate { publishing { publications { release(MavenPublication) { //小驼峰flavorBuildType from components.release //必填的三个内容,组id,工件id,版本 groupId = 'xyz.junerver.fileselector' artifactId = 'file-selector-phone' version = '1.1' } } repositories { //如果有多个仓库需要上传,就写几个maven{} maven { //如果私服是http的协议需要写这行配置 allowInsecureProtocol = true //名称可以随便起 name = "nexus" //私服仓库地址 url = "http://10.5.0.39:8081/repository/maven-releases/" credentials { username = 'admin' password = 'zhao1127' } } } } }
使用命令:
gradlew assemble
gradlew publish
依赖需要在setting中修改:
pluginManagement { repositories { gradlePluginPortal() google() mavenCentral() maven { allowInsecureProtocol = true url = uri('http://10.5.0.39:8081/repository/maven-releases/') } } } dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { google() mavenCentral() maven{ allowInsecureProtocol = true url = 'http://10.5.0.39:8081/repository/maven-releases/'} } }
在build.gradle中添加
apply plugin: 'maven-publish' publishing { repositories { mavenCentral() google() jcenter() maven { allowInsecureProtocol = true url = uri('http://10.5.0.39:8081/repository/maven-releases/') } } }