Simple question about Gradle task when running java application
So I am trying to better understand how gradle works with java applications and just created a simple IntelliJ java Hello World application. When I create and run an Application Run Configuration for a simple HelloWorld class I created it gives me the output I expect (println of "Hello World"), but I am curious based on the output, of exactly what IntelliJ is running as I don't see anything obvious in the build.gradle that suggests how it IntelliJ actually knew to run that main method in that class. The build.gradle only has java in the plugins section. The output suggests that there is an actual gradle operation being done to execute the main method in my class but I don't understand where that comes from.
Admittedly, I am just trying to learn the finer details of graddle and so it is possible I just don't understand some of the default/built-in functionality of gradle. Specifically, the line below that says "Task :HelloWorld.main()" is the one that is unclear to me where that comes from.
Sorry if this is something that should be known and/or was answered previously. I did spend more than 45-60 minutes searching this forum, google, gradle and IntelliJ documentation prior to posting. TIA for any help.
Dave
OUTPUT:
5:53:00 AM: Executing task 'HelloWorld.main()'...
> Task :compileJava UP-TO-DATE
> Task :processResources NO-SOURCE
> Task :classes UP-TO-DATE
> Task :HelloWorld.main()
Hello World
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.
See https://docs.gradle.org/5.2.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 0s
2 actionable tasks: 1 executed, 1 up-to-date
5:53:00 AM: Task execution finished 'HelloWorld.main()'.
请先登录再写评论。
>The output suggests that there is an actual gradle operation being done to execute the main method in my class but I don't understand where that comes from.
With the Gradle selected as Settings (Preferences on macOS) | Build, Execution, Deployment | Build Tools | Gradle | Build and run using - IDE invokes actual Gradle to run the class. IDE calls JavaExec task implicitly via Gradle tooling API.
Perfect, that is exactly what I was suspecting and it was good to know where this can be inferred. Thanks for the quick reply.
Thanks to this thread !
I registered to write something down here. I have the same questiion and also spent much time to google.
this maybe an unremarkable detail, but both of us @... are truth seekers that do not want to miss it.
It seems that I am over-excited :)