-
Notifications
You must be signed in to change notification settings - Fork 0
/
publish.gradle
101 lines (86 loc) · 2.85 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
// maven发布
apply plugin: 'maven-publish'
apply plugin: 'signing'
def mavenPropertiesFile = file('local.properties')
def mavenProperties = new Properties()
mavenProperties.load(new FileInputStream(mavenPropertiesFile))
def PUBLISH_GROUP_ID = mavenProperties['publish.groupId']
def PUBLISH_ARTIFACT_ID = mavenProperties['publish.artifactId']
def PUBLISH_DESCRIPTION = mavenProperties['publish.description']
def PROJECT_MAIN_URL = mavenProperties['project.mainUrl']
def PROJECT_GIT_URL = mavenProperties['project.gitUrl']
def DEVELOPER_NAME = mavenProperties['developer.name']
def DEVELOPER_EMAIL = mavenProperties['developer.email']
def LICENSE_NAME = mavenProperties['license.name']
def LICENSE_URL = mavenProperties['license.url']
def MAVEN_UPLOAD_URL = mavenProperties['maven.uploadUrl']
def MAVEN_USERNAME = mavenProperties['maven.username']
def MAVEN_PASSWORD = mavenProperties['maven.password']
java {
withJavadocJar()
withSourcesJar()
}
publishing {
// 定义发布什么
publications {
mavenJava(MavenPublication) {
// groupId,artifactId,version,如果不定义,则会使用项目默认配置
groupId = PUBLISH_GROUP_ID
artifactId = PUBLISH_ARTIFACT_ID
// version = project.version
from components.java
pom {
// 构件名称
// 区别于artifactId,可以理解为artifactName
name = project.name
// 构件描述
description = PUBLISH_DESCRIPTION
// 构件主页
url = PROJECT_MAIN_URL
// 许可证名称和地址
licenses {
license {
name = LICENSE_NAME
url = LICENSE_URL
}
}
// 开发者信息
developers {
developer {
name = DEVELOPER_NAME
email = DEVELOPER_EMAIL
}
}
// 版本控制仓库地址
scm {
url = PROJECT_MAIN_URL
connection = PROJECT_GIT_URL
developerConnection = PROJECT_GIT_URL
}
}
}
}
// 定义发布到哪里
repositories {
maven {
url MAVEN_UPLOAD_URL
credentials {
// issues.sonatype.org的账号
username MAVEN_USERNAME
password MAVEN_PASSWORD
}
}
}
}
// 签名
signing {
useGpgCmd()
sign publishing.publications.mavenJava
}
javadoc {
if (JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption('html5', true)
}
// 防止本地打开中文乱码
options.addStringOption("charset", "UTF-8")
}