The embedded netty server is very convenient for d...
# ktor
v
The embedded netty server is very convenient for development (or for someone else to clone the project and quickly run it), but shouldn't be a dependency for production builds. What's the best way to do this? I've been thinking of defining a develop/production property in a gradle settings file, and conditionally including the dependency.
d
You can also have a multi-module with common code not depending on netty, and then two modules: one depending on netty with the embedded server, and other with whatever you use. I know it is more work, but usually it is what works best. You could also have two mains and use proguard, but it would take more time and still it would be more configuration.
v
The code is identical - the dependency is only needed for the IDE and Gradle
mainClassName
run configurations.
d
The problem is that if you have a main file getting the Netty object, it won’t exist. Maybe you can put that main function in a separate folder and include as source root only with your develop property. It would be similar to what I have said. At any rate, if you do it, let me know how have you done it, or create a PR to
ktor-samples
, since it could be an interesting sample reusable for other people.
v
The main file is just an extension function on
Application
, it doesn't reference Netty at all.
d
Oh you mean using application.conf, then yeah you can do that
v
Not even in .conf 🙂
mainClassName = 'io.ktor.server.netty.DevelopmentEngine'
in build.gradle
d
I see, ok, makes sense 🙂
I thought you had a custom main doing some stuff for the embedded version