JetGradle tool window not available

Hi

When I open a gradle project, the project opens, but I don't see the JetGradle tool window. In the preferences, my project is not listed in the 'linked project' list. I saw the post http://devnet.jetbrains.com/message/5503444.
This doesn't work if I open the project was created using the gradle idea plugin (gradlew idea) task. Is there way to link this project once created using the 'idea' task? We have extend the grails-gradle plugin to set the right source directories and generate run configurations. It would be nice if we can link the projects created and use the gradle tool view.

Anand

12 comments

Hi Anand,

The only way to link gradle project with IntelliJ project is to use IntelliJ project/module import wizard.
IJ gradle integration in v13 (I assume you are using IJ v.13) uses gradle build scripts as a "single source of truth". So, ideally all project settings should be imported from *.gradle files.

Lets try the following:
1. remove IDEA files ('.idea' folder, *.iml files etc.)
2. Make sure that you have configured right source directories in the following place:

apply plugin: 'idea'
idea {     module {         testSourceDirs += file('src/some-test/java')
        ...     } }


3. Import the project again (but do not run gradlew idea!)

Does it help?

Vlad

0

Hi Vlad,

Thanks for the response. Your suggestion works. I have not tried setting the source paths yet. Why isn't the source paths set by default. It would be nice to if intellij could set the source paths, spring, web facets etc like regular grails project, instead of every project having to configure these in the build.gradle file.

Is that something that we can expect in intellij 13?

Anand

0

All source paths imported from gradle, so if gradle knows about the source path, intelij also should be aware about it (without explicit usage of 'idea' script block).

e.g.
sample.png


You may need to use 'idea' script block only if you have explicit complex configuration of sourcesets' type or classpath (e.g. in a separate gradle task) and for some reason it can not be recognized by the gradle tooling api to tell intellij.
In that case you may fix it with excplicit declaration in 'idea' script block

0

btw, web facets and web artifacts already created automatically for gradle web projects

0

The sample project that you provided is a plain java/groovy project. But for grails projects/plugins, the source paths are not set correctly and the web, spring facets are not added. Since grails has a pretty standard directory structures (grails-app/controllers, grails-app/services, src/groovy, src/java etc), wouldn't it be possible for intellij to recognize the project as a gradle app and set these during import?

Thanks
Anand

0

The custom plugin that we have does that when you run the idea tasks. But Intellj 13 is not able to import that.

Anand

0

could you create an issue at http://youtrack.jetbrains.com with a simple project sample attached to illustrate the problem, please?

0

Created an issue - http://youtrack.jetbrains.com/issue/OC-8785 and attached a sample grails project with build.gradle.

Anand

0

Thanks Anand,

I've looked into the project. You are using org.grails:grails-gradle-plugin. I've found the source of the plugin - https://github.com/grails/grails-gradle-plugin/blob/master/src/main/groovy/org/grails/gradle/plugin/GrailsPlugin.groovy
You can see, there is no additional sourcesets configured for this plugin. See an example of such configuration https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/groovy/org/gradle/api/plugins/JavaPlugin.java method "configureSourceSets".

That's why you do not have source sets in IDEA.

Also this plugin does not provide configuration for web application (ideally it should extends from gradle war plugin - http://www.gradle.org/docs/current/userguide/war_plugin.html)

That's why you do not have web facet created in IDEA.

As soon as grails plugin adds grails specific sourcesets and extends gradle war plugin - you will get those in IDEA automatically.

0

Thanks for looking into this Vlad. As I stated earlier, our tools group has exented the grails gradle plugin and sets the source sets. It works when I run the 'idea' task, but not when importing the project via Intellij. The code looks something like this. Seems to set the source sets when the task is run.

void apply(Project project) {
     this.project = project
      project.plugins.apply(GrailsPlugin)

     ....

     project.plugins.withType(IdeaPlugin) {
           def configurer = new GrailsIntellijConfigurer(project)   // This is a utility class that sets the sources, etc...
          configurer.configureProject()
          configurer.configureWorkspace()
           def grailsModuleConfig = project.tasks.create( 'grailsIdeaModule')
          grailsModuleConfig.doFirst {
               configurer.configureModule()
          }

           grailsModuleConfig.dependsOn('grails-compile')
          project.tasks.withType(GenerateIdeaModule) { it.dependsOn(grailsModuleConfig) }

      }
}

I also looked at the java gradle plugin, which seems to set the source sets in the 'apply' phase.
When intellij imports the project, does it run the 'idea' task?

Thanks
Anand

0

IntelliJ uses Gradle Tooling API and all source sets known to gradle should be available for IntelliJ.
Is your project open source? Can I look on you plugin extension?

0

Vlad,

My project is not an open source project. But I will ask the tooling group (who wrote the plugin extension), if I can provide you the source for the plugin.
There is an open issue in gradle-grails project - https://github.com/grails/grails-gradle-plugin/pull/46 to set sourcesets and other things in gradle plugin. I think, that might fix my problem.

Anand

0

Please sign in to leave a comment.