This repository was archived by the owner on May 21, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
201 lines (158 loc) · 5.51 KB
/
build.gradle.kts
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
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.gradle.api.JavaVersion.VERSION_1_8
import org.gradle.api.publish.PublishingExtension
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.jvm.tasks.Jar
import org.gradle.kotlin.dsl.withType
import org.gradle.testing.jacoco.plugins.JacocoPluginExtension
import org.gradle.testing.jacoco.tasks.JacocoReport
import org.jooq.util.GenerationTool
import org.jooq.util.jaxb.*
import org.jooq.util.jaxb.Target
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.flywaydb.gradle.FlywayExtension
import org.slf4j.LoggerFactory
val hopperVersion by project
val kotlinVersion by project
buildscript {
val kotlinBuildScriptVersion = "1.1.51"
repositories {
jcenter()
mavenCentral()
maven(url = "https://plugins.gradle.org/m2/")
}
dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinBuildScriptVersion")
classpath("com.github.jengelman.gradle.plugins:shadow:1.2.3")
classpath("nu.studer:gradle-jooq-plugin:2.0.7")
classpath("org.xerial:sqlite-jdbc:3.16.1")
classpath("gradle.plugin.com.boxfuse.client:flyway-release:4.2.0")
}
}
plugins {
kotlin("jvm") version "1.1.51"
application
}
apply {
plugin("com.github.johnrengelman.shadow")
plugin("jacoco")
plugin("maven-publish")
plugin("nu.studer.jooq")
plugin("org.flywaydb.flyway")
}
java {
sourceCompatibility = VERSION_1_8
targetCompatibility = VERSION_1_8
sourceSets["main"].java.srcDirs.add(File("src/generated/java"))
}
val buildNumberAddition = if(project.hasProperty("BUILD_NUMBER")) { ".${project.property("BUILD_NUMBER")}" } else { "" }
version = "$hopperVersion$buildNumberAddition"
group = "chat.willow.hopper"
val projectTitle = "Hopper"
val mainClass = "$group.$projectTitle"
project.setProperty("archivesBaseName", projectTitle)
application {
mainClassName = mainClass
}
repositories {
jcenter()
maven { setUrl("https://maven.ci.carrot.codes/") }
maven { setUrl("https://oss.sonatype.org/content/repositories/snapshots") }
}
dependencies {
compile(kotlin("stdlib"))
compile("org.slf4j:slf4j-api:1.7.25")
compile("org.slf4j:slf4j-simple:1.7.25")
compile("com.google.guava:guava:22.0")
compile("com.sparkjava:spark-core:2.6.0")
compile("chat.willow.warren:Warren:2.1.1.7")
compile("com.squareup.moshi:moshi:1.5.0")
compile("com.squareup.moshi:moshi-kotlin:1.5.0")
compile("org.xerial:sqlite-jdbc:3.16.1")
compile("org.jooq:jooq")
compile("org.flywaydb:flyway-core:4.2.0")
testCompile("junit:junit:4.12")
testCompile("org.mockito:mockito-core:2.7.21")
testCompile("com.nhaarman:mockito-kotlin:1.4.0")
}
task(name = "generateJooq") {
val configuration = Configuration().apply {
jdbc = Jdbc().apply {
driver = "org.sqlite.JDBC"
url = "jdbc:sqlite:run/hopper.db"
}
generator = Generator().apply {
name = "org.jooq.util.DefaultGenerator"
strategy = Strategy().apply {
name = "org.jooq.util.DefaultGeneratorStrategy"
}
target = Target().apply {
packageName = "chat.willow.hopper.generated"
directory = "src/main/java/"
}
database = Database().apply {
name = "org.jooq.util.sqlite.SQLiteDatabase"
includes = ".*"
excludes = ""
}
}
}
if (File("run/hopper.db").exists()) {
GenerationTool.generate(configuration)
} else {
LoggerFactory.getLogger("generateJooq").warn("run/hopper.db doesn't exist, so not running JOOQ generation")
}
}
configure<JacocoPluginExtension> {
toolVersion = "0.7.9"
}
tasks.withType<JacocoReport> {
classDirectories = fileTree("build/classes/main").apply {
// Exclude well known data classes that should contain no logic
// Remember to change values in codecov.yml too
exclude("**/*Event.*")
exclude("**/*State.*")
exclude("**/*Configuration.*")
exclude("**/*Runner.*")
exclude("**/generated/*")
}
reports.xml.isEnabled = true
reports.html.isEnabled = true
}
val shadowJars = tasks.withType<ShadowJar> {
mergeServiceFiles()
exclude("META-INF/*.DSA")
exclude("META-INF/*.RSA")
manifest.attributes.apply {
put("Main-Class", mainClass)
}
}
configure<FlywayExtension> {
driver = "org.sqlite.JDBC"
url = "jdbc:sqlite:run/hopper.db"
locations = arrayOf("filesystem:src/main/resources/db/migration")
}
val sourcesJar = task<Jar>("sourcesJar") {
dependsOn("classes")
from(java.sourceSets["main"].allSource)
classifier = "sources"
}
project.artifacts.add("archives", sourcesJar)
project.artifacts.add("archives", shadowJars.first())
configure<PublishingExtension> {
val deployUrl = if (project.hasProperty("DEPLOY_URL")) { project.property("DEPLOY_URL") } else { project.buildDir.absolutePath }
this.repositories.maven({ setUrl("$deployUrl") })
publications {
create<MavenPublication>("mavenJava") {
from(components.getByName("java"))
artifact(sourcesJar)
artifact(shadowJars.first())
artifactId = projectTitle
}
}
}
fun kotlin(module: String, version: String = kotlinVersion as String) = "org.jetbrains.kotlin:kotlin-$module:$version"
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
kotlinOptions.apiVersion = "1.1"
}