Plugin - How can I run a task before Gradle project is linked?

  • Our company works in Gradle git repositories that don't have a gradle or gradlew file on a fresh checkout.
  • Users are required to run an initialization script to pull a gradle wrapper and file from a remote host before opening IDEA
  • IDEA works with previously initialized wrapper, but fails if users forget to run the script as IDEA will use a wrapper from that doesn't contain information the repository needs

In a plugin, I would like to make this a seamless process for users by running the initialization script that sets up gradlew before Gradle will attempt to initialize the module and link it to the project. I need to do the following:

  1. Run script just before Gradle links module to project
  2. Run script on project open for Gradle projects already linked

I feel I'm on the right track but can't really find the right way to go about it. I've looked at:

ProjectOpenProcessor, GradleTaskManagerExtension, GradleProjectResolverExtension

1 comment
Comment actions Permalink

Please take a look at ExternalSystemExecutionAware.prepareExecution
Parameter `task: ExternalSystemTask` allows you to check if it is a reload (sync) or just Gradle task launch.
Parameter `taskNotificationListener: ExternalSystemTaskNotificationListener` allows to send events (text) to sync/build output toolwindow


Please sign in to leave a comment.