Can JetGradle Be Used In IntelliJ 12 Alongside Gradle Generated Project Files That Have Scala Facets?


(Tim Leahy) #1

I’ve been trying to make the switch to IntelliJ and Gradle for the Java/Scala projects at my company. From the command line Gradle has been great but I’ve run into a problem when using Gradle with IntelliJ and projects with Scala facets.

I’ve tried importing projects in both ways and the only one I’ve been able to get Scala facets working is to run:

gradle idea

using the Gradle IDEA plugin. After that all I need to do it open the ipr file for the project and the projects work fine.

However, there are some Gradle tasks that I would like to run from within IntelliJ for various things (code generation being the biggest one). I would like to be able to use JetGradle to run those tasks. The problem is when I link the Gradle project to JetGradle, the dependencies in each project break the Scala facet’s compiler settings.

It’s a multi-module project. Here is the build.gradle for the parent:

allprojects {
    apply plugin: 'idea'
      version = '1.0'
    group = 'company-x'
      repositories {
        mavenCentral()
    }
}

And here’s the build.gradle for the scala modules:

apply plugin: 'scala'
  dependencies {
  compile 'org.scala-lang:scala-library:2.10.1',
          'org.scala-lang:scala-reflect:2.10.1',
          'org.scala-lang:scala-compiler:2.10.1',
          'org.slf4j:slf4j-log4j12:1.7.2',
          'com.typesafe.akka:akka-actor_2.10:2.1.4'
    testCompile 'junit:junit:4.8.1',
              'org.scalatest:scalatest:1.2'
}

Before linking the project to JetGradle the Scala facet is setup with a library called ‘scala-compiler-2.10.1’ that contains the Scala compiler, library, and reflect jars and src. After linking the project, the project libraries are replaced with all of the Gradle project dependencies. The Scala facet then gives the error:

Compiler library: no scala-library*.jar found When I look at the libraries again, there is still a library called ‘scala-compiler-2.10.1’ but it’s only the compiler. The library and reflect jars are now separated out.

Has anyone out there figured out how to get the Scala facet and JetGradle to play nicely with one another?