thinking of yougradle使⽤maven-publish发布jar包上传到私有maven配置
⽬录
⼀、添加插件
⼆、添加如下配置
三、执⾏以下命令进⾏上传
四、遇见的问题
⼀、添加插件
apply plugin: 'maven-publish'
⼆、添加如下配置
//打包源码
task sourceJar(type: Jar) {
from sourceSets.main.allJava
}
publishing {
publications {
maven(MavenPublication) {
//指定group/artifact/version信息,可以不填。默认使⽤项⽬group/name/version作为groupId/artifactId/version
up
artifactId project.name
lindsay marie
version project.version
//如果是war包填写components.web,如果是jar包填写components.java
from components.java
//配置上传源码
artifact sourceJar {
classifier "sources"
}
}
}
repositories {
maven {vacuum pump>深圳美发
//指定要上传的maven私服仓库
url = ":8080/maven/content/repositories/thirdparty/"
//认证⽤户和密码
credentials {
ogallala
urname 'admin'
password 'maxrocky5721'
}
}
}
}神探夏洛克第一季
三、执⾏以下命令进⾏上传
gradle publishMavenPublicationToMavenRepository
正常的输出结果
➜ gradle publishMavenPublicationToMavenRepository翻译软件免费下载
:
common:generatePomFileForMavenPublication
:common:compileJava UP-TO-DATE
:common:processResources UP-TO-DATE
:common:class UP-TO-DATE
:common:jar UP-TO-DAT
:common:sourceJar UP-TO-DATE
:common:publishMavenPublicationToMavenRepository
Upload :8080/maven/content/repositories/thirdparty/com/kingboy/common/1.0/common-1.0.jar
Upload :8080/maven/content/repositories/thirdparty/com/kingboy/common/1.0/common-1.0.jar.sha1
Upload :8080/maven/content/repositories/thirdparty/com/kingboy/common/1.0/common-1.0.jar.md5
Upload :8080/maven/content/repositories/thirdparty/com/kingboy/common/1.0/common-1.0.pom
Upload :8080/maven/content/repositories/thirdparty/com/kingboy/common/1.0/common-1.0.pom.sha1
Upload :8080/maven/content/repositories/thirdparty/com/kingboy/common/1.0/common-1.0.pom.md5
Upload :8080/maven/content/repositories/thirdparty/com/kingboy/common/1.0/common-1.0-sources.jar
Upload :8080/maven/content/repositories/thirdparty/com/kingboy/common/1.0/common-1.0-sources.jar.sha1
Upload :8080/maven/content/repositories/thirdparty/com/kingboy/common/1.0/common-1.0-sources.jar.md5
Upload :8080/maven/content/repositories/thirdparty/com/kingboy/l
Upload :8080/maven/content/repositories/thirdparty/com/kingboy/l.sha1
Upload :8080/maven/content/repositories/thirdparty/com/kingboy/l.md5
BUILD SUCCESSFUL
Total time: 1.906 cs
四、遇见的问题
有时候会出错,如下输出
:common:generatePomFileForMavenPublication
:common:compileJava UP-TO-DATE
:common:processResources UP-TO-DATE
:common:class UP-TO-DATE
tips是什么意思:common:jar UP-TO-DATE
:common:sourceJar UP-TO-DATE
:common:publishMavenPublicationToMavenRepository
shanghai massage
Upload :8080/maven/content/repositories/thirdparty/com/kingboy/common/1.0/common-1.0.jar
新gre总分
Could not transfer artifact com.kingboy:common:jar:1.0 from/to remote (:8080/maven/content/repositories/thirdparty/): Could not write to resource 'com/kingboy/common/1.0/common-1.0.jar'
Upload :8080/maven/content/repositories/thirdparty/com/kingboy/common/1.0/common-1.0.pom
Could not transfer artifact com.kingboy:common:pom:1.0 from/to remote (:8080/maven/content/repositories/thirdparty/): Could not write to resource 'com/kingboy/common/1.0/common-1.0.pom'
Upload :8080/maven/content/repositories/thirdparty/com/kingboy/common/1.0/common-1.0-sources.jar
Could not transfer artifact com.kingboy:common:jar:sources:1.0 from/to remote (:8080/maven/content/repositories/thirdparty/): Could not write to resource 'com/kingboy/common/1.0/common-1.0-sources.jar'
:common:publishMavenPublicationToMavenRepository FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':common:publishMavenPublicationToMavenRepository'.
> Failed to publish publication 'maven' to repository 'maven'
> Failed to deploy artifacts: Could not transfer artifact com.kingboy:common:jar:1.0 from/to remote (:8080/maven/content/repositories/thirdparty/): Could not write to resource 'com/kingboy/common/1.0/common-1.0.jar' * Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
我的是因为⽹络原因,换个⽹络,多试⼏次就成功了,去stackoverflow上看了以下,没有太明确的原因。
以上就是gradle使⽤maven-publish发布jar包上传到私有maven配置的详细内容,更多关于gradle发布jar包到私有maven的资料请关注其它相关⽂章!