Skip to content

Instantly share code, notes, and snippets.

@ypujante
Last active June 4, 2019 13:30
Show Gist options
  • Save ypujante/6974e88fa47131bedc4a42cbb936a254 to your computer and use it in GitHub Desktop.
Save ypujante/6974e88fa47131bedc4a42cbb936a254 to your computer and use it in GitHub Desktop.
Pass command line arguments to ktor server
// ... build.gradle
// ...
def webFolder = new File(project.buildDir, "web")
// ...
task run(type: JavaExec, dependsOn: [jvmMainClasses, jsJar]) {
main = "sample.SampleJvmKt"
classpath {
[
kotlin.targets.jvm.compilations.main.output.allOutputs.files,
configurations.jvmRuntimeClasspath,
]
}
args = ["-P:sample.SampleJvmKt.static.web.dir=${webFolder.canonicalPath}"]
}
// ...
// then in any module (environment.config is "experimental (2019/06/03)
// @KtorExperimentalAPI
// fun Application.jobsRouting() {
// val webDir = environment.config.propertyOrNull("sample.SampleJvmKt.static.web.dir")?.getString()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment