发布 snapshot 版本配置
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
apply plugin: 'maven-publish'
afterEvaluate {
publishing {
publications {
release(MavenPublication) {
from components.release
groupId = 'io.github.xxxxx' //sonatype平台创建的groupId
artifactId = project.name
version = '1.0.0' //版本,快照版本需要添加后缀 -SNAPSHOT
}
}
repositories {
maven {
// 名字可随意,会显示在 task 中
name = 'sonatypeRepository'
//url = "https://s01.oss.sonatype.org/content/repositories/snapshots/" //快照上传地址
// url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" 正式服务器
url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
credentials {
//sonatype平台账号密码 密码有特殊字符可用 \ 转义
username = "***"
password = "********"
}
}
}
}
}
发布 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
apply plugin: 'maven-publish'
apply plugin: 'signing'
ext["signing.keyId"] = "*****" //GPG指纹后8位
ext["signing.password"] = "*****" //GPG密码
ext["signing.secretKeyRingFile"] = "/xxxxxx/xxxxx/xxxx.gpg" //GPG私钥文件
afterEvaluate {
publishing {
publications {
release(MavenPublication) {
from components.release
groupId = 'io.github.xxxxx' //sonatype平台创建的groupId
artifactId = project.name
version = '1.0.0' //版本,快照版本需要添加后缀 -SNAPSHOT
pom {
name = project.name// 推荐和 artifactId 相同
description = "noting to description"
url = "https://github.com/xxxxx" //项目主页地址,可用 GitHub
licenses {
license {
name = "The Apache License, Version 2.0"
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
}
}
developers {
developer { //随意填开发者信息
id = "**"
name = "****"
email = "******"
}
}
scm {
connection = "scm:svn:http://github.com/xxxx" //项目联系地址
developerConnection = "scm:svn:https://github.com/xxxxx" //项目仓库地址
url = "http://github.com/xxx" //项目主页地址
}
}
}
}
repositories {
maven {
// 名字可随意,会显示在 task 中
name = 'sonatypeRepository'
//url = "https://s01.oss.sonatype.org/content/repositories/snapshots/" //快照上传地址
// url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" 正式服务器
url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
credentials {
//sonatype平台账号密码 密码有特殊字符可用 \ 转义
username = "***"
password = "********"
}
}
}
}
signing {
sign publishing.publications
}
}
终极版配置
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
80
81
82
83
84
apply plugin: 'maven-publish'
apply plugin: 'signing'
task('generateSourcesJar', type: Jar) {
from project.android.sourceSets.main.java.srcDirs
classifier 'sources'
}
task('androidJavadocs', type: Javadoc) {
source = project.android.sourceSets.main.java.srcDirs
failOnError = false
if (JavaVersion.current().isJava8Compatible()) {
project.allprojects {
project.tasks.withType(Javadoc) {
enabled = false
options.addStringOption('Xdoclint:none', '-quiet')
options.setCharSet('UTF-8')
options.setEncoding("UTF-8")
}
}
}
}
task('javadocJar', type: Jar) {
from project.tasks.androidJavadocs
archiveClassifier = 'javadoc'
}
ext["signing.keyId"] = "*****" //GPG指纹后8位
ext["signing.password"] = "*****" //GPG密码
ext["signing.secretKeyRingFile"] = "/xxxxxx/xxxxx/xxxx.gpg" //GPG私钥文件
afterEvaluate {
publishing {
publications {
release(MavenPublication) {
from components.release
groupId = 'io.github.xxxxx' //sonatype平台创建的groupId
artifactId = project.name
version = '1.0.0' //版本,快照版本需要添加后缀 -SNAPSHOT
artifact javadocJar
artifact generateSourcesJar
pom {
name = project.name// 推荐和 artifactId 相同
description = "noting to description"
url = "https://github.com/xxxxx" //项目主页地址,可用 GitHub
licenses {
license {
name = "The Apache License, Version 2.0"
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
}
}
developers {
developer { //随意填开发者信息
id = "**"
name = "****"
email = "******"
}
}
scm {
connection = "scm:svn:http://github.com/xxxx" //项目联系地址
developerConnection = "scm:svn:https://github.com/xxxxx" //项目仓库地址
url = "http://github.com/xxx" //项目主页地址
}
}
}
}
repositories {
maven {
// 名字可随意,会显示在 task 中
name = 'sonatypeRepository'
//url = "https://s01.oss.sonatype.org/content/repositories/snapshots/" //快照上传地址
// url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" 正式服务器
url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
credentials {
//sonatype平台账号密码 密码有特殊字符可用 \ 转义
username = "***"
password = "********"
}
}
}
}
signing {
sign publishing.publications
}
}