I'm working on a project that uses Ktor and Hibernate. Currently the project can only run using the gradle Shadow plugin. This however breaks hot reloading, since all classes are compiled into a jar file, preventing ktor from picking up changes. If I run without the Shadow plugin, then I get a '<Entity> is not mapped' message from Hibernate.
Does anyone have a similar setup where they managed to get the auto reload functionality to work?
d
Didier Villevalois
11/25/2021, 1:37 PM
You could minimize the impact of having to make a shadow jar by splitting your project in two sub-projects:
• a library containing your entities, for which you build a shadow jar, and
• a Ktor app that uses the above library and uses hot reloading.
r
Raymond Boswel
11/29/2021, 10:47 AM
So I managed to get the application running withou shadowJar by adding the following to my build script:
Copy code
sourceSets {
java {
main {
output.setResourcesDir(file("$buildDir/classes/kotlin"))
}
}
}
The only issue now is that auto-reload doesn't quite seem to work. If I update a log to an endpoint, while a 'gradle build' process is running alongside my 'gradle run' process, I see
Copy code
ktor.application Changes in application detected.
ktor.application Responding at <http://0.0.0.0:11111>
But when I hit the endpoint, the log message isn't updated 😕