-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
164 lines (135 loc) · 3.61 KB
/
build.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
buildscript {
dependencies {
classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.5.3"
}
}
plugins {
id 'net.researchgate.release' version '2.2.0'
}
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'signing'
apply plugin: 'io.codearte.nexus-staging'
targetCompatibility = "1.7"
sourceCompatibility = "1.7"
def gitpath = "github.com/${githubUser}/${archivesBaseName}.git"
release {
tagPrefix = group
}
configurations {
archives
provided {
dependencies.all { dep ->
configurations.default.exclude group: dep.group, module: dep.name
}
}
compile.extendsFrom provided
}
repositories {
mavenCentral()
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
if (JavaVersion.current().isJava8Compatible()) {
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
}
}
}
if (!hasProperty('nexusUsername')) {
ext.nexusUsername = ''
ext.nexusPassword = ''
}
task checkReleaseConfig(dependsOn: clean) << {
def requiredConfigs= ['nexusPassword', 'nexusUsername', 'signing.password', 'signing.keyId', 'signing.secretKeyRingFile']
def notFoundProperties = requiredConfigs.findAll {
!project.hasProperty(it) || !project.getProperties()[it]
}
if (notFoundProperties) {
throw new GradleException("""
Not found properties: ${notFoundProperties}
The following is needed to upload (put in ~/.gradle/gradle.properties)
nexusUsername=<login for https://oss.sonatype.org/>
nexusPassword=<password for https://oss.sonatype.org/>
signing.password=<password for gpg key>
signing.keyId=<keyId>
signing.secretKeyRingFile=<path to secring.gpg>
""")
}
}
artifacts {
archives sourcesJar
archives javadocJar
}
signing {
required { false }
sign configurations.archives
}
dependencies {
provided 'com.squareup.okhttp:okhttp:2.5.0'
provided 'com.squareup.okhttp3:okhttp:3.5.0'
compile 'com.google.code.gson:gson:2.3.1'
provided 'org.apache.logging.log4j:log4j-core:2.7'
testCompile 'org.apache.logging.log4j:log4j-core:2.7'
testCompile 'junit:junit:4.10'
}
uploadArchives {
repositories {
mavenDeployer {
pom.artifactId = project.name
configuration = configurations.archives
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: nexusUsername, password: nexusPassword)
}
pom.project {
url 'http://${gitpath}'
inceptionYear '2015'
name archivesBaseName
description project.description
scm {
url "scm:git:https://${gitpath}"
connection "scm:git:ssh://git@${gitpath}"
}
licenses {
license {
name 'MIT'
comments new File(rootDir, 'LICENSE').getText()
url 'https://opensource.org/licenses/MIT'
distribution 'repo'
}
}
developers {
developer {
id 'tobias-'
name 'Tobias Olsson'
email '[email protected]'
}
}
}
pom.packaging = 'jar'
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
}
}
}
nexusStaging {
username = nexusUsername
password = nexusPassword
}
closeRepository.dependsOn uploadArchives
createReleaseTag.dependsOn closeAndPromoteRepository
checkCommitNeeded.dependsOn checkReleaseConfig
test {
[ "SLACK_WEBHOOK" ].each { envVar ->
if (project.hasProperty(envVar)) {
jvmArgs "-D${envVar}=${project.getProperty(envVar)}"
} else if (!System.env[envVar]) {
logger.warn("Didn't find ${envVar} property. This means tests will probably fail")
}
}
}