-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathplugin_maven_publish_jar.gradle
79 lines (72 loc) · 2.23 KB
/
plugin_maven_publish_jar.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
apply plugin: 'maven-publish'
apply plugin: 'signing'
// 设置group和版本名称
group = LIB_GROUP
version = LIB_VERSION
// 如何配置,参考文档:https://developer.android.com/studio/publish-library
java {
withJavadocJar()
withSourcesJar()
}
def LIB_ARTIFACT = project.name
println("LIB_ARTIFACT = $LIB_ARTIFACT")
publishing {
publications {
// release:自定义发布产物名称
release(MavenPublication) {
afterEvaluate {
from components.java
}
versionMapping {
usage('java-api') {
fromResolutionOf('runtimeClasspath')
}
usage('java-runtime') {
fromResolutionResult()
}
}
artifactId = LIB_ARTIFACT
pom {
name = LIB_ARTIFACT
description = LIB_DES
url = LIB_URL
licenses {
license {
name = LICENSE_NAME
url = LICENSE_URL
distribution = LICENSE_DIST
}
}
developers {
developer {
name = DEVELOPER_NAME
email = DEVELOPER_EMAIL
}
}
scm {
url = SCM_URL
}
}
}
}
repositories {
maven {
// change URLs to point to your repos, e.g. http://my.org/repo
def releasesRepoUrl = 'https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/'
def snapshotsRepoUrl = 'https://s01.oss.sonatype.org/content/repositories/snapshots/'
def mavenUrl = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
url = mavenUrl
println("publish to mavenUrl=$mavenUrl")
// 校验不支持本地文件目录
if (mavenUrl.startsWith("https")) {
credentials {
username = ossrhUsername
password = ossrhPassword
}
}
}
}
}
signing {
sign publishing.publications.release
}