Discussion:
Gradle, Scala, Eclipse and IDEA
Russel Winder
2012-10-09 11:52:59 UTC
Permalink
Has anyone managed to get Gradle built Scala project working with either
or both of IntelliJ IDEA or Eclipse? It all works fine using SBT and
fails to do anything useful using Gradle :-(
--
Russel.
=============================================================================
Dr Russel Winder t: +44 20 7585 2200 voip: sip:***@ekiga.net
41 Buckmaster Road m: +44 7770 465 077 xmpp: russel-***@public.gmane.org
London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
Andrew Oberstar
2012-10-10 23:54:48 UTC
Permalink
Are you referring to building any Scala project with Gradle and developing
in Eclipse/IDEA or building the Scala Language project with Gradle?

I've been able to use Eclipse with my Gradle built Scala projects.

Andrew Oberstar
Post by Russel Winder
Has anyone managed to get Gradle built Scala project working with either
or both of IntelliJ IDEA or Eclipse? It all works fine using SBT and
fails to do anything useful using Gradle :-(
--
Russel.
=============================================================================
London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
Jeppe Nejsum Madsen
2012-10-11 06:40:39 UTC
Permalink
We're also using Gradle/Eclipse for our (multi module) project. Works
fine, though we had to modify how the eclipse classpath files are
generated to make the Scala Eclipse plugin happy.

/Jeppe
Post by Andrew Oberstar
Are you referring to building any Scala project with Gradle and developing
in Eclipse/IDEA or building the Scala Language project with Gradle?
I've been able to use Eclipse with my Gradle built Scala projects.
Andrew Oberstar
Post by Russel Winder
Has anyone managed to get Gradle built Scala project working with either
or both of IntelliJ IDEA or Eclipse? It all works fine using SBT and
fails to do anything useful using Gradle :-(
--
Russel.
=============================================================================
London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
Russel Winder
2012-10-11 07:18:23 UTC
Permalink
Post by Jeppe Nejsum Madsen
We're also using Gradle/Eclipse for our (multi module) project. Works
fine, though we had to modify how the eclipse classpath files are
generated to make the Scala Eclipse plugin happy.
Is this something that should be fixed in the Gradle Scala plugin or
just something that has to be done manually?

Are you using ScalaTest?
--
Russel.
=============================================================================
Dr Russel Winder t: +44 20 7585 2200 voip: sip:***@ekiga.net
41 Buckmaster Road m: +44 7770 465 077 xmpp: russel-***@public.gmane.org
London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
Jeppe Nejsum Madsen
2012-10-12 06:28:40 UTC
Permalink
Post by Russel Winder
Post by Jeppe Nejsum Madsen
We're also using Gradle/Eclipse for our (multi module) project. Works
fine, though we had to modify how the eclipse classpath files are
generated to make the Scala Eclipse plugin happy.
Is this something that should be fixed in the Gradle Scala plugin or
just something that has to be done manually?
Code added below,

I think Gradle should add the container and not add the
scala-library.jar, but the ordering of the classpath entries seems like
a bug in the Eclipse Scala plugin.
Post by Russel Winder
Are you using ScalaTest?
No, we're using specs2 with the JUnit launcher. This doesn't work (at
least with earlier versions of the plugin, Eclipse can't find the
classes iirc) unless the scala runtime is before the java runtime.

/Jeppe

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)
}
}
}
}
}

Russel Winder
2012-10-11 07:17:24 UTC
Permalink
Post by Andrew Oberstar
Are you referring to building any Scala project with Gradle and developing
in Eclipse/IDEA or building the Scala Language project with Gradle?
The former. I have a trivial Scala/ScalaTest project that executes fine
using Gradle directly, but trying to generate Eclipse or IntelliJ IDEA
projects leads to no way of running the tests in the project. Using SBT
everything works fine for IntelliJ IDEA but Eclipse is still
problematic.
Post by Andrew Oberstar
I've been able to use Eclipse with my Gradle built Scala projects.
Which test framework were you using?
--
Russel.
=============================================================================
Dr Russel Winder t: +44 20 7585 2200 voip: sip:***@ekiga.net
41 Buckmaster Road m: +44 7770 465 077 xmpp: russel-***@public.gmane.org
London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
Andrew Oberstar
2012-10-12 02:28:53 UTC
Permalink
Hmm... I was thinking I had an example of Scala building in Gradle with
tests, but I'm not seeing one now. I've only toyed with Scala so far, so I
guess I don't know for sure if it was working with tests when I tried.

Andrew Oberstar
Post by Andrew Oberstar
Post by Andrew Oberstar
Are you referring to building any Scala project with Gradle and
developing
Post by Andrew Oberstar
in Eclipse/IDEA or building the Scala Language project with Gradle?
The former. I have a trivial Scala/ScalaTest project that executes fine
using Gradle directly, but trying to generate Eclipse or IntelliJ IDEA
projects leads to no way of running the tests in the project. Using SBT
everything works fine for IntelliJ IDEA but Eclipse is still
problematic.
Post by Andrew Oberstar
I've been able to use Eclipse with my Gradle built Scala projects.
Which test framework were you using?
--
Russel.
=============================================================================
London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
Loading...