Plugin in intellij that run in intellij start up - intellij-plugin

I want to write a plugin in intellij. Can I create an plugin for intellij that runs in the background as soon as the user opens the intellij IDE?

You can implement the ProjectComponent interface (which is run on project loading). This class needs to be registered as project-components in your plugin.xml. There are also other components like ApplicationComponent.
For more information see: https://confluence.jetbrains.com/display/IDEADEV/IntelliJ+IDEA+Plugin+Structure#IntelliJIDEAPluginStructure-PluginComponents

Related

Eclipse Editor monitor file changes from out of Eclipse

I am developing a Plugin for eclipse, and notice that when user changes file from out of IDE, e.g., do a git pull using shell, my editor does not pick up the change. I try to use IResourceChangeListener but realize it only monitors changes happening in the workspace.
I have seen eclipse TextEditor can monitor external file change, but failed to find how it implements this from code. My editor is not a text editor so I cannot extend from TextEditor to get this for free.
Can anyone give me a hint how to properly implement this feature for eclipse? Thanks!
According to Eclipse FAQ you need to monitor non Eclipse file changes in separate thread.
Fortunately Java have file change notification API which can be used to implement this.

Intellij - how to make a plugin that can perform IDE actions via a CLI or web service?

I need some help getting started making a specific IntelliJ plugin.
I want to make an IntelliJ plugin that makes it so you can launch intelliJ actions from CLI (or from a web service if it's easier).
For example, I'm done building my project with a gradle script... but i want to get it ready in intelliJ too. Right now I have to do this manually with a point-and-clicks.
Instead I want to have this the ability to externally trigger some IntelliJ commands. In my example I would want to fire off these requests from my gradle script:
run-intellij-command {project-path} --action refresh-gradle
run-intellij-command {project-path} --action build-project
run-intellij-command {project-path} --action start-debugging --configurationName={configuration-name}
Does anyone have an example of how I can get started with this?
Really hoping there is an intellij plugin project that already does something similar like reacting to cli commands or hosts a web service that can be called?
Thanks!
Also created this https://youtrack.jetbrains.com/issue/IDEA-184885
hoping to see this feature become a reality some day
You can use the ApplicationStarterEx interface to implement that. Provide a class implementing the interface, and register it in your plugin.xml as the <appStarter> extension point.
To execute your code, use Tools | Create Command-line Launcher, and then run idea <startername> <arguments> from the command line, where startername is what you return from ApplicationStarter.getCommandName().
I'm not aware of any existing open-source plugins that implement similar functionality.

Intellij and Hybris Tests

Currently I'm doing the hybris 5 Developer Training Trails 5.7 - Part I - Core in Intellij and the Hybris Plugin for Intellij.
Now I'm at the point where I have to run a test class. When I'm doing it, it tells me that it's not finding a a class "de.hybris.platform.cuppy.jalo.Match".
When I'm running the same test in http://localhost:9001/test then everything works fine.
I guess I have to fix my classpath, but I don't know how. If I change the classpath of the module in "Run/Debug Configurations" to something else, then it's not working. If I change there the working directory from MODULES_DIR to the whole project path it's not working either. Now I have no ideas anymore.
Just install "Hybris Integration" plugin it will do everything automatically. You will be able to import Hybris projects just like maven or gradle based projects. That plugin provides Hybris integration into Intellij IDEA and another IDE based on it.
You can install it to your IDE directly from the repository by clicking on the "Browse Repositories" button in Settings/Plugins dialog.
You need to remove all your JAVA Build Path Problems. Then test cases should work.
In my case I had set the "power save mode" on IntelliJ. Removing it solved the problem for testing

IntelliJ: Launch Run-configuration from the embeded terminal

Lets say I have run-config1 and run-config2 setup for my project in IntelliJ.
I know there are ways of adding custom shell code to be perfomed before/after a build run, but that's not what I want to do.
Is there a way of calling them from the embedded terminal?
As of IntelliJ IDEA 14 there is no such way. You can write a plugin for IntelliJ IDEA that will handle a command like "idea.sh run configuration-name" and start the run configuration in the existing instance, but this is fairly non-trivial.

How to import and run existing plugins from intellij community edition repo

I'm trying to import and run the IntelliJ git4idea (Git Integration) plugin in order to play around and contribute some of my own code.
I've pulled the Intellij community edition from the github repo, and imported the git4idea plugin as a project. I'm running the Intellij community edition
My main issue is this:
After importing all the modules, the git4idea module comes up as a general module type, and not a plugin module type.
This means that when trying to create a new run\debug configuration, I get [none] under "Use classpath of module", instead of of the ability to select the git4idea plugin. This obviously results in a "Run configuration error: no plugin module specified for configuration".
So the question is -
How can I change the general type of imported "git4idea" to plugin type?
Or better yet, what are the steps required in order to import and build/debug/run a plugin from the Intellij community edition repo?
I was able to solve this by manually reordering file directories, sorting out dependencies and editing the .iml file. The type of plugin is defined by changing type="JAVA_MODULE" to type="PLUGIN_MODULE".
...
This is the answer given by Dmitry Jemerov on the official Jetbrains plugin development forum:
The easiest answer to this is "don't". The IntelliJ IDEA Community
Edition project is set up to be developed as a whole, and the
dependencies are set up accordingly. If you want to hack on the Git
plugin, you simply run IDEA using the provided run configuration, it
runs with all plugins enabled, and you simply make whatever changes
you need and test them using the main run configuration.
If you really want, you can set up a new plugin module and point it to
the source code of the git4idea plugin inside the IntelliJ IDEA
Community Edition Git checkout. This is not too hard, but it's
something you'll need to do from scratch, and you can't use the
existing .iml file.
I had the same no plugin module specified for configuration issue. To work around it, instead of importing, I created a new plugin project and used the existing code directory.
when you import the intelij plugin projects
You should run the 'runIde' task in gradle.
Step-by-step instruction
Build your IDEA plugin (usually done with gradle build).
Start Intellij IDEA.
If you have any project opened, go to menu "File->Close all projects" to return to Intellij IDEA startup screen.
Install the plugin you've just built: on the left side of the "Welcome to Intellij IDEA" startup screen go to "Plugins", then click "gear" icon on the right side, it's located to the right of "Marketplace" and "Installed". From the pop-up menu select "Install Plugin from Disk...", navigate to plugin file (usually in build folder) and click "Ignore and continue" when you see the warning message saying something about signature.
Restart Intellij IDEA.
Open the folder with your IDEA plugin.
Wait until IDEA imported your Gradle project.
Put breakpoints inside your plugin code so you can debug it.
Go to menu "Run->Edit configurations".
In the "Run/Debug Configurations" window on the left side click "+".
Select "Gradle" from the pop-up menu.
On the right side change "Name" to "gradle-run-ide" (without quotes).
On the right side under "Run", inside "Tasks and arguments" field enter runIde ("i" must be capital, other letters small).
Click "OK" to save changes.
Go to menu "Run->Debug 'gradle-run-ide'".
A new, black-colored IDEA window should appear.
In this black-colored IDEA window do whatever you need to do in order to invoke methods of your plugin. When you invoke them, the first IDEA window should stop you on breakpoints you set previously.
Happy debugging.
After changing type="JAVA_MODULE" to type="PLUGIN_MODULE" in *.iml file I was getting following error -
Error running 'IdeaPlugin': Wrong SDK type for plugin module
To fix this go to -
Module Settings -> Platform settings -> SDKs.
Click on Add new SDK
Select Intellij Platform plugin SDK
For home directory select your Inetllij installation dir
Select JAVA SDK you want to use with it.
Once this is added got to Module Settings again
Module Settings -> Project settings -> project.
In Project SDK change the JAVA sdk to the SDK we just added in the above steps.
Run/Debug you plugin now.