How to add Gradle options

Answered

I have a Gradle project. It uses Gradle version 5.5.1. When I run using a Gradle type Run Configuration that simply ends up building a jar file, there are no warnings. When I run using an Application type Run Configuration, it runs fine, but I get this warning:

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.

I'm trying to tack down why I'm getting that warning. So, my first question is how do set '--warning-mode all' so Gradle will use it when I run my app using an Application type of Run Configuration? When I go to Settings > Gradle, I don't see where I can add Gradle options like this. I tried adding ORG_GRADLE_WARNING_MODE=all to the "Environment variables" field in the Run Configuration, but that didn't do anything.

I got a similar warning when this project was using Gradle 4 too, except in that case it said "...incompatible with Gradle 5.0".

Thanks.

 

6 comments
Comment actions Permalink

Does it help to re-create project configuration by import it via File | New | project from Existing Sources... action?

0
Comment actions Permalink

No. In fact, if I create a brand new Gradle Groovy project, by going to File > Project... > Gradle > checkmark only Groovy > etc... Then create a new class MyClass with static void main method, and then run that using an Application Run Configuration with MyClass.main, it runs AND gives that depreciated Gradle features warning after it runs. So, it has nothing to do with my specific project. It's IDEA 2019.2.

But, first I wish I could just show the warnings.

0
Comment actions Permalink

Create gradle.properties file next to build.gradle file with the following:

org.gradle.warning.mode=all

The warning occurs because of the Run delegation feature enabled where IntelliJ IDEA generates the special Gradle code to run the project run configuration in the temp directory. This generated code triggers the warning.

As a workaround you can either disable the delegation or create your own task based on JavaExec and use it to start app from the Gradle tool window.

1
Comment actions Permalink

Custom execute task configuration:

1
Comment actions Permalink

This is very helpful.

Thank you Serge.

0
Comment actions Permalink

I am getting this error too with gradle 5.6.2.

Unnecessarily replacing a task that does not exist has been deprecated. This is scheduled to be removed in Gradle 6.0. Try using create() or register() directly instead. You attempted to replace a task named 'ApplicationStartup.main()', but no task exists with that name already.
at ApplicationStartup_main__1_7yrvxwjctmuj2skl8oqlefggl$_run_closure1$_closure2.doCall(C:\Users\xyz\AppData\Local\Temp\ApplicationStartup_main__1.gradle:18)
(Run with --stacktrace to get the full stack trace of this deprecation warning.)

I created this issue for the warning: https://youtrack.jetbrains.com/issue/IDEA-224030

0

Please sign in to leave a comment.