Last active
June 4, 2019 13:30
-
-
Save ypujante/6974e88fa47131bedc4a42cbb936a254 to your computer and use it in GitHub Desktop.
Pass command line arguments to ktor server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ... 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