Setup Issue: "Cannot find Scala library on the classpath. Verify your build path!"

5,241 views
Skip to first unread message

clay

unread,
May 29, 2012, 7:27:36 PM5/29/12
to scala-i...@googlegroups.com
Windows 7 x64
Eclipse Indigo SR2 (64-bit)
Scala 2.9.2
Scala IDE for Eclipse 2.0.1.v-2_09-201204232213-dae5cd4

When I open a very simple Hello World Scala project created in Gradle (with Eclipse project generator), I get:

"Cannot find Scala library on the classpath. Verify your build path!"

I have googled this error and clicked through all the Eclipse preferences settings to look for a problem and I'm stumped.

Any ideas?

Mirco Dotta

unread,
May 30, 2012, 2:23:17 AM5/30/12
to scala-i...@googlegroups.com

Mirco Dotta

unread,
May 30, 2012, 2:41:07 AM5/30/12
to scala-i...@googlegroups.com
> created in Gradle (with Eclipse project generator)

Uuups, for some reason I completely missed this :)

Can you paste the generated .classpath

-- Mirco

iulian dragos

unread,
May 30, 2012, 4:02:47 AM5/30/12
to scala-i...@googlegroups.com
The Scala library has to come either form the Scala Classpath
container, or be called scala-library.jar. Otherwise, the builder will
fail to identify it. The preferred way is to use the Scala classpath
contiainer (for instance, sbteclipse does it that way). You can easily
fix this by adding it yourself: project properties/Java build path,
click on Add Library and the rest is easy :)

cheers
iulian

>
> Any ideas?



--
« Je déteste la montagne, ça cache le paysage »
Alphonse Allais

Jeppe Nejsum Madsen

unread,
May 30, 2012, 4:12:57 AM5/30/12
to scala-i...@googlegroups.com
On Wed, May 30, 2012 at 1:27 AM, clay <clayt...@gmail.com> wrote:
We're using gradle as well and had to tweak the generated .classpath
slightly to make it work with scala-ide:

- Since gradle has scala-library as dependency, it's put on the
"Referenced Libraries", which for some reason causes scala-ide to
always build the entire project
- In order to run specs2 unit tests with the JUnitRunner, the
SCALA_CONTAINER should come before the JRE_CONTAINER in order for
scala-ide to find the test classes


eclipse {
classpath {
containers "org.scala-ide.sdt.launching.SCALA_CONTAINER"
file {
whenMerged { classpath ->
def javaRuntime = classpath.entries.find { it instanceof
org.gradle.plugins.ide.eclipse.model.Container &&
it.path.contains('JRE_CONTAINER') }
def scalaRuntime = classpath.entries.find { it instanceof
org.gradle.plugins.ide.eclipse.model.Container &&
it.path.contains('SCALA_CONTAINER') }
def scalaLib = classpath.entries.findAll
{it.toString().contains("scala-library")}

// Avoid problems with the Scala IDE
classpath.entries.removeAll(scalaLib)

// Change container order to support running unit tests
if(javaRuntime != null && scalaRuntime != null) {
classpath.entries.remove(javaRuntime)
classpath.entries.remove(scalaRuntime)
classpath.entries.add(scalaRuntime)
classpath.entries.add(javaRuntime)
}
}
}
}
}

/Jeppe

clay

unread,
May 30, 2012, 6:16:10 PM5/30/12
to scala-i...@googlegroups.com
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="output" path="bin"/>
<classpathentry kind="src" path="src/main/scala"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER" exported="true"/>
<classpathentry sourcepath="C:/Users/cwohl/.gradle/caches/artifacts-13/filestore/org.scala-lang/scala-library/2.9.2/source/1c8e0222e53c7157befbf752bee474c7ab458eb4/scala-library-2.9.2-sources.jar" kind="lib" path="C:/Users/cwohl/.gradle/caches/artifacts-13/filestore/org.scala-lang/scala-library/2.9.2/jar/55cf429e92d45524a548929a9d6e790205a0e61/scala-library-2.9.2.jar" exported="true"/>
</classpath>

clay

unread,
May 30, 2012, 6:27:01 PM5/30/12
to scala-i...@googlegroups.com
Thanks. This fixed it. The Gradle generated project had a version of the scala-library.jar in the Eclipse project Java Build Path, but when I deleted it and recreated it to point directly to the scala-library.jar in the Scala installation folder as opposed to some Gradle cache directory, it worked.

On Wednesday, May 30, 2012 3:02:47 AM UTC-5, Iulian Dragos wrote:
Reply all
Reply to author
Forward
0 new messages