-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle.kts
200 lines (171 loc) · 6.37 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
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
import org.hibernate.build.publish.auth.maven.MavenRepoAuthPlugin
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
plugins {
java
id("com.github.ben-manes.versions") version Versions.VERSIONS_PLUGIN
id("org.jlleitschuh.gradle.ktlint") version Versions.KTLINT_PLUGIN
kotlin("jvm") version Versions.KOTLIN
kotlin("plugin.serialization") version Versions.KOTLIN
id("maven-publish")
id("signing")
id("org.hibernate.build.maven-repo-auth") version Versions.MAVEN_REPO_AUTH_PLUGIN apply false
}
if (!project.hasProperty("isGithubActions")) {
// only use this plugin if we're running locally, not on github.
apply<MavenRepoAuthPlugin>()
}
group = "io.newm"
version = "2.3.2-SNAPSHOT"
java.sourceCompatibility = JavaVersion.VERSION_21
java.targetCompatibility = JavaVersion.VERSION_21
repositories {
mavenLocal()
mavenCentral()
maven {
name = "jitpack.io"
url = uri("https://jitpack.io")
}
}
dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:${Versions.KOTLIN}")
implementation("io.ktor:ktor-client-websockets:${Versions.KTOR}")
implementation("io.ktor:ktor-client-cio-jvm:${Versions.KTOR}")
implementation("commons-logging:commons-logging:${Versions.COMMONS_LOGGING}")
implementation("ch.qos.logback:logback-classic:${Versions.LOGBACK}")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:${Versions.COROUTINES}")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:${Versions.COROUTINES}")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:${Versions.KOTLINX_SERIALIZATION}")
implementation("org.jetbrains.kotlinx:kotlinx-datetime:${Versions.KOTLINX_DATETIME}")
implementation("org.apache.commons:commons-numbers-fraction:${Versions.COMMONS_NUMBERS}")
testImplementation("io.mockk:mockk:${Versions.MOCKK}")
testImplementation("com.google.truth:truth:${Versions.GOOGLE_TRUTH}")
testImplementation("org.junit.jupiter:junit-jupiter:${Versions.JUNIT}")
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:${Versions.COROUTINES}")
}
ktlint {
version.set(Versions.KTLINT)
}
tasks {
val sourcesJar by registering(Jar::class) {
archiveClassifier.set("sources")
dependsOn("classes")
from(sourceSets["main"].allSource)
}
val javadocJar by registering(Jar::class) {
archiveClassifier.set("javadoc")
dependsOn("javadoc")
from("${layout.buildDirectory}/javadoc")
}
artifacts {
archives(javadocJar)
archives(sourcesJar)
}
assemble {
dependsOn("sourcesJar", "javadocJar")
}
}
publishing {
repositories {
maven {
name = "ossrh"
val releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
val snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
if (project.hasProperty("release")) {
setUrl(releasesRepoUrl)
} else {
setUrl(snapshotsRepoUrl)
}
}
}
publications {
create<MavenPublication>("mavenKotlin") {
from(components["kotlin"])
artifact(tasks["sourcesJar"])
artifact(tasks["javadocJar"])
pom {
groupId = "io.newm"
artifactId = "kogmios"
name.set("Kogmios")
description.set("Kotlin Wrapper for Ogmios")
url.set("https://github.com/projectNEWM/kogmios")
licenses {
license {
name.set("Apache 2.0")
url.set("https://github.com/projectNEWM/kogmios/blob/master/LICENSE")
}
}
developers {
developer {
id.set("AndrewWestberg")
name.set("Andrew Westberg")
email.set("[email protected]")
organization.set("NEWM")
organizationUrl.set("https://newm.io")
}
}
scm {
connection.set("scm:git:git://github.com/projectNEWM/kogmios.git")
developerConnection.set("scm:git:ssh://github.com/projectNEWM/kogmios.git")
url.set("https://github.com/projectNEWM/kogmios")
}
}
}
}
}
signing {
useGpgCmd()
sign(publishing.publications["mavenKotlin"])
}
fun isNonStable(version: String): Boolean {
val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.uppercase().contains(it) }
val regex = "^[0-9,.v-]+(-r)?$".toRegex()
val isStable = stableKeyword || regex.matches(version)
return isStable.not()
}
tasks.withType<Test> {
useJUnitPlatform()
}
tasks.withType<DependencyUpdatesTask> {
// Example 1: reject all non stable versions
rejectVersionIf {
isNonStable(candidate.version)
}
// Example 2: disallow release candidates as upgradable versions from stable versions
rejectVersionIf {
isNonStable(candidate.version) && !isNonStable(currentVersion)
}
// Example 3: using the full syntax
resolutionStrategy {
componentSelection {
all {
if (isNonStable(candidate.version) && !isNonStable(currentVersion)) {
reject("Release candidate")
}
}
}
}
}
project.tasks.withType<org.jetbrains.kotlin.gradle.tasks.UsesKotlinJavaToolchain>().configureEach {
val service = project.extensions.getByType<JavaToolchainService>()
val customLauncher =
service.launcherFor {
this.languageVersion.set(JavaLanguageVersion.of(JavaVersion.VERSION_17.majorVersion))
}
this.kotlinJavaToolchain.toolchain.use(customLauncher)
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
compilerOptions {
freeCompilerArgs =
listOf(
"-Xjsr305=strict",
"-opt-in=kotlin.RequiresOptIn",
"-opt-in=kotlinx.serialization.ExperimentalSerializationApi",
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
)
jvmTarget.set(JvmTarget.JVM_21)
}
}
tasks.withType<Test> {
maxHeapSize = "8192m"
}