Studio 6.4.1 IDEA modules not found after new project

Hi
Just tried studio 6.4.1 and the ‘gradle get stuck’ issue when creating a new project is solved -> gratz !
However, just tried to create a blank project with fts, reports, charts and then IDEA complains that it cannot find modules ‘.iml’ files (see screenshot attached). Actually files are there, I suspect they are generated by studio a bit late in the process of creating idea files (async issue ?)
And still have the issue that gradle wrapper is not created in the project (‘gradle/wrapper’ directory and ‘gradlew.bat’ file).

studio-6.4.1-idea-error

Could you just close project in IDEA and reopen it?

And why do you need Gradle wrapper and what do you do to create it?

More simple, I just clicked on ‘keep all’ files, but there is probably an async issue somewhere in the process of generating IDEA project.

About Gradle Wrapper, it is the recommended way to use Gradle in a project , studio used to generate the wrapper when creating an IDEA project and does not it anymore. Wrapper is the way to ensure your project is built with a precise version of gradle, without the burden of downloading it yourself.

My goal is to be able to build the project in IDEA with gradle plugin, exactly like studio does, which used to work out of the box.

Before 6.4, when studio generated an IDEA project it was setting the ‘gradle wrapper’ in the project. I tested that months ago by generating all sample projects. I attached the ‘sample-akkount’ directory structure generated by studio at this time so that you can see the gradle/wrapper subdirectory. Not sure about studio version (6.1, 6.2 maybe).

With 6.4, studio did not managed anymore to create the wrapper, either stuck/deadlock or file lock exception (as reported in my previous messages) : error registering project files tree
java.nio.file.FileSystemException: d:\dev\studio-projects\untitled\gradle\wrapper: the file is locked by another process

With 6.4.1, the gradle wrapper is not created anymore by studio, which indeed prevents the issues above but is a loss of feature IHMO. Especially when the wrapper task is defined in the ‘build.gradle’ generated by studio, it is just a matter of executing ‘gradle wrapper’ (w/out sync issues of course). Which I’m quite certain it was doing before.


task wrapper(type: Wrapper) {
    gradleVersion = '3.1'
}

Now to circumvent the issue with IDEA one should use the ‘custom gradle wrapper’ instead of the ‘default gradle wrapper’, this will generate the wrapper (through ‘gradle wrapper’ command) with IDEA gradle plugin. Then it is possible to choose ‘use default gradle wrapper’ to stick to the version generated.

NB : I’m using IDEA 2015 ultimate, maybe the ultimate version is doing more stuff than the basic one when creating a new project, and that stuff would collide with studio generation process in some way.

sample-akkount.rar (3.9M)

Hi Michael,

We’ve checked Gradle wrapper generation in the last Studio and didn’t find any problems - it successfully creates wrapper v.3.1 in the project root folder.

Perhaps the problem is somewhere in the interaction of Gradle daemon and your IDEA Gradle plugin.

I think the following approach should work for everybody, because we constantly use and test it:

  • Close the project in IDEA and kill all Gradle daemons

  • In Studio: Build > Create or update Gradle wrapper (needed only for building from command line further)

  • In Studio: Build > Create or update IDEA project files

  • Start IDEA

  • Click IDE on Project properties tab in Studio or open *.ipr file in IDEA. Don’t accept any suggestions from IDEA about importing project from Gradle.

  • Now you can edit your project in IDEA and build from command line, for example gradlew deploy. If you have Premium Add-ons in your project, you need to specify credentials in the command line as described here. You can create convenient *.bat files for building or define External Tools in IDEA, see attached screenshot for example.

We don’t recommend using IDEA Gradle integration plugin as we cannot control it and cannot guarantee it is working properly with CUBA projects. Reportedly it was buggy up until recently, and your version of IDEA is not quite fresh, so it can be a problem.

If you want a tested and 100% working approach - stick with Studio and command line. Besides, you can easily invoke Gradle tasks from IDEA as I said above.

Edit Tool

Thanks Konstantin. I agree that one should not try to use a different version of Gradle than Studio, hence the wrapper.

Once the wrapper is installed, IDEA plugin is just throwing gradle command lines at the wrapper like a human would do (and you can see and edit them), so using IDEA integration is not risky at this point.

I don’t know why on my system gradle wrapper is not created by Studio automatically on new project. But now that I know about the ‘Create or update Gradle wrapper’, I have an easy workaround.

*I don’t know why on my system gradle wrapper is not created by Studio automatically on new project. *

In fact, it has never happened automatically, only by executing gradle wrapper or through the menu command.

Hi Konstantin. Between June 2016 and December 2016 I have tested all studio samples. Attached is the screenshot of directories and files created by Studio at that time. You can clearly see by files creation dates that the wrapper was generated by Studio.

But I made additional tests today to be sure and I got it : Studio does create gradle wrapper for a new sample project, and only for them. If you create a project from scratch it won’t. I suggest not creating gradle wraper for sample projects also in order to remove confusion.

studio-projects-samples-dirstruct-JUN16-DEC16