-
Notifications
You must be signed in to change notification settings - Fork 0
/
publish.gradle
112 lines (98 loc) · 2.71 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
102
103
104
105
106
107
108
109
110
111
112
apply plugin: 'maven-publish'
apply plugin: 'signing'
/*
1. Create request in
https://issues.sonatype.org/secure/CreateIssue.jspa?issuetype=21&pid=10134
2. Close and Release in
https://oss.sonatype.org/#stagingRepositories
3. Or Snapshot
https://oss.sonatype.org/#view-repositories;snapshots~browsestorage~org/dreamcat/
*/
def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
def isReleaseVersion = !version.endsWith("SNAPSHOT")
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
tasks.withType(Javadoc) {
options.encoding = "UTF-8"
}
tasks.withType(Sign) {
onlyIf { isReleaseVersion }
}
task sourcesJar(type: Jar) {
archiveClassifier.set 'sources'
from sourceSets.main.allJava
}
task javadocJar(type: Jar) {
archiveClassifier.set 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives javadocJar, sourcesJar
}
def pomConfig = {
licenses {
license {
name LICENCE_NAME
url LICENCE_URL
distribution LICENCE_DIST
}
}
developers {
developer {
id DEVELOPER_ID
name DEVELOPER_NAME
email DEVELOPER_EMAIL
}
}
scm {
url PROJECT_URL
}
}
publishing {
publications {
mavenJava(MavenPublication) {
// components.web for war
from components.java
artifact sourcesJar
artifact javadocJar
versionMapping {
usage('java-api') {
fromResolutionOf('runtimeClasspath')
}
usage('java-runtime') {
fromResolutionResult()
}
}
groupId project.group
artifactId project.name
version project.version
pom.withXml {
def root = asNode()
root.appendNode('name', project.name)
root.appendNode('url', PROJECT_URL)
root.appendNode('description', PROJECT_DESCRIPTION)
root.children().last() + pomConfig
}
}
}
repositories {
maven {
url isReleaseVersion ? releasesRepoUrl : snapshotsRepoUrl
credentials {
username project.findProperty("oss.username") as String
password project.findProperty("oss.password") as String
}
}
}
}
signing {
required { isReleaseVersion && gradle.taskGraph.hasTask("publish") }
sign publishing.publications.mavenJava
}
javadoc {
if (JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption('html5', true)
}
}