-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
194 lines (162 loc) · 4.73 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
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
/////////////
// PLUGINS //
/////////////
plugins {
id "org.jetbrains.kotlin.jvm" version "1.6.10"
id "java-library"
id "maven-publish"
id "signing"
id "jacoco"
id "org.jlleitschuh.gradle.ktlint" version "10.2.1"
id "io.gitlab.arturbosch.detekt" version "1.19.0"
id "com.github.ben-manes.versions" version "0.41.0"
}
//////////////////
// DEPENDENCIES //
//////////////////
repositories {
mavenCentral()
}
ext {
ktorVersion = "1.6.7"
}
dependencies {
// KOTLIN
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
implementation "org.jetbrains.kotlin:kotlin-reflect"
// KTOR
implementation "com.koriit.kotlin:ktor-controllers:0.7.0"
implementation "io.ktor:ktor-server-core:$ktorVersion"
implementation "io.ktor:ktor-server-host-common:$ktorVersion"
// OpenAPI
// the matcher part of this library is only for test use
// the matcher dependencies should not be included at all times
compileOnly "com.koriit.kotlin:openapi-matcher:0.7.0"
testImplementation "com.koriit.kotlin:openapi-matcher:0.7.0"
// TESTING
testImplementation "org.junit.jupiter:junit-jupiter:5.8.2"
testImplementation "io.ktor:ktor-server-test-host:$ktorVersion"
}
/////////////
// UPDATES //
/////////////
def isNonStable = { String version ->
def regex = /^[0-9,.v-]+((-r)|(release)|(final)|(ga))?$/
return !(version.toLowerCase() ==~ regex)
}
dependencyUpdates {
rejectVersionIf {
isNonStable(it.candidate.version) && !isNonStable(it.currentVersion)
}
}
/////////////
// COMPILE //
/////////////
targetCompatibility = 1.8
sourceCompatibility = targetCompatibility
def compilerArgs = [
"-Xjsr305=strict"
]
compileKotlin {
dependsOn ktlintFormat
kotlinOptions {
freeCompilerArgs += compilerArgs
jvmTarget = "$targetCompatibility"
}
}
compileTestKotlin {
kotlinOptions {
freeCompilerArgs += compilerArgs + [
"-Xopt-in=kotlin.ExperimentalStdlibApi"
]
jvmTarget = "$targetCompatibility"
}
}
//////////
// TEST //
//////////
ktlint {
version = "0.43.2"
verbose = true
}
detekt {
config = files("detekt.yml")
buildUponDefaultConfig = true
}
test {
useJUnitPlatform {
excludeTags hasProperty("fast") ? "Slow" : "None"
}
}
jacoco {
toolVersion = "0.8.7"
}
if (!hasProperty("fast")) test.finalizedBy(jacocoTestReport)
/////////////
// PUBLISH //
/////////////
java {
withJavadocJar()
withSourcesJar()
}
publishing {
publications {
mavenJava(MavenPublication) {
groupId = project.group
artifactId = projectName
version = project.version
from components.java
pom {
name = "Ktor Controllers OpenAPI"
description = "Support for OpenAPI3 in ktor-controllers"
url = "https://github.com/Koriit/ktor-controllers-openapi"
licenses {
license {
name = "The MIT License"
url = "https://github.com/Koriit/ktor-controllers-openapi/blob/master/LICENSE"
}
}
developers {
developer {
id = 'koriit'
name = 'Aleksander Stelmaczonek'
email = 'al.stelmaczonek@gmail.com'
}
}
scm {
connection = 'scm:git:git://github.com/Koriit/ktor-controllers-openapi.git'
developerConnection = 'scm:git:ssh://github.com/Koriit/ktor-controllers-openapi.git'
url = 'https://github.com/Koriit/ktor-controllers-openapi'
}
}
}
}
repositories {
maven {
credentials {
username = findProperty("sonatype.user") ?: System.getenv("SONATYPE_USERNAME")
password = findProperty("sonatype.password")?: System.getenv("SONATYPE_PASSWORD")
}
def releasesRepoUrl = 'https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/'
def snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
}
}
}
signing {
def signingKey = findProperty("signing.key") ?: System.getenv("PGP_SIGNING_KEY")
def signingPassword = findProperty("signing.password") ?: System.getenv("PGP_SIGNING_PASSWORD")
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications.mavenJava
}
///////////
// OTHER //
///////////
task getVersion {
doLast {
print project.version
}
}
task fmt {
dependsOn ktlintFormat
}