How to listen to Gradle build file (Kotlin or Groovy) changes?

Answered

Hello,

I need to listen to Gradle build file changes in order to automatically launch an action.

Is there an easy way to do that?

Thanks for help

Regards

5 comments
Comment actions Permalink

I found the solution implementing "DocumentListener" on the PSI file but it triggers event on live change.

I would like to be warned on property change only after file is saved. Any idea?

0
Comment actions Permalink

There's dedicated EP com.intellij.ide.actionsOnSave.impl.ActionsOnSaveFileDocumentManagerListener.ActionOnSave

0
Comment actions Permalink

Thanks a lot Yann, I'll have a look to this EP

For now I work with 'PsiTreeChangeListener / Adapter' but it's the same behavior (live notification when a child is replaced which is pretty good to be sure the right parameter is updated, but not useful for the user since He cannot finish to update the parameter value without being interrupted with a notification)

0
Comment actions Permalink

I'm facing an issue with the ActionOnSave EP.

Should I extends "com.intellij.ide.actionsOnSave.impl.ActionsOnSaveFileDocumentManagerListener"? ("actionsOnSave" seems not known -> error on import)

Or Should I only implements FileDocumentManagerListener?

FileDocumentManagerListener only manage before saving operations (not after saving).

0
Comment actions Permalink

Finally, "com.intellij.openapi.fileEditor.FileDocumentManagerListener.beforeDocumentSaving" API is suiting me (fileDocumentManagerListener EP).

0

Please sign in to leave a comment.