Gradle support in IntelliJ idea: empty tool window - java

I've got a gradle opensource project I want to tinker with a bit.
Said project is here: https://github.com/Blood-Asp/GT5-Unofficial
When I try to import it into IntelliJ IDE it kind of works (as in - ide does it stuff reading up sources, does gradle wrapper downloads, etc) but IDEA doesn't see any gradle tasks. I --suppose-- this's like that due to lack of gradlew wrapper.
When I run gradle <taskname> or gradle <tasks> by hand in project directory, I see all the tasks and I can run them.
What can be done to allow IDEA to see the gradle tasks as well?

did you first run the setupDecompWorkspace?
The usual process for me setting up a Gradle project in Idea for Forge is as follows
Command Line : gradlew setupDecompWorkspace
Import Gradle project into IDEA
look on the gradle view in idea for genIntellijRuns and run that within idea
Close and reopen the Project.
Program

Related

What exactly IntelliJ is doing when compiling project using Gradle?

IntelliJ IDEA 2016.3 add the ability to delegate build/run to Gradle.
It's clear that when the delegate option is on Gradle is doing everything.
My question is what exactly IntelliJ is doing when this option is off?
I'm asking this because I have custom code inside my Gradle files and it does not seems like this code is executed when building in IntelliJ. When I run gradlew build everything works just fine.
IntelliJ has its own build system, called JPS, which uses the IntelliJ IDEA project and .iml files as the project model. When you're using IntelliJ IDEA's default build system to build the project, it does not execute any code in Maven or Gradle files; it uses its own logic, which can only be extended by writing plugins to JPS.

IntelliJ plugin: maven, gradle and travis-ci

Currently, my built structure for a plugin in is a bit messy: I'm using the normal IDEA project file to build the plugin locally. When I push it to the repo and travis-ci is building it, it uses the maven pom.xml because for travis to work, it always has to download the complete IDEA sources.
Although this works, this has several drawbacks:
I need to keep two built mechanisms up to date. This is
When a new IDEA version is out (every few weeks), I need to change the SDK in maven and in my IDEA settings
When I add a new library, change resources, etc. I need to do this for two the two settings as well
I ran into problems when I kept the IDEA Maven plugin turned on because it saw the pom.xml and interfered with my local built. Turning it off means, I cannot download libraries with Maven which has the feature of tracking dependencies.
I saw that Gradle has an 'idea' plugin and after googling, I got the impression that Gradle is the preferred choice these days. I have seen Best way to add Gradle support to IntelliJ IDEA and I'm sure I can use the answers there to turn my pom.xml into a valid build.gradle.
However, maybe someone else has already done this or can provide a better approach. What I'm looking for is a unified way to build my plugin locally and on Travis-CI.
Some Details
For compiling an IDEA plugin, you need its SDK which you can access through an installation of IDEA or a download of the complete package. Locally, I'm using my installation for the SDK. With Travis, my maven built has the rule to download the tar.gz and extract it.
It turns out that in particular for building an IntelliJ plugin, Gradle seems to have many advantages. This is mainly due to the great IntelliJ plugin for Gradle which makes compiling plugins so much easier. With Gradle, I could turn my >220 lines of Maven build into a few lines of easily readable Gradle code. The main advantages are that
It takes care of downloading and using the correct IDEA SDK while you only have to specify the IDEA version.
It can publish your plugin to your Jetbrains repository and make it instantly available to all users
It fixes items in your plugin.xml, e.g. you can use one central version number in gradle.build and it will keep plugin.xml up-to-date or it can include change-notes
It seamlessly integrates with Travis-CI
How to use Gradle with an existing IDEA plugin
Do it manually. It's much easier.
Create an empty build.gradle file
Look at an example and read through the README (there are many build.gradle of projects at the end) to see what each intellij property does.
Adapt it to your plugin by
Setting the intellij.version you want to build against
Setting your intellij.pluginName
Define where your sources and resources are
Define your plugin version
Define a Gradle wrapper that enables people (and Travis) to build your plugin without having Gradle
Create the gradle wrapper scripts with gradle wrapper
Test and fix your build process locally with ./gradlew assemble
If everything works well, you can push build.gradle, gradlew, gradlew.bat and the gradle-folder to your repo.
Building with Travis-CI
For Travis you want to use the gradlew script for building. To do so, you need to make it executable in the travis run. An example can be found here.

How to prevent IntelliJ from asking to provide the Scala SDK after every Gradle build?

I'm using IntelliJ IDEA (15.0.3) to write a project in Scala over Spark.
Every time I build using the following command
./gradlew clean build idea
IntelliJ pops up the message 'No Scala SDK in module' and asks to setup the Scala SDK version.
Is there a way to permanently specify the SDK version so that building with Gradle won't override it?
In general you don't need to run the idea task with every build. That task generates IDEA project files so you're able to open the project from within the IDE - you usually only need to run it once when setting up the project. Running the task over existing project files can (partially) overwrite them, depending on how the task is configured and apparently does override the SDK configuration changes made in your case.
So just running ./gradlew clean build when building should solve your issue (unless I'm missing/misunderstanding part of your question).

Intellij IDEA and Gradle projects

I have a new project. Should I place apply plugin: 'idea' in build.gradle and run $ gradle idea? Or should I import the gradle project directly into IntelliJ IDEA 14.1? Which one will allow me to add dependencies to build.gradle and have IDEA automatically download & know about them?
With Intellij 14 you can just open the the build.gradle file using Intellij's File --> Open. this will import the gradle project, including all dependencies.
After you change something in the build.gradle file, you can click on "refresh all gradle projects" at the top of the gradle tool window.
You may also mark "use auto-import" under the Build Tools/Gradle tab in Settings. This will resolve all changes made to the gradle project automatically every time you refresh your project.
The idea plugin is the old method of importing a gradle project into Intellij.
With the newer versions of Intellij, it has become redundant.
From my experience using the idea plugin does not always work correctly in IntelliJ and actually IntelliJ documentation guidelines are to simply import build.gradle file.
Also, Peter Niederwieser who is a Principal Software Engineer at Gradleware answered a similar question ~2 years ago mentioning the following:
If you use Gradle's idea task to generate project files, this is normal, as there is no way to tell IDEA what the class path of the build script itself is. If you instead use IDEA's Gradle integration ("Import from Gradle model"), this problem doesn't exist.
Bottom line, your safer way to go would be importing gradle project directly from IntelliJ.
You can create a new Gradle Project in IntelliJ, and it will handle all of the dependencies and integrate well with Gradle. You can see here for more info and specifics.

Eclipse gradle refresh from cmd

I wondered if there is a cmd command for refreshing an eclipse gradle project?
Normally you would right-click -> gradle -> refresh -> refresh all.
I am looking for something like gradlew project:refresh eclipse, to be able to update projects using a .bat file.
Cheers :)
It depends on how you are integrating with Eclipse. If you are using the project file generation approach, just run gradlew eclipse (or gradlew cleanEclipse eclipse) another time, then hit F5 to refresh the Eclipse project. If you are using the Eclipse plugin (also known as Eclipse Gradle integration), you can only refresh in the IDE, in the way you already described (but perhaps you could assign a shortcut).
Reading a documentation can give you the answer - http://www.gradle.org/docs/current/userguide/eclipse_plugin.html
Just apply the eclipse plugin in your gradle buildscript(s) and you will be able to run gradle eclipse from command line.

Categories

Resources