简体   繁体   中英

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM