1.1 build.gradle 项目设置

plugins {
    id 'java'
    id 'maven' //引入maven插件
}

group 'com.inkyi' //包名
version '1.0.1-SNAPSHOT' //版本号

1.2 build.gradle 上传设置

// 指定上传的路径
def localMavenRepo = 'file://' + new File(System.getProperty('user.home'), '.m2/repository').absolutePath

// 上传Task,Gradle会生成并上传pom.xml文件。
uploadArchives {
    repositories {
        mavenDeployer {
            repository(url: localMavenRepo)//构造项目的Pom文件
            pom.project {
                name = project.name
                packaging = 'jar'
                description = 'description'
            }
        }

    }
}

1.3 项目根目录执行命令

Z:\xxxxxx>gradle uploadArchives

BUILD SUCCESSFUL in 0s
3 actionable tasks: 1 executed, 2 up-to-date

 

2.上传私有仓库(参考Gradle Plugin文档,没有真正上传过)

2.1 build.gradle 项目设置和上面的 1.1 一样

2.2 build.gradle 上传设置

// 上传Task,Gradle会生成并上传pom.xml文件。
uploadArchives {
repositories {
mavenDeployer {
       //这个地方,多了填写用户名和密码的方法,用来私有仓库的验证
repository(url: "scp://repos.mycompany.com/releases") {
authentication(userName: "me", password: "myPassword")
}
//构造项目的Pom文件
pom.project {
name = project.name
packaging = 'jar'
description = 'description'
}
}

}
}

2.3 项目根目录执行命令与1.3是一样的

 

上传本地仓库的我试过是可以用的,上传私有仓库的还没试过,有不符合的地方,建议参考文档再调整一下。文档地址:https://docs.gradle.org/current/userguide/maven_plugin.html

相关文章:

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