"No such property" when refreshing project in IntelliJ IDEA Ultimate - intellij-idea

I have a groovy project in IntelliJ Ultimate 2017.1.5 based on gradle. I'm using groovy 2.4.4. My IDEA is set up to run gradle with gradle 4.0.2.
Gradle 'webclient' project refresh failed
Error:No such property: from for class: org.gradle.api.internal.tasks.DefaultTaskOutputs$TaskOutputUnionFileCollection
Unfortunately, nothing in IntelliJ tells me where this error comes from. All I know is, from the package name, that it has to do with gradle. This IDE is seemingly really unhelpful. It either works, which is rarely, and when it doesn't work, doesn't give you much error reporting.

I found a work-around. If I add
apply plugin: 'idea'
To the top of my module's build.gradle
and run
./gradlew idea
It downloads my dependencies in to the right place (where, IDK, but it works - im guessing IDEA knows how to find my local ~/.gradle repo).
But refreshing the project from the UI still fails. It would be nice of IntelliJ told you what it's doing. I don't know why they want to hide everything it's doing, when the system is so brittle and breakable.

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.

Is it possible to customize IntelliJ IDEA 14.0's "Refresh all Gradle projects" / Gradle projects sync behavior?

When I hit the Refresh all Gradle projects button in IntelliJ IDEA, it uses its built-in Gradle scripts comprehension mechanism to produce the IDE's build configuration. However, it doesn't always do exactly what I want. Is there a way to customize its behavior? Perhaps make IDEA understand Gradle's IDEA plugin?
Experiments show that IntelliJ IDEA is completely oblivious to the apply plugin: 'idea'. There is no auto-complete and no Gradle tasks from it are recognized. The IDEA's Gradle integration roadmap linked from Gradle's tooling page is severely outdated and doesn't seem to mention anything on this subject.
IntelliJ is affected by apply plugin: 'idea' (which should always be done) and (some of the) related configuration in the build script. There is already quite some auto-completion, but obviously it's not perfect yet. Expect improvements with every new IntelliJ and Gradle release.
For now, if you want utmost customizability, consider generating the IntelliJ project with gradle idea, rather than using IntelliJ's Gradle integration.

Gradle dependency cannot show in intellij idea

I used maven a lot before, now, I want to investigate about gradle, but it seems gradle dont give me a good first impression.
When I config the repo, and build the project, intellij idea show me build successful, however, I cannot see the dependency from the project view, I have no idea why, I try to create several projects with almost same configuration, some of them will show dependency, some of them not, I have no idea why. Sometimes, the dependency will come out suddenly, and actually, I found gradle already download those dependnecy into the catch folder, but I have no idea why intellij cannot show it and use it.
Can someome show me how to fight with gradle and intellij?
Br,
Tim

How to use an existing Gradle project in IntelliJ IDEA 13/14

I am using Gradle and IntelliJ IDEA. Normally I use apply plugin: 'idea' to generate the IDEA project files. With IDEA 12 I was used to work with the JetGradle tool view.
Now I updated to IDEA 13 and the JetGradle tool view is gone. When I use the old run configuration gradle:run, IDEA tells me:
Error running gradle:run:
Module 'X' is not backed by gradle.
How can I activate the gradle build in IDEA 13 without the tool view? I found this tweet from Cédric Champeau, but was still not able to solve it. Do I have to turn my simple gradle project into a multi module project or what?
Update
With File - Import Project ... I can import the build.gradle file and than I can choose View - Tool Windows - Gradle, which was hidden before. Is this the way to go?
What you state in your update is the correct way to go. The Gradle Plug-in received a lot of love in the IDEA 13 update and has changed a bit. An import of the Gradle build file is necessary. And as you have noted, the JetGradle tool window is now named simple Gradle
Tested with Gradle 1.9. In my opinion there are 2 issues:
Issue 1: when using gradlew idea I expect to receive a valid IDEA project without the need to import it. There are discussions on the gradle forum, see this Gradle forum post. In this Jetbrains forum post it is told that there is no backward compatibility with IntelliJ 12 gradle projects at the moment.
Issue 2: With IDEA 12 it was possible to open the JetGradle View even if the current project was not a gradle projcet. But the view displayed the message "There is no linked Gradle project. You can Add one" and offered you the possibility to convert the project to an gradle project with a simple click. In IDEA 13 it is not possible to open the Gradle View when the current project is not a gradle project. I asked a question here.
In the Gradle forum post mentioned above Peter Niederweiser stated:
The preferred way of integrating with IDEA 13 is to use IDEA's Gradle import, without running gradle idea. (You should still apply the idea plugin though, and it's still important to apply it to allprojects {} rather than subprojects {} when dealing with multi-project builds.)
So the answer from Mark Vedder is correct, altough I would have liked to have more information.
I have found that when you initially import a gradle project into Idea, if you don't have all of your directories created yet, the gradle tool window vanishes while you are importing into Idea. (It is there when the import starts, but at the end it disappears.) However, if I manually build the project first (on a mac, >gradle clean build), and then go back to IDEA and import the project, the gradle tool window stays active. Hopefully this will help someone else.
you can go to Project Structure (Ctrl + Alt + Shift +S) and then under the Modules, click "Import Module" and choose your build.gradle from the project file repo. It will make the module gradle aware and then you will also see the Gradle window
The simplest way to do this is to use the Import Project option if you cannot use the gradlew idea to produce the idea project

IntelliJ 12 + Gradle 1.3 - Basic Gradle syntax seems non-functional

I am attempting to play around with Gradle integration in IntelliJ Idea (Ultimate) v12.
It seems even if $GRADLE_HOME is configured properly, basic syntax such as 'apply', 'dependencies', etc. is not recognized.
I would seem like the solution should be something simple. Any help is appreciated.
IntelliJ IDEA doesn't currently offer syntax completion for Gradle build scripts. All you get is the standard Groovy support.
I was having the same problem until this morning. I did the following steps and it solved itself:
added the root build.gradle file (we have several) to the JetGradle tab and refreshed
updated to IDEA 12.0.1 (it restarts and reindexes)
I think doing the first one and restarting may be enough, but I'm not sure.
I'm using Intellij 13 and have had similar problems. What I noticed was, creating a new Project from Intellij (i.e. new Groovy Project or Gradle project), I get the syntax error markers. I also have noticed it didn't do a good job pulling in Gradle dependencies.
On the other hand, if I Import a Project through an already created build.gradle file, the syntax error markings go away and the dependencies seem to play more nicely. Not sure if this works for you.
With Intellij 14 and Gradle 2.3 I found that adding {$GRADLE_HOME}/lib and {$GRADLE_HOME}/lib/plugins as libraries in my project settings got rid of all the warnings like "dependencies cannot be applied to groovy.lang.Closure".