I'm using spock for testing(it won't be changed) ...
# getting-started
s
I'm using spock for testing(it won't be changed) is it possible to make kotlin use@JvmStatic by default for generated methods? I know there are spring plugins that make classes not final by default. is there something like this for static methods?
y
I don't think there is, but a compiler plugin can definitely be easily written for it. I might have a look in a few hours to see if I can make such a thing
Quick question: by generated methods, do you mean methods on companion/regular objects etc? Because, as far as I know, only companion/regular object methods work with
@JvmStatic
s
yes, I mean those methods
y
Perfect, currently working on it!
Quick update: I've successfully made the plugin! Currently Publishing
Released! Try it now (It might take a bit of time for Maven Central to update and everything):
Copy code
plugins {
  id("io.github.kyay10.kotlin-all-static") version "0.1.0"
}
I'm not familiar with Spock at all really, so bear in mind that if you're trying to access those methods from Java directly that the IDE will give you errors and red lines since it doesn't know that the plugin will make those methods static. However when you compile the code (or if Spock uses reflection and so it just accesses the methods at runtime) the methods will all resolve correctly. Just try it out and tell me what happens lol!
s
thanks @Youssef Shoaib [MOD] thanks