-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
146 lines (126 loc) · 4.32 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
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("org.springframework.boot") version "2.5.3"
id("io.spring.dependency-management") version "1.0.11.RELEASE"
kotlin("jvm") version "1.5.21"
kotlin("plugin.spring") version "1.5.21"
kotlin("plugin.serialization") version "1.5.21"
`maven-publish`
}
group = "tech.sharply"
version = "0.2.0"
java.sourceCompatibility = JavaVersion.VERSION_1_8
configurations {
compileOnly {
extendsFrom(configurations.annotationProcessor.get())
}
}
publishing {
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/cosminstn/spring-disruptor-mediatr/")
credentials {
username = project.findProperty("gpr.user") as String? ?: System.getenv("GITHUB_USERNAME")
password =
project.findProperty("gpr.key") as String? ?: System.getenv("GITHUB_PACKAGES_REPOSITORY_TOKEN")
}
}
}
publications {
register<MavenPublication>("gpr") {
from(components["java"])
}
}
}
repositories {
mavenCentral()
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.2.2")
// https://mvnrepository.com/artifact/com.lmax/disruptor
implementation("com.lmax:disruptor:3.4.4")
testImplementation("org.awaitility:awaitility-kotlin:4.1.0")
developmentOnly("org.springframework.boot:spring-boot-devtools")
annotationProcessor("org.springframework.boot:spring-boot-configuration-processor")
testImplementation("org.springframework.boot:spring-boot-starter-test")
}
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "1.8"
}
}
tasks.withType<Test> {
useJUnitPlatform()
}
// region Version Increment
data class Version(
val major: Int,
val minor: Int,
val patch: Int
) {
fun bumpPatch(): Version {
return Version(this.major, this.minor, patch + 1)
}
fun bumpMinor(): Version {
return Version(this.major, this.minor + 1, 0)
}
fun bumpMajor(): Version {
return Version(this.major + 1, 0, 0)
}
override fun toString(): String {
return "$major.$minor.$patch"
}
companion object {
fun versionFromCode(code: String): Version {
val versionParts = code.toLowerCase()
.replace(" ", "")
.replace("version", "")
.replace("snapshot", "")
.replace("-", "")
.split(".")
if (versionParts.size != 3) {
throw IllegalArgumentException(
"Invalid version code! " +
"Must contain major, minor and patch, separated by dots!"
)
}
return Version(versionParts[0].toInt(), versionParts[1].toInt(), versionParts[2].toInt())
}
}
}
tasks.create("bumpPatch") {
doLast {
val currentVersion = Version.versionFromCode(version.toString())
val newVersion = currentVersion.bumpPatch()
println("New version: $newVersion")
val buildFileContent = buildFile.readText()
.replaceFirst("version = \"$currentVersion\"", "version = \"$newVersion\"")
buildFile.writeText(buildFileContent)
}
}
tasks.create("bumpMinor") {
doLast {
val currentVersion = Version.versionFromCode(version.toString())
val newVersion = currentVersion.bumpMinor()
println("New version: $newVersion")
val buildFileContent = buildFile.readText()
.replaceFirst("version = \"$currentVersion\"", "version = \"$newVersion\"")
buildFile.writeText(buildFileContent)
}
}
tasks.create("bumpMajor") {
doLast {
val currentVersion = Version.versionFromCode(version.toString())
val newVersion = currentVersion.bumpMinor()
println("New version: $newVersion")
val buildFileContent = buildFile.readText()
.replaceFirst("version = \"$currentVersion\"", "version = \"$newVersion\"")
buildFile.writeText(buildFileContent)
}
}
// endregion