How to figured out facet settings have been changed since last build

Hi,

I am trying to develop some plugin, which is a facet. It generates some file when user clicks "Build->Make Project".  It has some facet setting options. I want the generated files being cleaned and regenerated if user changes the options and clicks "Build->Make Project".

Currently, I have added a CompileTask through compilerManager.addBeforeTask(), which has the logic of cleaning generated files if user clicks "Build -> Rebuild Project", which is detected by calling CompileContext.isRebuild().

Is there a way to figure out whether the settings have changed since the last build, given the CompileContext object, so that I can clean the generated file in the CompileTask#execute()?


Or if the above way is not the ideal way, what is the common practice for IntelliJ plugin to achieve similar goal?

Thanks.

5 comments
Comment actions Permalink

Hello,

how did you plug into the build process? If you created an external builder plugin
(http://www.jetbrains.org/intellij/sdk/docs/reference_guide/frameworks_and_external_apis/external_builder_api.html) and have a special BuildTarget for
your build task you can override BuildTarget#writeConfiguration method.

--
Nikolay Chashnikov
JetBrains
http://www.jetbrains.com
"Develop with pleasure!"

0
Comment actions Permalink

Hi Nikolay,

Sorry I hid some fact when I asked the question, to make it easier to describe the problem. The truth is I was trying to add an option to protobuf plugin (I am not the owner of it, just want to make a small change to it) at: https://github.com/nnmatveev/idea-plugin-protobuf.  Changing the option should make the generated files invalid, which doesn't happen right now. The plugin doesn't seem to use the BuildTarget you mentioned and I don't have full understanding how the whole plugin works.  Could you give some advice?  Thanks.

I know it is not a good manner to point a lot of code to other people so I tried to abstract the problem and make it minimal, but looks like it doesn't work due to my short of knowledge in how whole intellij plugin system works, sorry for that.

0
Comment actions Permalink

The build process is not a BuildTarget, but added as compilerManager.addBeforeTask and compilerManager.addCompiler:
https://github.com/nnmatveev/idea-plugin-protobuf/blob/master/src/protobuf/compiler/PbCompilerLoader.java#L25

Any suggestion?

0
Comment actions Permalink

You can store the setting in PbGenerationItemValidityState for each item. So if the setting is changed since last compilation all items will be
regenerated.

--
Nikolay Chashnikov
JetBrains
http://www.jetbrains.com
"Develop with pleasure!"

0
Comment actions Permalink

Hi Nikolay,

It is not working.  You know what, the PbGenerationItemValidityState.{load,save,equalsTo} are never called. The only place the class is used is https://github.com/nnmatveev/idea-plugin-protobuf/blob/master/src/protobuf/compiler/PbCompiler.java#L141, which only calls PbGenerationItemValidityState.valid(), which doesn't have access to previous state.  I believe this plugin doesn't use standard way to plug itself into the framework, instead it is doing things in a very hacky way.  Do you have any suggestions on how to make sure framework store and load the ValidityState?  Thanks.

0

Please sign in to leave a comment.