Intellij error: no scala-library*.jar found


(kevin.stembridge.dev) #1

I’m using the idea plugin to configure my multi-module project in Intellij. When I try to run a unit test from within Intellij I get the following error in the console:

scala: No ‘scala-library*.jar’ in Scala compiler library in mahana-modelgen-runtime

The generated *.ipr file has this in it:

<component name="libraryTable">
    <library name="scala-compiler-2.10.0">
      <CLASSES>
        <root url="jar:///home/kevin/.gradle/caches/artifacts-23/filestore/org.scala-lang/scala-compiler/2.10.0/jar/fec8066cd2b4f8dc7ff7ba7a8e0a792939d9f9a/scala-compiler-2.10.0.jar!/"/>
        <root url="jar:///home/kevin/.gradle/caches/artifacts-23/filestore/org.scala-lang/scala-library/2.10.0/jar/43c6d98b445187c6b459a582c774ffb025120ef4/scala-library-2.10.0.jar!/"/>
        <root url="jar:///home/kevin/.gradle/caches/artifacts-23/filestore/org.scala-lang/scala-reflect/2.10.0/jar/10ec1256a6e875e886fec050edb0669166912d0d/scala-reflect-2.10.0.jar!/"/>
      </CLASSES>
      <JAVADOC/>
      <SOURCES/>
    </library>
  </component>

And the module .iml file has this in it:

<component name="FacetManager">
    <facet type="scala" name="Scala">
      <configuration>
        <option name="compilerLibraryLevel" value="Project"/>
        <option name="compilerLibraryName" value="scala-compiler-2.10.0"/>
      </configuration>
    </facet>
  </component>

Is there perhaps a name clash going on where intellij thinks that the ‘scala-compiler-2.10.0’ compiler libary is actually just the scala-compiler jar?

I’m using Intellij 12.1.2 and gradle 1.5.


(Peter Niederwieser) #2

I’ve never heard of this error before, and running tests works fine for me. Make sure that you only (re)open the IDEA project after it has been fully generated (i.e. the Gradle build has finished), that you have the latest Scala plugin installed, and that the correct Scala version is selected in the modules’ Scala facet. If this doesn’t help, can you provide a reproducible example?


(kevin.stembridge.dev) #3

Hi Peter, I started from scratch with a new project to try and create a reproducible example. The test ran fine without any errors.

There were a couple of differences between the new project and the faulty one.

In the faulty project, there were iml files for each module in the root of the project as well as one in each module. If I deleted all *.iml files and the *.ipr file, they all got regenerated by gradle cleanIdea idea.

In the project structure view of the faulty project, every dependency was listed in the libraries view whereas in the new project only the scala-compiler-2.10.0 library was listed.

The faulty project had a .idea directory in the root whereas the new project did not. I found that if I deleted this directory as well as every other idea file (*.iml, *.ipr, *.iws) and then ran gradle cleanIdea idea, everything worked.

So for some reason, when there is a .idea directory present (or maybe its something specific to what is in that directory), the gradle idea plugin generates *.iml files in the project root for each module and incorrectly lists every dependency as a library.

Anyways, I’m up and running again. Thanks for your help.


(Peter Niederwieser) #4

Sounds like you had IDEA files/dirs in your project beyond those generated by Gradle, and IDEA got confused by this. ‘gradle cleanIdea’ will only delete the files generated by ‘gradle idea’.

So for some reason, when there is a .idea directory present (or maybe its something specific to what is in that directory), the gradle idea plugin generates *.iml files in the project root for each module and incorrectly lists every dependency as a library.

Gradle’s IDEA plugin doesn’t know about the ‘.idea’ directory or its contents. It’s probably a (confused) IDEA that generated those iml files.

To summarize, as long as you make sure that no other IDEA files/dirs are present beyond those generated by Gradle, you should be fine.


(kevin.stembridge.dev) #5

Cool. Thanks very much.