Run intellij plugin on Android Studio - intellij-plugin

I'm developing an intellij plugin supposed to be used in android studio.
I've already setup the plugin development environment, but when I hit "Run" command it starts a new intellij instance with the plugin installed.
What I'm looking for is how to run the plugin directly on Android Studio, is that possibile? The only place where I think it can be configured is from "Run configurations" but I do not find anything useful there.
Thanks

You can specify the platform to run on in the IntelliJ Platform Plugin SDK settings, under Platform Settings | SDKs in the Project Structure settings. Point the IntelliJ Platform Plugin SDK home path to your Android Studio installation.
Another option is to create a new Plugin Run Configuration. In the Run Configuration it is possible to specify the JRE to run on. Click on the ... button there and select an Android Studio installation directory (e.g. /Applications/Android Studio.app/Contents on the Mac). This way it is possible to create a Run Configuration for all IntelliJ Platform IDEs you want to test your plugin on.

Related

How to get jrebel, jetty, gradle and intellij idea working together

I have installed JRebel plugin for Intellij Idea and my project is running with Jetty gradle plugin.
I run my project with "Run with JRebel", project perfectly runs, but hot swap which i expected is not working.
Does anybody have an understandable and detailed instruction how to set up Jrebel for work with jetty, gradle and intellij idea?
1) You need to add JRebel Agent as a vm argument into Jetty.
Depending on your environment:
Windows 64-bit JDK jrebel64.dll
Windows 32-bit JDK jrebel32.dll
Mac OS X 64-bit JDK libjrebel64.dylib
Mac OS X 32-bit JDK libjrebel32.dylib
Linux 64-bit JDK libjrebel64.so
Linux 32-bit JDK libjrebel32.so
You need to add -agenthpath argument in gradle.properties file:
org.gradle.jvmargs=-agentpath:[c:\path\to\]lib\jrebel64.dll
2) You need to generate rebel.xml files for your projects in JRebel IDE plugin
Right-click on the project node in the Project View and select JRebel > rebel.xml. Alternatively, you can check projet in JRebel Modules window
3) You need to deploy(run) your projects into the Jetty with rebel.xml configuration files and when you make a code change in a .java file you need to generate new .class file. IntelliJ IDEA does not compile classes on save by default. Press Ctrl+Shift+F9 to compile the current file, module or package (you can also find this command via Build > Make Project).

Intellij plugin development "the selected directory is not a valid home for intellij platform plugin sdk"

I'm following these guidelines on how to develop Intellij plugin.
So I
Open project settings.
Project SDK --> New
Choose the community edition path I just downloaded
Expected the directory is selected fine.
Actual: I get the error message:
"the selected directory is not a valid home for intellij platform plugin sdk"
See screenshot:
Am I doing something wrong?
Thanks
Intellij platform plugin sdk home should be your installed or builded IntelliJ, not sources. You can add that intellij-community folder as sources to your IntelliJ SDK later or not at all.
Goto Intellij installed directory
C:\ProgramFiles\JetBrains\IntelliJ IDEA Community Edition 2016.3.4
Select plugin folder
Create a directory (eg: scala)
Copy the scala lib folder
Restart the intellij
In my case, I had to download a newer IDEA version (Community Edition) and after the installation, everything worked fine.
This is the official and updated link for setting up your plugin development environment.

Can I get project build command in intellij plugin?

I'm trying to make plugin for Intellij.
Can I get project build command in plugin? (like make dist or gbs build --include-all)
And does it works for Android Studio?
In IntelliJ IDEA, to build a project, call
CompilerManager.getInstance(project).make(null);
Android Studio does not use IntelliJ IDEA's build system, so you need to call a different API:
GradleInvoker.getInstance(project).compileJava(moduleManager.getModules());

Can't get Changes tool window (Alt+9) to show on IntelliJ IDEA

I can't get the Changes tool window to show on this project.
The project is imported "from sources" and has no facet and no sdk. Which is ok because I'm only editing it in the IDE and running from the terminal.
I'm on Windows 8.
The tool window does show when I open another java web maven project there.
It also does show for the first (no sdk) project when I'm on Ubuntu.
What might the Changes tool window not like about my project?
The IDE wasn't aware of Git in my project.
That happened because the directory I import this project from isn't the same as the Git repository directory, the former is inside the later.
I fixed it in: VCS > Enable Version Control Integration

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.