-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
145 lines (122 loc) · 4.51 KB
/
build.gradle.kts
File metadata and controls
145 lines (122 loc) · 4.51 KB
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
plugins {
id("buildsrc.convention.kotlin-jvm")
`java-library`
alias(libs.plugins.kotlin.plugin.serialization)
id("com.vanniktech.maven.publish") version "0.30.0"
}
group = "com.vcontrol"
version = file("version.properties")
.readLines().first { it.startsWith("version=") }.substringAfter("=")
dependencies {
// Ktor BOM for version alignment
api(platform(libs.ktor.bom))
// Coroutines
implementation(libs.kotlinx.coroutines)
// Kotlin serialization
implementation(libs.kotlinx.serialization)
// Ktor server
implementation(libs.ktor.server.core)
api(libs.ktor.server.auth)
api(libs.ktor.server.auth.jwt)
implementation(libs.ktor.server.content.negotiation)
implementation(libs.ktor.serialization.json)
implementation(libs.ktor.server.status.pages)
implementation(libs.ktor.server.forwarded.header)
api(libs.ktor.server.sessions)
// Bearer sessions (shared session storage infrastructure)
api("com.vcontrol:ktor-bearer-sessions:0.2.0")
// JWT
implementation(libs.java.jwt)
// Logging
api(libs.kotlin.logging)
// Test dependencies
testImplementation(kotlin("test"))
testImplementation(libs.kotlinx.coroutines)
testImplementation(libs.ktor.server.tests)
testImplementation(libs.ktor.server.cio)
testImplementation(libs.ktor.client.content.negotiation)
testImplementation(libs.ktor.serialization.json)
testImplementation(libs.slf4j.simple)
}
// Generate version file for runtime access
val generateVersionFile = tasks.register("generateVersionFile") {
val outputDir = layout.buildDirectory.dir("generated/resources")
val versionFile = outputDir.map { it.file("ktor-oauth-version.properties") }
val versionValue = version.toString()
inputs.property("version", versionValue)
outputs.file(versionFile)
doLast {
outputDir.get().asFile.mkdirs()
versionFile.get().asFile.writeText("version=$versionValue\n")
}
}
tasks.processResources {
dependsOn(generateVersionFile)
}
sourceSets.main {
resources.srcDir(layout.buildDirectory.dir("generated/resources"))
}
// Ensure sourcesJar depends on generateVersionFile since it includes generated resources
tasks.withType<Jar>().configureEach {
if (name == "sourcesJar") {
dependsOn(generateVersionFile)
}
}
// Enable experimental APIs globally
kotlin {
compilerOptions {
freeCompilerArgs.addAll(
"-opt-in=kotlin.time.ExperimentalTime",
"-opt-in=kotlinx.serialization.InternalSerializationApi",
"-opt-in=kotlinx.serialization.ExperimentalSerializationApi"
)
}
}
// CLI task for generating bearer tokens
tasks.register<JavaExec>("generateToken") {
group = "application"
description = "Generate a bearer token and setup URL for clients that don't support OAuth"
mainClass.set("com.vcontrol.ktor.oauth.cli.GenerateTokenKt")
classpath = sourceSets["main"].runtimeClasspath
if (project.hasProperty("args")) {
args = (project.property("args") as String).split(" ")
}
}
// CLI task for generating setup URLs for existing clients
tasks.register<JavaExec>("generateSetupUrl") {
group = "application"
description = "Generate a setup URL for an existing client ID (e.g., OAuth clients)"
mainClass.set("com.vcontrol.ktor.oauth.cli.GenerateSetupUrlKt")
classpath = sourceSets["main"].runtimeClasspath
if (project.hasProperty("args")) {
args = (project.property("args") as String).split(" ")
}
}
// Maven Central publishing via vanniktech plugin
mavenPublishing {
publishToMavenCentral(com.vanniktech.maven.publish.SonatypeHost.CENTRAL_PORTAL)
signAllPublications()
pom {
name.set("Ktor Server OAuth")
description.set("OAuth 2.0 authorization server plugin for Ktor with dynamic client registration and JWT tokens")
url.set("https://github.com/vctrl/ktor-server-oauth")
licenses {
license {
name.set("Apache License 2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0")
}
}
developers {
developer {
id.set("pmokbel")
name.set("Paul Mokbel")
email.set("paul@mokbel.com")
}
}
scm {
url.set("https://github.com/vctrl/ktor-server-oauth")
connection.set("scm:git:git://github.com/vctrl/ktor-server-oauth.git")
developerConnection.set("scm:git:ssh://git@github.com/vctrl/ktor-server-oauth.git")
}
}
}