jlengrand
jlengrand

Reputation: 12807

Running ktor with a custom Configuration file via Gradle

I have a simple Ktor application using application.conf files. The documentation mentions that I can specify a custom configuration file to use as such :

enter image description here

Now, I would like to do exactly the same, except that I start my application using ./gradlew run.

Using ./gradlew run -config=... won't even run, while using ./gradlew run -Dconfig=... seems to gloriously ignore the input I give it.

What is the proper way to provide a custom configuration time when starting my Ktor server with gradle?

enter image description here

Upvotes: 0

Views: 1272

Answers (2)

YueYue
YueYue

Reputation: 52

Supplement.

If you use idea to run a program, you can add the -config parameter to Program arguments.

e.g. e.g.image

Upvotes: 1

jlengrand
jlengrand

Reputation: 12807

Ok, answering my own question after further research. The answer in this case is to run gradle as such :

$./gradlew run --args="-config=src/main/resources/application.test.conf

As per [the gradle documentation](https://docs.gradle.org/current/userguide/application_plugin.html#:~:text=Since%20Gradle%204.9%2C%20the%20command,setArgsString(java.).

Upvotes: 1

Related Questions