This repository has been archived by the owner on Aug 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle.kts
152 lines (128 loc) · 5.01 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
import org.gradle.jvm.tasks.Jar
import java.net.URL
plugins {
kotlin("jvm") version "1.6.20"
`maven-publish`
signing
id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
id("net.nemerosa.versioning") version "2.15.1"
id("org.jetbrains.dokka") version "1.6.10"
id("io.gitlab.arturbosch.detekt") version "1.19.0"
}
group = "dev.forst"
base.archivesName.set("ktor-api-key")
version = (versioning.info?.tag ?: versioning.info?.lastTag ?: versioning.info?.build) ?: "SNAPSHOT"
repositories {
mavenCentral()
}
dependencies {
compileOnly(kotlin("stdlib-jdk8"))
// Ktor server dependencies
val ktorVersion = "2.0.0"
compileOnly("io.ktor", "ktor-server-core", ktorVersion)
compileOnly("io.ktor", "ktor-server-auth", ktorVersion)
// testing
testImplementation("io.ktor", "ktor-server-core", ktorVersion)
testImplementation("io.ktor", "ktor-server-test-host", ktorVersion)
testImplementation("io.ktor", "ktor-server-auth", ktorVersion)
testImplementation("io.ktor", "ktor-server-content-negotiation", ktorVersion)
testImplementation("io.ktor", "ktor-serialization-jackson", ktorVersion)
testImplementation("io.ktor", "ktor-client-content-negotiation", ktorVersion)
testImplementation(kotlin("test"))
testImplementation(kotlin("stdlib-jdk8"))
testImplementation("ch.qos.logback", "logback-classic", "1.3.0-alpha5") // logging framework for the tests
val junitVersion = "5.8.2"
testImplementation("org.junit.jupiter", "junit-jupiter-api", junitVersion) // junit testing framework
testImplementation("org.junit.jupiter", "junit-jupiter-params", junitVersion) // generated parameters for tests
testRuntimeOnly("org.junit.jupiter", "junit-jupiter-engine", junitVersion) // testing runtime
}
detekt {
config = files("detekt.yml")
parallel = true
}
tasks {
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
test {
useJUnitPlatform()
}
dokkaHtml {
outputDirectory.set(File("$buildDir/docs"))
dokkaSourceSets {
configureEach {
displayName.set("Ktor API Key Authentication Provider")
sourceLink {
localDirectory.set(file("src/main/kotlin"))
remoteUrl.set(URL("https://github.com/LukasForst/ktor-api-key/tree/master/src/main/kotlin"))
remoteLineSuffix.set("#L")
}
}
}
}
}
// ------------------------------------ Deployment Configuration ------------------------------------
// deployment configuration - deploy with sources and documentation
val sourcesJar by tasks.creating(Jar::class) {
archiveClassifier.set("sources")
from(sourceSets.main.get().allSource)
}
val javadocJar by tasks.creating(Jar::class) {
archiveClassifier.set("javadoc")
from(tasks.javadoc)
}
// name the publication as it is referenced
val publication = "mavenJava"
publishing {
// create jar with sources and with javadoc
publications {
create<MavenPublication>(publication) {
from(components["java"])
artifact(sourcesJar)
artifact(javadocJar)
pom {
name.set("Ktor API Key Authentication Provider")
description.set("Native API Key authentication in Ktor.")
url.set("https://ktor-api-key.forst.dev")
packaging = "jar"
licenses {
license {
name.set("MIT")
url.set("https://mit-license.org/license.txt")
}
}
developers {
developer {
id.set("lukasforst")
name.set("Lukas Forst")
email.set("[email protected]")
}
}
scm {
connection.set("scm:git:git://github.com/LukasForst/ktor-api-key.git")
url.set("https://github.com/LukasForst/ktor-api-key")
}
}
}
}
}
signing {
val signingKeyId = project.findProperty("gpg.keyId") as String? ?: System.getenv("GPG_KEY_ID")
val signingKey = project.findProperty("gpg.key") as String? ?: System.getenv("GPG_KEY")
val signingPassword = project.findProperty("gpg.keyPassword") as String? ?: System.getenv("GPG_KEY_PASSWORD")
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
sign(publishing.publications[publication])
}
nexusPublishing {
repositories {
sonatype {
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
username.set(project.findProperty("ossrh.username") as String? ?: System.getenv("OSSRH_USERNAME"))
password.set(project.findProperty("ossrh.password") as String? ?: System.getenv("OSSRH_PASSWORD"))
}
}
}