Calling a Gradle task when idea refreshes the project Follow
I use the avro plugin and i would like to automatically run "generateAvroJava" when idea reloads the project.
is it documented somewhere what gradle tasks idea calls when it refreshes the gradle project? Then i could just make that task depend on "generateAvroJava"
Please sign in to leave a comment.
IDEA doesn't call gradle tasks during project refresh. It uses gradle tooling api to get project information.
However you can configure it in IDEA. Open gradle tool window, find the task and using context menu enable "execution after and/or before Sync".
See details at https://www.jetbrains.com/help/idea/2016.2/gradle-tool-window.html#d329225e354
I'd really like to see IDEA support running a task without having to do that through IDEA. The gradle file should be the "source of truth" and I need to be able to generate a new project without everybody having to know that you must then run a specific task to get everything up and running.
Wouldn't it be possible for IDEA to read a pre-determined property that would contain a list of tasks to run when syncing?
So you could put the following into your gradle.properties file for example:
Similar use case here. Previously used "gradlew idea" to update the IntelliJ project model. But that doesn't work with the .idea directory or the linking to Gradle and requires an IDE restart every time, I could hack the XML directly to add, say, a new run configuration with "loose" Groovy that runs as part of the project figuring itself out, but who knows how that might interact with IntelliJ itself updating its files at the same time.
another easy solution would be to have a virtual gradle task that idea calls
lets say that task is called ideaImport then i can just do
My use case is similar to those above.
You can now do this in your Gradle script using the `idea-ext` plugin. See: https://github.com/JetBrains/gradle-idea-ext-plugin/wiki/Change-log-DSL-v0.2#gradle-tasks-triggers-settings
Jendrik How can you do it? Can you show/link an example?
@43personal see Gradle tasks triggers settings.
From Kotlin `idea.project` does not have property `settings`! How do you call it from Kotlin?
Please check this example. See also this thread for some more information on Kotlin DSL configurations.
I knew it was some evil Groovy black magic! Thank you for the hint :)
The idea-ext plugin is not usable for this because of https://youtrack.jetbrains.com/issue/IDEA-282322, if you checkout an older commit then IDEA cannot import or build the project anymore.