发布Gradle插件(java)

发布Gradle插件到远程maven仓库


使用的Gradle版本是6.7.1,可以查看如下链接:
https://docs.gradle.org/6.7.1/userguide/publishing_maven.html#publishing_maven:complete_example
https://www.cnblogs.com/huhx/p/16556548.html

  • 第一步:点击Close按钮,它会触发对发布包的检验
    可能出现signature validation问题
    失败原因:No public key in http://keyserver.ubuntu.com:11371
    是因为同步key可能会花些时间。手动发布key到服务器即可
    gpg –keyserver http://keyserver.ubuntu.com:11371 –send-keys [signing.keyId替换]

  • 第二步:点击Refresh按钮

  • 第三步:点击Release按钮

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
plugins {
id 'groovy'
id 'java-library'
id 'maven-publish'
id 'signing'
}
version "1.0.1"
group "io.github.stewforani"
java {
withJavadocJar()
withSourcesJar()
}
publishing {
publications {
mavenJava(MavenPublication) {
artifactId "lifemonitor"
from components.java
versionMapping {
usage('java-api') {
fromResolutionOf('runtimeClasspath')
}
usage('java-runtime') {
fromResolutionResult()
}
}
pom {
name = 'Activity Life Log'
description = 'get log from activity execute oncreate'
url = 'https://github.com/stewForAni/lifemonitor'

licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}

developers {
developer {
id = 'stewForAni'
name = 'stew'
email = 'stewForAni@gmail.com'
}
}

scm {
connection = 'https://github.com/stewForAni/lifemonitor.git'
developerConnection = 'https://github.com/stewForAni/lifemonitor.git'
url = 'https://github.com/stewForAni/lifemonitor'
}

}
}
}
repositories {
maven {

//url "../myrepo"
url "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
credentials {
username ossrhUsername // ossrhUsername is your sonatype username
password ossrhPassword // ossrhUsername is your sonatype password
}
}
}
}

signing {
sign publishing.publications.mavenJava
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation gradleApi()
implementation localGroovy()
implementation 'com.android.tools.build:gradle:4.2.2'
implementation 'org.ow2.asm:asm:7.1'
implementation 'org.ow2.asm:asm-commons:7.1'
}

查看项目:https://github.com/stewForAni/lifemonitor
参考文章:https://www.cnblogs.com/huhx/p/16556548.html