forked from schnapster/Magma
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
195 lines (164 loc) · 5.4 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
buildscript {
ext {
grgitVersion = '2.3.0'
aptPluginVersion = '0.18'
sonarqubeVersion = '2.6.2'
}
repositories {
maven { url 'https://plugins.gradle.org/m2/' }
mavenCentral()
}
dependencies {
classpath "org.ajoberstar:grgit:${grgitVersion}"
classpath "net.ltgt.gradle:gradle-apt-plugin:${aptPluginVersion}"
classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:${sonarqubeVersion}"
}
}
apply plugin: 'idea'
apply plugin: 'java'
apply plugin: 'java-library'
apply plugin: 'maven-publish'
apply plugin: 'org.ajoberstar.grgit'
apply plugin: 'net.ltgt.apt-idea'
apply plugin: 'jacoco'
apply plugin: 'org.sonarqube'
group = "space.npstr.magma"
version = "${versionFromTag()}"
sourceCompatibility = 10
targetCompatibility = 10
repositories {
jcenter()
mavenCentral()
maven { url 'https://jitpack.io' }
}
ext {
//@formatter:off
gradleVersion = '4.9'
orgJsonVersion = '20180130'
slf4jVersion = '1.7.25'
springVersion = '5.0.8.RELEASE'
undertowVersion = '2.0.11.Final'
spotbugsVersion = '3.1.6'
annotationsVersion = '0.0.1'
immutablesVersion = '2.6.3'
junitVersion = '5.2.0'
logbackVersion = '1.2.3'
//@formatter:on
}
dependencies {
//@formatter:off
compile group: 'org.json', name: 'json', version: orgJsonVersion
compile group: 'org.slf4j', name: 'slf4j-api', version: slf4jVersion
// project reactor & reactive websocket client
compile group: 'org.springframework', name: 'spring-webflux', version: springVersion
compile group: 'io.undertow', name: 'undertow-core', version: undertowVersion
// annotations
compileOnly group: 'com.github.spotbugs', name: 'spotbugs-annotations', version: spotbugsVersion
compileOnly group: 'space.npstr', name: 'annotations', version: annotationsVersion
// immutable objects, to pass values around
annotationProcessor group: 'org.immutables', name: 'value', version: immutablesVersion
compileOnly group: 'org.immutables', name: 'value', version: immutablesVersion, classifier: 'annotations'
// testing
testCompile group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: junitVersion
testRuntime group: 'ch.qos.logback', name: 'logback-classic', version: logbackVersion
testRuntime group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: junitVersion
//@formatter:on
}
compileJava {
dependsOn(clean)
options.encoding = 'UTF-8'
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}
wrapper {
gradleVersion = project.ext.gradleVersion
//noinspection UnnecessaryQualifiedReference
distributionType = Wrapper.DistributionType.ALL
}
build {
doLast {
println 'Version: ' + version
}
}
test {
useJUnitPlatform()
jacoco {
includes['space.npstr.magma.*']
}
}
sonarqube {
properties {
property "sonar.inclusions", "src/main/java/space/npstr/magma/**/*"
}
}
jar.mustRunAfter clean
publishToMavenLocal.dependsOn jar
// called by jitpack
task install {
dependsOn test
dependsOn publishToMavenLocal
doLast {
println 'Version: ' + version
}
}
task sourceJar(type: Jar) {
from sourceSets.main.allJava
classifier 'sources'
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact sourceJar
groupId project.group
artifactId project.name
version project.version
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'
}
}
}
}
}
idea {
project {
configureAnnotationProcessing = true
}
module {
apt {
addGeneratedSourcesDirs = true
addAptDependencies = true
addCompileOnlyDependencies = false
mainDependenciesScope = 'PROVIDED'
}
}
}
//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()
}
def clean = grgit.status().clean //uncommited changes? -> should be SNAPSHOT
if (headTag && clean) {
headTag.getName()
} else {
"${grgit.head().id}-SNAPSHOT"
}
}