how do I enable assertions with gradle (kts) ?
# gradle
k
how do I enable assertions with gradle (kts) ?
v
For JVM or native?
k
JVM
v
It's a runtime JVM option called
-ea
, so depends on how you run your project.
k
I am running from intellij
I added the -ea flag in run configuration which worked but is there a way to specify it in gradle script or properties?
v
It is a runtime option, so unless you run from Gradle, no. Logic should never depend on assertions and assertions should be side-effect free. You can use them to do additional checks to find bugs and don't have the performance gut during normal usage. If you want to enforce assertions (I wouldn't recommend that), you could probably have a failing assertion and verify it throws an exception.
👍 1
109 Views