This repository has been archived by the owner on Oct 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathbuild.gradle
319 lines (274 loc) · 8.57 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
import org.sonarqube.gradle.SonarQubeTask
buildscript {
ext {
//@formatter:off
grgitVersion = '4.+'
sonarqubeVersion = '2.+'
versionsVersion = '0.+'
bintrayVersion = '1.+'
orgJsonVersion = '20190722'
springBootVersion = '[2.2.6.RELEASE, 2.3['
spotbugsVersion = '[4.0.1, 5.0['
annotationsVersion = '[0.0.2, 0.2['
immutablesVersion = '[2.8.3, 3.0['
jcabiVersion = '[1.1, 2.0['
//@formatter:on
}
repositories {
gradlePluginPortal()
mavenCentral()
}
dependencies {
classpath "org.ajoberstar.grgit:grgit-gradle:${grgitVersion}"
classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:${sonarqubeVersion}"
classpath "com.github.ben-manes:gradle-versions-plugin:${versionsVersion}"
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:${bintrayVersion}"
}
configurations.classpath {
resolutionStrategy.activateDependencyLocking()
}
}
apply plugin: 'org.ajoberstar.grgit'
apply plugin: 'com.jfrog.bintray'
apply plugin: 'org.sonarqube'
configure(allprojects.findAll { it.name != 'platform' }) {
apply plugin: 'java-library'
dependencies {
api platform(project(':platform'))
annotationProcessor platform(project(':platform'))
compileOnly platform(project(':platform'))
// annotations
compileOnly 'com.github.spotbugs:spotbugs-annotations'
compileOnly 'space.npstr:annotations'
// immutable objects, to pass values around
compileOnly(group: 'org.immutables', name: 'value', classifier: 'annotations')
annotationProcessor 'org.immutables:value'
//testing
testImplementation 'org.junit.jupiter:junit-jupiter-api'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
testRuntimeOnly 'ch.qos.logback:logback-classic'
}
}
project(':platform') {
apply plugin: 'java-platform'
javaPlatform {
allowDependencies()
}
dependencies {
api platform("org.springframework.boot:spring-boot-dependencies:$springBootVersion")
constraints {
api "com.github.spotbugs:spotbugs-annotations:$spotbugsVersion"
api "org.immutables:value:$immutablesVersion"
api "org.json:json:$orgJsonVersion"
api "space.npstr:annotations:$annotationsVersion"
api "com.jcabi:jcabi-manifests:$jcabiVersion"
}
}
}
dependencies {
api project(':api')
implementation project(':impl')
}
project(':api') {
dependencies {
api platform(project(':platform'))
api 'org.slf4j:slf4j-api'
// project reactor & reactive websocket client
api 'org.springframework:spring-webflux'
api 'io.projectreactor:reactor-core'
}
}
project(':impl') {
dependencies {
implementation platform(project(':platform'))
implementation project(':api')
implementation "org.json:json"
implementation "com.jcabi:jcabi-manifests"
implementation 'io.projectreactor.netty:reactor-netty'
}
}
allprojects {
apply plugin: 'maven-publish'
apply plugin: 'jacoco'
apply plugin: 'com.github.ben-manes.versions'
group = "space.npstr.magma"
version = "${versionFromTag()}"
archivesBaseName = project.name
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_8
repositories {
jcenter()
mavenCentral()
maven { url 'https://jitpack.io' }
}
compileJava {
options.encoding = 'UTF-8'
options.incremental = true
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}
test {
useJUnitPlatform()
jacoco {
includes['space.npstr.magma.*']
}
}
sonarqube {
properties {
property "sonar.inclusions", "**/src/main/java/space/npstr/magma/**/*.java"
}
}
tasks.withType(SonarQubeTask) {
dependsOn jacocoTestReport
}
jacocoTestReport {
reports {
xml.enabled true
}
}
jar {
manifest {
attributes(
'Magma-Version': project.version
)
}
}
publishToMavenLocal.dependsOn jar
task sourceJar(type: Jar) {
from sourceSets.main.allJava
archiveClassifier.set('sources')
}
task javadocJar(type: Jar, dependsOn: javadoc) {
archiveClassifier.set('javadoc')
from javadoc.destinationDir
}
// called by jitpack
task install {
dependsOn test
dependsOn publishToMavenLocal
doLast {
println 'Version: ' + version
}
}
defaultTasks 'build'
publishing {
publications {
mavenJava(MavenPublication) {
if (components.hasProperty('java')) {
from components.java
}
if (components.hasProperty('javaPlatform')) {
from components.javaPlatform
}
afterEvaluate {
groupId project.group
artifactId archivesBaseName
version project.version
}
artifact sourceJar
artifact javadocJar
versionMapping {
allVariants {
fromResolutionResult()
}
}
pom {
name = 'Magma'
description = 'A voice only API for Discord, focused on delivering music at scale.'
url = 'https://github.com/napstr/Magma'
licenses {
license {
name = 'Apache License 2.0'
url = 'https://choosealicense.com/licenses/apache-2.0/'
distribution = 'repo'
}
}
developers {
developer {
name = 'Napster'
email = '[email protected]'
}
}
scm {
url = 'https://github.com/napstr/Magma'
}
}
}
}
}
bintray {
user = this.properties["bintrayUsername"]
key = this.properties["bintrayApiKey"]
publications = ["mavenJava"]
pkg {
repo = "maven"
name = archivesBaseName
licenses = ["Apache-2.0"]
vcsUrl = "https://github.com/napstr/Magma"
githubRepo = "napstr/Magma"
publish = true
version {
name = project.version
vcsTag = project.version
released = new Date()
gpg.sign = true
}
}
}
bintrayUpload {
dependsOn clean
dependsOn build
dependsOn javadocJar
dependsOn sourceJar
build.mustRunAfter clean
}
dependencyUpdates.resolutionStrategy {
componentSelection properReleasesOnly()
}
dependencyLocking {
lockAllConfigurations()
}
// ./gradlew resolveAndLockAll --write-locks
task resolveAndLockAll {
doFirst {
assert gradle.startParameter.writeDependencyLocks
}
doLast {
configurations.all {
resolutionStrategy {
componentSelection properReleasesOnly()
}
}
configurations
.findAll { it.canBeResolved }
.each { it.resolve() }
}
}
}
build {
doLast {
println 'Version: ' + version
}
}
static def properReleasesOnly() {
return { rules ->
rules.all { ComponentSelection selection ->
boolean rejected = ['alpha', 'beta', 'rc', 'preview', 'm1', 'm2', 'm3'].any {
q -> selection.candidate.version.toLowerCase().contains(q)
}
if (rejected) {
selection.reject('Release candidate')
}
}
}
}
//returns either a git tag if there is one on this commit, or the commit hash, to be used as a version
@SuppressWarnings("GrMethodMayBeStatic")
String versionFromTag() {
def headTag = grgit.tag.list().find {
it.commit == grgit.head()
}
if (headTag) {
headTag.getName()
} else {
"${grgit.head().id}"
}
}