Where do the gradle tasks come from when running class with main method in intelliJ?

Answered

I can directly run a class with a main method in IntelliJ (This is a java project using Gradle). When I run a class A by doing that I notice IntelliJ executes a gradle task called A.Main(). But I don't have that task in my Gradle build script. So where do they come from?

3
5 comments

IntelliJ IDEA generates the stub task to run the method and you can find it in the temporary generated build file used for execution.

If this behavior is not desirable, you can run directly from IntelliJ IDEA without using Gradle by enabling the option as shown on this screenshot.

4
Avatar
Permanently deleted user

> generates the stub task to run the method and you can find it in the temporary generated build file used for execution

I'm afraid I can't find this build file. Can you please provide more information about it's location?

I'm using MacOS

0

For Main.main() IDE will create Main_main__.gradle file in the system TEMP directory.

2

Can we somehow configure this task? When running a test from Gradle, we automatically add a couple of system properties. It would be very convenient to add them when a developer runs the class from IDE too.

0

When you run a Class in a Gradle-based Project IDEA automatically creates an Application-type Run/Debug Configuration, which you can edit via the corresponding menu and add Environmental Variables / Program Arguments.

0

Please sign in to leave a comment.