Can someone take a look at my build config and see...
# announcements
t
Can someone take a look at my build config and see if there's some obvious way to speed up compilation and testing? https://gitlab.com/timmc/cavern/-/blob/master/spelunk/pom.xml Right now it takes about a minute and a half to do
mvn test -Dtest="StateTest"
. I don't have the fastest computer, but I feel like this should take 30 seconds at most. Alternatively, is there some way I can do incremental compilation and/or testing? Anything to get the feedback loop down to seconds rather than minutes.
v
I didn't look at your build, but one obvious thing would be to switch to Gradle. Besides many other pros Gradle is usually also faster than Maven, especially when doing repeated builds as Gradle is pretty good in avoiding unnecessary work. This afair includes incremental Kotlin compilation and when running tests it for example can run tests first that failed last to get faster feedback that it still fails and so on.
t
Hmm, I can take a look at switching. I've had unpleasant experiences with Gradle in the past -- it seems non-trivial to get it set up from scratch. But if it's faster, it might be worth the time.
v
It usually is easier to set up than Maven imho. But ymmv of course.
t
There's a lot to like about Gradle, and I'm not a huge fan of Maven either, but it's "the devil I know". :-)
But! Apparently incremental compilation is supported on Maven:
<kotlin.compiler.incremental>true</kotlin.compiler.incremental>
. And that gets a single test run (with a small code change) down to under 30 seconds.
Gradle's faster startup would probably improve on that, but the gradle daemon is actually one of the unpleasant things I've run into -- it's not uncommon for me to end up with stale daemons taking up memory, burning CPU, or causing compile errors.
v
Ah, didn't know it is supported in Maven too now. Actually you can disable the daemon via Gradle property either for all Gradle projects run on your computer or for a specific Grale project for everyone by using
~/gradle.properties
or
gradle.properties
. Though with that you loose many of the speed improvements, like reduced start up time, filesystem watching that remembers file states between builds, ... The daemons should quit themselves if they see the system memory becoming low or after some time. If it isn't, you should report that so that it can eventually be fixed. Afair you can even configure the idle time after which the daemon is quit. While the daemon is idle it should not really use the CPU either. Again, if it does, you should probably report that. That I got build failures because of daemon usage is for me very long ago and usually was caused by some bug in some plugin that misbehaved like using static state without appropriate encapsulation. But yeah, if you prefer Maven, stay with it, your beast to tame. :-)
t
Yeah, Gradle may have since improved in that regard. Worth another shot at some point. Great to know about those configuration options!