-
Notifications
You must be signed in to change notification settings - Fork 126
/
publish.gradle
85 lines (79 loc) · 2.62 KB
/
publish.gradle
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
85
//该文件为发布密钥配置
//如果想要本地编译
//可以在最外层目录添加sonatype.gradle文件
//并定义sonatypeUsername和sonatypePassword
apply from: '../../sonatype.gradle'
apply plugin: 'maven-publish'
apply plugin: 'signing'
task sourcesJar(type: Jar) {
from sourceSets.main.allSource
classifier = 'sources'
}
task javadocJar(type: Jar) {
from javadoc
classifier = 'javadoc'
}
publishing {
// 定义发布什么
publications {
mavenJava(MavenPublication) {
// groupId = project.group
// artifactId = project.name
// version = project.version
// groupId,artifactId,version,如果不定义,则会按照以上默认值执行
from components.java
//artifact makeJar
artifact sourcesJar
artifact javadocJar
pom {
// 构件名称
// 区别于artifactId,可以理解为artifactName
name = publishName
// 构件描述
description = publishDescription
// 构件主页
url = 'https://github.com/Linyuzai/concept'
// 许可证名称和地址
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
// 开发者信息
developers {
developer {
name = '黑白法师'
email = '[email protected]'
}
}
// 版本控制仓库地址
scm {
url = 'https://github.com/Linyuzai/concept'
connection = 'scm:git:git://github.com/Linyuzai/concept.git'
developerConnection = 'scm:git:ssh://[email protected]:Linyuzai/concept.git'
}
}
}
}
// 定义发布到哪里
repositories {
maven {
url "https://oss.sonatype.org/service/local/staging/deploy/maven2"
credentials {
// 这里就是之前在issues.sonatype.org注册的账号
username sonatypeUsername
password sonatypePassword
}
}
}
}
signing {
sign publishing.publications.mavenJava
}
javadoc {
// 防止本地打开中文乱码
options.addStringOption("charset", "UTF-8")
options.addStringOption('encoding', 'UTF-8')
options.addStringOption('Xdoclint:none', '-quiet')
}