forked from briandilley/jsonrpc4j
-
Notifications
You must be signed in to change notification settings - Fork 2
/
publishing.gradle
129 lines (115 loc) · 4.73 KB
/
publishing.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
import io.codearte.gradle.nexus.BaseStagingTask
import io.codearte.gradle.nexus.NexusStagingPlugin
import javax.naming.ConfigurationException
buildscript {
repositories {
gradlePluginPortal()
}
dependencies {
classpath 'io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.11.0'
classpath 'gradle.plugin.net.wooga.gradle:atlas-github:1.0.1'
classpath 'net.researchgate:gradle-release:2.7.0'
classpath 'org.ajoberstar:grgit:2.3.0'
classpath 'org.kohsuke:github-api:1.93'
}
}
ext {
it.'signing.secretKeyRingFile' = project.findProperty('jsonrpc4j.signing.secretKeyRingFile') ?:
project.findProperty('signing.secretKeyRingFile')
it.'signing.password' = project.findProperty('jsonrpc4j.signing.password') ?:
project.findProperty('signing.password')
it.'signing.keyId' = project.findProperty('jsonrpc4j.signing.keyId') ?:
project.findProperty('signing.keyId')
sonatypeUsername = project.findProperty('jsonrpc4j.sonatype.username') ?:
project.findProperty('sonatype.username')
sonatypePassword = project.findProperty('jsonrpc4j.sonatype.password') ?:
project.findProperty('sonatype.password')
sonatypeStagingProfileId = project.findProperty('jsonrpc4j.sonatype.stagingProfileId') ?:
project.findProperty('sonatype.stagingProfileId')
it.'github.token' = project.findProperty('jsonrpc4j.github.token') ?:
project.findProperty('github.token')
}
allprojects {
apply plugin: 'maven-publish'
publishing {
repositories {
maven {
name 'sonatype'
if (releaseVersion) {
url 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
} else {
url 'https://oss.sonatype.org/content/repositories/snapshots/'
}
credentials {
username sonatypeUsername
password sonatypePassword
}
}
}
}
tasks.withType(PublishToMavenRepository) {
doFirst {
if (!sonatypeUsername) {
throw new ConfigurationException(
'Please set the Sonatype username with project property "sonatype.username" ' +
'or "jsonrpc4j.sonatype.username". If both are set, the latter will be effective.')
}
if (!sonatypePassword) {
throw new ConfigurationException(
'Please set the Sonatype password with project property "sonatype.password" ' +
'or "jsonrpc4j.sonatype.password". If both are set, the latter will be effective.')
}
}
}
}
publishing {
publications {
jsonrpc4j(MavenPublication) {
from components.java
artifact documentationJar
artifact sourcesJar
}
}
}
apply from: 'pom.gradle'
allprojects {
apply plugin: 'signing'
signing {
required {
// signing is required if this is a release version and the artifacts are to be published
releaseVersion && tasks.withType(PublishToMavenRepository).find {
gradle.taskGraph.hasTask it
}
}
sign publishing.publications
}
}
apply plugin: NexusStagingPlugin
// remove superfluous tasks from NexusStagingPlugin
//tasks.removeAll([promoteRepository, closeAndPromoteRepository, getStagingProfile])
nexusStaging {
stagingProfileId sonatypeStagingProfileId
username sonatypeUsername
password sonatypePassword
}
// make sure the staging tasks are run after any publishing tasks if both are to be run
tasks.withType(BaseStagingTask) {
mustRunAfter allprojects.tasks*.withType(PublishToMavenRepository)
doFirst {
if (!sonatypeStagingProfileId) {
throw new ConfigurationException(
'Please set the Sonatype staging profile id with project property "sonatype.stagingProfileId" ' +
'or "jsonrpc4j.sonatype.stagingProfileId". If both are set, the latter will be effective.')
}
if (!sonatypeUsername) {
throw new ConfigurationException(
'Please set the Sonatype username with project property "sonatype.username" ' +
'or "jsonrpc4j.sonatype.username". If both are set, the latter will be effective.')
}
if (!sonatypePassword) {
throw new ConfigurationException(
'Please set the Sonatype password with project property "sonatype.password" ' +
'or "jsonrpc4j.sonatype.password". If both are set, the latter will be effective.')
}
}
}