JetBrains/gradle-idea-ext-plugin

Some possiblility to do one-shot tasks

Vampire opened this issue · 5 comments

It would be nice to have some way to do configure a task that should be executed on initial import of a project.
If you e. g. have a code-generation task, this could be set to run on initial import, so if one checks out your project and opens it in IJ, the generated code is instantly present.
One could of course use afterSync, but it might be overkill to do this task on every sync.

The second time you run the task, it would already be up-to-date and wouldn't really take much build time anyway. At the moment though afterSync doesn't even work, so it's a moot point anyway.

It depends on the task whether it would be up to date or not. And it depends on the build how long it would take. For our main project at work even the configuring needs significant amount of time.

Luckily Gradle can now even avoid configuring things it doesn’t need to run. But you’re right, tasks do have to be written correctly.

I think afterSync is the right place. Just make your task idempotent (e.g. it should check conditions when to be run, like checks some flag/file availability).

Again, this doesn't help if your project already needs significant time for configuration phase