-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
175 lines (166 loc) · 4.58 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
plugins {
idea
java
application
kotlin("jvm")
id("org.ajoberstar.reckon")
id("com.github.ben-manes.versions")
id("com.github.johnrengelman.shadow")
}
val mainClass: String by project
val mapDbVersion: String by project
val junit4Version: String by project
val assertjVersion: String by project
val coroutinesVersion: String by project
val javaVersion = JavaVersion.VERSION_1_8
val junitJupiterVersion: String by project
val gradleWrapperVersion: String by project
idea {
module.iml {
beforeMerged(Action<org.gradle.plugins.ide.idea.model.Module> {
dependencies.clear()
})
}
}
allprojects {
apply<JavaLibraryPlugin>()
repositories {
mavenCentral()
}
java {
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
}
dependencies {
implementation(kotlin("stdlib"))
implementation(kotlin("reflect"))
implementation("org.mapdb:mapdb:$mapDbVersion")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion")
testImplementation("org.assertj:assertj-core:$assertjVersion")
testImplementation(platform("org.junit:junit-bom:$junitJupiterVersion"))
testRuntimeOnly("org.junit.vintage:junit-vintage-engine")
testImplementation("org.junit.jupiter:junit-jupiter")
testImplementation("junit:junit:$junit4Version")
}
sourceSets {
main {
java.srcDir("src/main/kotlin")
}
test {
java.srcDir("src/test/kotlin")
}
}
application {
mainClassName = mainClass
}
tasks {
// register("fatJar", Jar::class.java) {
// //archiveAppendix.set("all")
// archiveClassifier.set("all")
// duplicatesStrategy = DuplicatesStrategy.EXCLUDE
// manifest {
// attributes("Main-Class" to mainClass)
// }
// from(configurations.runtimeClasspath.get()
// .onEach { println("add from dependencies: ${it.name}") }
// .map { if (it.isDirectory) it else zipTree(it) })
// val sourcesMain = sourceSets.main.get()
// sourcesMain.allSource.forEach { println("add from sources: ${it.name}") }
// from(sourcesMain.output)
// }
withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
kotlinOptions {
freeCompilerArgs += "-Xjsr305=strict"
jvmTarget = "$javaVersion"
}
}
withType<Test> {
// useJUnit()
// useJUnitPlatform()
useJUnitPlatform {
includeEngines("junit-jupiter", "junit-vintage")
}
systemProperties["sleep"] = System.getProperty("sleep") ?: "10"
testLogging {
showCauses = true
showExceptions = true
showStackTraces = true
showStandardStreams = true
events(
org.gradle.api.tasks.testing.logging.TestLogEvent.PASSED,
org.gradle.api.tasks.testing.logging.TestLogEvent.SKIPPED,
org.gradle.api.tasks.testing.logging.TestLogEvent.FAILED
)
}
}
named("clean") {
doLast {
delete(
project.buildDir,
"${project.projectDir}/out"
)
}
}
}
}
tasks {
create<Zip>("sources") {
dependsOn("clean")
shouldRunAfter("clean", "assemble")
description = "Archives sources in a zip file"
group = "Archive"
from("src") {
into("src")
}
from(".github") {
into(".github")
}
from("gradle") {
into("gradle")
}
from(".gitattributes")
from(".gitignore")
from("gradlew")
from("gradlew.bat")
from("gradle.properties")
from("build.gradle.kts")
from("README.md")
from("settings.gradle.kts")
lateinit var ver: String
doFirst {
ver = project.version.toString()
archiveFileName.set("$buildDir/sources-$ver.zip")
println("creation $ver ${archiveFileName.get()}")
}
}
withType(Wrapper::class.java) {
gradleVersion = gradleWrapperVersion
distributionType = Wrapper.DistributionType.ALL
// distributionType = Wrapper.DistributionType.BIN
}
}
// defaultTasks("clean", "sources", "fatJar", "installDist")
defaultTasks("clean", "test", "sources", "shadowJar", "installDist")
reckon {
scopeFromProp()
// stageFromProp()
snapshotFromProp()
}
tasks {
register("version") {
println(project.version.toString())
}
register("status") {
doLast {
val status = grgit.status()
status?.let { s ->
println("workspace is clean: ${s.isClean}")
if (!s.isClean) {
if (s.unstaged.allChanges.isNotEmpty()) {
println("""all unstaged changes: ${s.unstaged.allChanges.joinToString(separator = "") { i -> "\n - $i" }}""")
}
}
}
}
}
}