Russel Winder <rus...@winder.org.uk> 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


Reply via email to