0

The project I am working on is Java, Gradle based. So I want to create a plugin/script that will run a certain Gradle task whenever I made changes to one of the files from the project.

For example

There is A.xml file and a B Gradle task. Whenever I do changes to A.xml and save it I want the B Gradle task to be run.

I am using IntelliJ IDEA, and my initial thoughts are that it could be solved through plugins/scripts.

Can you suggest where to start? Should it be done through plugins? Maybe there are automatisation settings in IntelliJ that have file watchers or smth. Thanks.

I tried to search similiar plugins, and didn't find any. Read documentation for plugin creation, I think I can reach the result, but isn't it overhead?

Vahe Karamyan
  • 33
  • 1
  • 10
  • Do you want [Continuous Build](https://docs.gradle.org/7.6/userguide/command_line_interface.html#sec:continuous_build)? – aSemy Jan 06 '23 at 13:36
  • Do you need this in order to produce some artifact that another gradle task needs? Because the idiomatic way to do that is to just make gradle aware of the dependency and how to produce the artifact so that rather than being generated every time the file is modified it instead runs the task lazily at the moment it is actually needed. – Max Jan 06 '23 at 14:59
  • In the Gradle tool window, you can assign a shortcut, e.g. Ctrl+S to a specific Gradle task. – Andrey Jan 09 '23 at 08:25
  • Let me tell you the case so we are clear. I have XML data based on which an enum is generated by Gradle task using Javapoet lib. Basically, I want that enum code to be immediately generated after I make changes to the source file, so I can use the fields, otherwise, I will have to remember to run the Gradle script every time I change the XML. Hope the case is clear. – Vahe Karamyan Jan 11 '23 at 13:59

0 Answers0