-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
143 lines (112 loc) · 3.78 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
buildscript {
ext.kotlin_coroutines = '1.2.2'
ext.kotlin_version = '1.3.50'
ext.vertx_version = '3.7.1'
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:5.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
def versionObj = new Version(major: 0, minor: 1, revision: 0)
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'kotlin'
allprojects {
group 'chat.union.apiengine'
version versionObj.toString()
}
repositories {
mavenCentral()
jcenter()
maven { url 'https://jitpack.io' }
maven { url "https://dl.bintray.com/kotlin/ktor" }
}
configurations { ktlint }
dependencies {
ktlint "com.pinterest:ktlint:0.33.0"
implementation 'io.sentry:sentry-logback:1.7.23'
implementation 'ch.qos.logback:logback-classic:1.2.3'
implementation 'org.reflections:reflections:0.9.11'
implementation 'xyz.bowser65:Tokenize:d4490a06a4'
implementation 'de.mkammerer:argon2-jvm:2.5'
// The MongoDB drivers are literal trash. Async driver is deprecated, reactivestreams is painful
// to use and sync driver is sync, but at least "usable". @devoxin make Kongo a thing when:tm:
implementation 'org.mongodb:mongodb-driver-sync:3.10.2'
implementation 'io.lettuce:lettuce-core:5.1.7.RELEASE'
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:$kotlin_coroutines"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
// --- Web servers pre-made adapters ---
// Vert.x
compileOnly "io.vertx:vertx-web:$vertx_version"
compileOnly "io.vertx:vertx-lang-kotlin:$vertx_version"
compileOnly "io.vertx:vertx-lang-kotlin-coroutines:$vertx_version"
// Ktor
}
compileKotlin {
kotlinOptions.jvmTarget = JavaVersion.VERSION_1_8
}
compileTestKotlin {
kotlinOptions.jvmTarget = JavaVersion.VERSION_1_8
}
task ktlint(type: JavaExec, group: "verification") {
description = "Check Kotlin code style."
classpath = configurations.ktlint
main = "com.pinterest.ktlint.Main"
args "src/**/*.kt"
}
task ktlintFormat(type: JavaExec, group: "formatting") {
description = "Fix Kotlin code style deviations."
classpath = configurations.ktlint
main = "com.pinterest.ktlint.Main"
args "-F", "src/**/*.kt"
}
import org.apache.tools.ant.filters.ReplaceTokens
//noinspection GroovyAssignabilityCheck
task sourcesForRelease(type: Copy) {
outputs.upToDateWhen { false }
from('src/main/kotlin') {
include '**/Version.java'
filter(ReplaceTokens, tokens: [
VERSION_MAJOR : versionObj.major,
VERSION_MINOR : versionObj.minor,
VERSION_REVISION: versionObj.revision,
COMMIT : getCommitHash(),
])
}
into 'build/filteredSrc'
includeEmptyDirs = false
}
//noinspection GroovyAssignabilityCheck
task generateJavaSources(type: SourceTask) {
outputs.upToDateWhen { false }
def javaSources = sourceSets.main.allJava.filter {
it.name != 'Version.java'
}
source = javaSources + sourcesForRelease.destinationDir
dependsOn sourcesForRelease
}
compileJava {
outputs.upToDateWhen { false }
source = generateJavaSources.source
dependsOn generateJavaSources
}
shadowJar {
version = versionObj.toString()
}
class Version {
String major, minor, revision
String toString() {
"$major.$minor.$revision"
}
}
static def getCommitHash() {
def p = Runtime.getRuntime().exec("git rev-parse HEAD")
p.waitFor()
p.getIn().text.trim()
}
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8