Gradle, Scala, Eclipse and IDEA

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Gradle, Scala, Eclipse and IDEA

Russel Winder-3
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:[hidden email]
41 Buckmaster Road    m: +44 7770 465 077   xmpp: [hidden email]
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder

signature.asc (205 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Gradle, Scala, Eclipse and IDEA

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


On Tue, Oct 9, 2012 at 6:52 AM, Russel Winder <[hidden email]> wrote:
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: <a href="tel:%2B44%2020%207585%202200" value="+442075852200">+44 20 7585 2200   voip: [hidden email]
41 Buckmaster Road    m: <a href="tel:%2B44%207770%20465%20077" value="+447770465077">+44 7770 465 077   xmpp: [hidden email]
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder

Reply | Threaded
Open this post in threaded view
|

Re: Gradle, Scala, Eclipse and IDEA

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.

/Jeppe

Andrew Oberstar <[hidden email]> writes:

> 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
>
>
> On Tue, Oct 9, 2012 at 6:52 AM, Russel Winder <[hidden email]> wrote:
>
>> 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:[hidden email]
>> 41 Buckmaster Road    m: +44 7770 465 077   xmpp: [hidden email]
>> London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder
>>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Gradle, Scala, Eclipse and IDEA

Russel Winder-3
In reply to this post by Andrew Oberstar
On Wed, 2012-10-10 at 18:54 -0500, Andrew Oberstar wrote:
> 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.

> 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:[hidden email]
41 Buckmaster Road    m: +44 7770 465 077   xmpp: [hidden email]
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder

signature.asc (205 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Gradle, Scala, Eclipse and IDEA

Russel Winder-3
In reply to this post by Jeppe Nejsum Madsen
On Thu, 2012-10-11 at 08:40 +0200, Jeppe Nejsum Madsen wrote:
> 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:[hidden email]
41 Buckmaster Road    m: +44 7770 465 077   xmpp: [hidden email]
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder

signature.asc (205 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Gradle, Scala, Eclipse and IDEA

Andrew Oberstar
In reply to this post by Russel Winder-3
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


On Thu, Oct 11, 2012 at 2:17 AM, Russel Winder <[hidden email]> wrote:
On Wed, 2012-10-10 at 18:54 -0500, Andrew Oberstar wrote:
> 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.

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

Which test framework were you using?

--
Russel.
=============================================================================
Dr Russel Winder      t: <a href="tel:%2B44%2020%207585%202200" value="+442075852200">+44 20 7585 2200   voip: [hidden email]
41 Buckmaster Road    m: <a href="tel:%2B44%207770%20465%20077" value="+447770465077">+44 7770 465 077   xmpp: [hidden email]
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder

Reply | Threaded
Open this post in threaded view
|

Re: Gradle, Scala, Eclipse and IDEA

Jeppe Nejsum Madsen
In reply to this post by Russel Winder-3
Russel Winder <[hidden email]> writes:

> On Thu, 2012-10-11 at 08:40 +0200, Jeppe Nejsum Madsen wrote:
>> 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.

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

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email