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

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.

Related

intellij hybris class recompile not working

I installed hybris plugin.
Imported project with it.
Have done ant clean all.
Then, if I try to build->recompile class it's not working. Seems like idea doesn't see classes generated by ant.
If I do build->rebuild project and then build->recompile class it's working fine, but it's not convenient at all. I believe there is fix to this, but I couldn't find it.
This is usual error I've got(packages are different for different cases):
this is essentially the expected behaviour. You can't mix "ant" build
and "native IDEA" build. Those are two separate build systems.
This is an explanation of hybris plugin developer (hybris-integration.atlassian.net/browse/IIPS-120)
And he suggests a solution for that:
before you try to import the project you need to do ant clean all (you will not need to use ant afterwards)
import the project using hybris plugin.
Press Build->Recompile project
Then you can create or modify your test run configuration if needed.
Recompile your classes and so on directly in Idea.
Also, he mentioned deal with JRebel here (hybris-integration.atlassian.net/browse/IIPS-47)
we support both compilation modes. Ant targets and idea internal. They
shouldn't be mixed as idea has it's own compilation model/cache. If
you use idea compilation then you can use JRebel or hotswap.
You cant hotswap classes in hybris without the help of a hotswap agent.There is a tool available in the market called JRebel. It is a good commercial tool if one can afford. However, if you are an open-sourcist, there is a promising alternative to JRebel, which is DCEVM (Dynamic Code Evolution Virtual Machine) along with HotswapAgent.
I don't know if this help,
you can start another cmd console, and run
setantenv and ant build to hotswap class in runtime.

How to make a ExternalSystemRunConfiguration of type Application, in IntelliJ plugin

So, I've been looking around for this for awhile, and since Jetbrains doesn't really document Plugin development for their IDEs, I just haven't been able to find the answer. I just need to figure out what I should be using in the constructor of ExternalSystemRunConfiguration if I'm making a Application run configuration Like this one
The "Application" run configuration is implemented by the ApplicationConfiguration class, not by ExternalSystemRunConfiguration.

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 write an IntelliJ IDEA Plugin?

IDEA has many plugins to use. I.e. IDEtalk is one of them which I use. How can I code a simple plugin that just connects to Internet and shows a web page? (no need for an address bar but it is not a problem to be). I want my plugin's shortcut's button locate at my IDE as like IDEtalk, Commander, Maven Projects etc.
Any ideas?
Check the documentation and the source code of the other plug-ins available in the public git repository of the Community Edition.
There is a Creating Your First Plugin guide on JetBrains web site. It covers all the needed steps from plugin creation to deployment to the plugin repository.
You might also want take a look in the source code of a simple plugin like Twitter Integration Plugin which I recently implemented. Or check a more complex one like this one.

How make Eclipse instrument classes at build time?

Sometimes I have to perform some custom bytecode transformation.
I have used mainly asm and javaassit.
Inside eclipse usually I run my code with the -javaagent jvm parameter. Outside eclipse I use maven, ant, or the command prompt to invoke the weavers before running the application code.
But the point is that: I would like to perform instrumentation at build time inside eclipse.
What is the best way to do it?
Is there an already made plugin that I can connect to by implementing some api?
May I script this with eclipse monkey?
May I use an ant builder and invoke my weaver with it?
Should I look at the AspectJ plugin (must be huge) and try to figure out how to make my own plugin?
Should I look at the some other plugin to get inspiration?
Thanks.
You can create an annotation processor. This way you will be able to use it with ant, maven and any IDE (not only Eclipse).
Here is an example:
http://java.dzone.com/news/using-java-6-processors