Can I get project build command in intellij plugin? - intellij-idea

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());

Related

IntelliJ IDEA: Unable to create a Gradle project

I'm facing difficulties in setting up a gradle project. During setting up of the Gradle settings in the wizard,
I am not able to use the default recommended gradle wrapper because it downloads the Gradle and the network connectivity is very bad. So I go with the local gradle distribution which I have installed in my Ubuntu. On refreshing of the gradle project after creation, I always get stuck to this error. When I run the gradle build command through the terminal on the empty project, It works fine.
I have also tried the troubleshooting solutions given by the IDE. But, that made no improvements. Need assistance to solve this problem.
Comment if any additional info required.
As no-one else has chipped in, an approach that should work is to use the Gradle Idea Plugin instead of relying on the build in support Gradle in Idea. In my experience the plugin supports a wider range of Gradle project structures than Ideasupports directly. So you would
Create a Gradle project outside Idea and confirm it all works on from the command line.
Add the Idea plugin to the project
Run 'gradle cleanIdea idea' to generate the Idea project files.
Open up the newly generated project files from Idea and off you go.

Run intellij plugin on Android Studio

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.

How to use script to build IntelliJ Idea project to a jar

i have created an IntelliJ Idea (Community Edition) java project. the project is quite simple. it only contains a main() method, but uses another 2 jars as dependencies. I also created an artifact to the project to build it to a jar.
My question is there any way to build the jar using script? because I want to add the build process to an existing build script.
thanks
IDEA doesn't do anything with the code on its own, it just counts on the default tools provided by SDK. In short, you will need javac and jar for packaging.

IntelliJ IDEA 14.1.4 + Gradle: Cannot Compile Groovy Files

Each time I attempt to create a new IntelliJ 14.1.4 project on Windows with Gradle integration I receive the following error during the 'Make' command when I have any Groovy source files included in the project...
Error:Cannot compile Groovy files: no Groovy library is defined for module 'GradleCommandLine'
I have tried:
Creating a Gradle project through the new project wizard in IntelliJ, choosing Groovy as a an 'Additional Library'
Creating a new Gradle project outside of IntelliJ using the gradle init --type groovy-library command, then opening IntelliJ which finds the gradle.build file and automatically links to the project
Converting an existing project that was working with the IvyIDEA plugin to a Gradle build
I have tried adding (made sure) my groovy-all library as a 'Global Library' within the project structure
Each of these gave me the same 'Cannot compile Groovy files' error.
What does work:
I can run the gradle war command which compiles correctly and I can deploy the build war to an application server (in my case Tomcat 7.0.47)
However in watching the Getting Started with Gradle in IntelliJ IDEA 13 (they do not have one for IntelliJ 14) demo video, they are able to just run the standard 'Make' and add the unexploded war as a build artifact.
Also had a colleague using the Mac version of IntelliJ 14.1.4 do the same 'I have tried' attempts above and he did not run into any issues. They even imported the same project I was having issues with and it was able to do the 'Make' without any changes to settings.
Pointing to local Gradle installation solved issue. There was an issue with a corporate proxy preventing the Gradle distribution from installing properly.

Intellij Idea 12 gradle build

I am trying to build a project with gradle from within Intellij Idea 12 (commercial editon) but this keeps failing. I have the gradle plugin enabled and also the gradle gui plugin. The native project gradle import is working. (I'm not using gradle idea btw.)
When using the bash I only run gradle war to build my web application. Now I want to do the same from within Intellij.
The gradle gui plugin seems to be using the wrong JDK (I guess it's the one Idea uses, a 1.6 JDK) and therefor fails to compile because this is a JDK 1.7 project. And it doesn't integrate well into Idea because it seems like an external build process (like triggering external ant tasks).
What I have done so far is to configure my own artifact in a way that is equivalent to the one gradle war would have build. But that means a lot of configuration and simply feels wrong. There should be a better way?
So what do I have to do to make Idea compile a project in a way similar to the command line gradle task?
JetGradle plugin doesn't provide native tasks support at the moment. It's scheduled for v.12.1 - IDEA-95897. Feel free to track the plugin's news and update it manually as soon as corresponding support is provided.