CLion: CompilerManager.addBeforeTask/addAfterTask alternative
Hi, I've implemented a small plugin for CLion, which allows to debug Serial port right from the IDE(https://plugins.jetbrains.com/plugin/8031 ). Currently I'm looking for a way to implement the following feature request: https://bitbucket.org/dmitry_cherkas/intellij-serial-monitor/issues/5
I need some API, which would allow my plugin to listen for "Build Project" events. In Open API I have discovered the following APIs, which pretty much serve my needs:
com.intellij.openapi.compiler.CompilerManager#addBeforeTask
com.intellij.openapi.compiler.CompilerManager#addAfterTask
Unfortunately, those APIs are not available in CLion.
Any hint on replacement APIs for CLion are highly appreciated!
请先登录再写评论。
Hi Anton,
Thanks for your reply. Unfortunately, this API does not allow me to listen to "build started" event. Possibly, I could use some workaround to execute my code before build execution? If it's not possible currently, is there any chance to have such API in upcoming releases?
This is new and only available in CLion 2018.3. I checked and all previous versions are missing
the interfaces.
I implemented the mechanism for disconnecting the serial port on build start and
reconnecting on build end in my own implementation of serial monitor and arduino development goes much smoother.
BTW, it would be good for us to figure out how we can get multiple plugins to make use of the
JSSC library. Right now the first plugin to load the native libs gets to use it. The rest fail
because native libs were loaded by another class loader. So my `Arduino Support` and your
`Serial Monitor` plugin are mutually exclusive.
I added my own serial monitor to eliminate the problem but this will creep up in the future more
often. We probably need to move JSSC into a separate plugin which exposes the library through
IDE Services. We can mark it as a required dependency of ours. We then use that plugin's
Services and API to access JSSC. This way any number of plugins can access JSSC without
conflict.
Here is a bare bones example of getting build events (flattened indents by copy/paste):
Dmitry,
currently there is only com.jetbrains.cidr.lang.workspace.OCWorkspaceModificationListener#buildFinished. Will it be enough?
(in platform version 163)
+1. The issue here is that Dmitriy's plugin and build process both need an access to the serial port, which is exclusive. So the plugin need to hook up to both build started event (to release the port) and build finished event (to acquire the port again).
I am trying to do the same in CLion 2018.3 and although there is a CidrBuildListener.TOPIC which would serve this purpose, the plugin instance of this topic is not the same one as seen by CLion core code. So the message is generated but my plugin is not being informed.
These might as well be different topics.
Is there a way to listen to build start/finish build messages? The one above would be perfect since it gives all the necessary information about the build configuration.
Solved. There was duplicate library in the project.
Hi Vladimir,
Since I never managed to implement the desired functionality, could you please share your approach (may be, a code snippet), that allowed you to track the build start/end events?
Hi,
Vladimir is correct - CidrBuildListener was introduced only in 2018.3.
Dmitry, you could try using it - it should solve your problems.