IntelliJ Gradle Plugin

When importing a build.gradle file using the IntelliJ Gradle plugin I noticed that certain configuration options are not applied. For example, the IDE plugin picks up any changes made to excludeDirs when importing (see below). The buildDir correctly gets removed as an excludedDir in the module settings.

idea {
 module {
  excludeDirs -= file(buildDir)
 }
}

However, other options like inheritOutputDirs don’t seem to get picked up. Is this expected?

We do pass the inheritOutputDirs information to the tooling api which is used the by the Gradle plugin. Can you paste the code how you configure the inheritOutputDirs? Also, might be worth asking JetBrains guys via their bug tracker.

subprojects {
    apply plugin: 'idea'
      idea {
        module {
            scopes.PROVIDED.plus += configurations.providedCompile // this works
              // none of these seem to be taken into account when importing
            inheritOutputDirs = false
            outputDir = file("${rootDir}/workspaces/idea/out")
            iml.generateTo = file(projectDir)
        }
       }

So when doing an import, the default output dir is still set to “${rootDir}/out”. Also, the imls get generated into rootDir instead of in the project dir like I specify. Again, this is only when importing from IntelliJ - when I run ‘gradle idea’ from the command line everything seems to work fine.

Regarding the output dir / inherit output dirs - we definitely pass this information to the tooling api (and we have integ tests that prove this :). Can you report this problem to the JetGradle issue tracker?

Regarding the iml.generateTo - this information is not available in the tooling api. JetGradle does not really need this information because it does not use *iml files.

Hope that helps!

Thanks, I’ll submit an issue for it. As for the iml.generateTo - what exactly generates the iml files then? Is it gradle itself and not the intellij gradle plugin?

I suspect that JetGradle generates the imls when importing to IDEA. When IDEA talks to Gradle via the tooling api, the imls are not generated.

What issue was ever filed here? I am struggling with the IDEA/Gradle integration as well, wanting to customize things in the iml files, but finding that those are not persisted after i do a “Gradle Refresh” from inside intellij which apparently does not use the ‘gradle idea’ task or ‘gradle ideaModule’ task to generate things…

I would also like to hook various tasks into the gradle refresh, so that, for example, I can copy in a custom inspection profile into the intellij project on ‘Gradle Refresh’. Anyway to hook into the tooling api to do these things?

I asked for a comment from IntelliJ because your question is more about extending IJ.

The support to hook an execution of any tasks before/after ‘import’ (and other IDE events like ‘Make’, ‘Rebuild’, ‘Run’, ‘Debug’ etc) are planned for IDEA 14.

Please, watch http://youtrack.jetbrains.com/issue/IDEA-125930 feature request for updates.

Regarding customization of iml files, I believe, better approach is to keep build scripts IDE-agnostic.

The main focus of IDEA Gradle integration is to improve understanding of Gradle project model using tooling api. Ideally, it should work transparetly for a user, without workarounds in build scripts.

Of course, there are still a lot of unsupported features and in some cases gradle idea plugin configuration can help.

Anyway, if you miss something in IDEA Gradle integration, please, file an issue at http://youtrack.jetbrains.com/issues/IDEA for Gradle subsystem

Ok thanks. I have commented there about some use-cases here that I think are interesting and useful…

thanks for this information Matt, we will try to provide the features you note