shadox
shadox

Reputation: 3749

Activating assertions in Gradle Project IntelliJ

I'm trying to make java assert work on my gradle project in IntellJ but whatever I try, nothing works. My first gradle script is this:

subprojects {
    tasks.withType(JavaCompile) {
    //        options.compilerArgs << "-ea:exceptions.Assertions"
        options.compilerArgs += "-ea:exceptions.Assertions" //my package and class

    }
}

I have tried without subprojects as well but no luck.

Another approach I have tried is this:

compileJava {
    options.compilerArgs += "-ea:exceptions.Assertions" //my package and class
}

Not sure what is the problem and how to fix it. Any ideas?

Upvotes: 2

Views: 843

Answers (1)

miskender
miskender

Reputation: 7958

At the top menu select Run->Edit Configurations write -ea to VM options. This will enable when you are running from idea.
When running form command line use command like this java -ea -jar yourJar

Upvotes: 1

Related Questions