[GRADLE-2855] How to replace scalaTools configuration? Created: 01/Aug/13  Updated: 10/Feb/17  Resolved: 10/Feb/17

Status: Resolved
Project: Gradle
Affects Version/s: None
Fix Version/s: None

Type: Task
Reporter: Gradle Forums Assignee: Unassigned
Resolution: Won't Fix Votes: 0


I'm trying to get rid of deprecated scalaTools configuration, but so far I'm unable to find working solution.

This is working configuraiton:

apply plugin: 'idea'
apply plugin: 'scala'

repositories {
flatDir(name: 'libs', dirs: 'lib')

def scalaVersion = '2.10.2'

def scalaDeps = [

dependencies {
compile scalaDeps
scalaTools scalaDeps

I'm able to build with no problem, gradle idea generates project correctly which means:

  • module has scala facet configured
  • there is a library with all four jar files configured (Project Structure > Libraries)

But when I try to change it as documentation suggests (adding library to compile configuration instead of scalaToos):

dependencies {
compile scalaDeps

It ends up with

Execution failed for task ':compileScala'.
> scala/Option

Idea project structure scala library contains only 'scala-compiler-2.10.2' and attempt to rebuild project in idea ends with

'scala: No 'scala-library*.jar' in Scala compiler library in gradle-scala'

My another attempt to fix this was to create special configuration and use it instead of scalaTools. It works with gradle, but idea project has still the problem decribed above (incompete library).

configurations {

dependencies {
compile scalaDeps
scalaLibs scalaDeps

tasks.withType(ScalaCompile) {
scalaClasspath = files(configurations.scalaLibs)

So my only option is to stick with deprecated scalaTools configuration.

Any help would be appreciated.

Thank you.

Comment by Gradle Forums [ 01/Aug/13 ]

Please provided the full stack trace. Why do you put `scala-compiler` and `scala-reflect` on the compile class path? Why do you use `@jar`?

Comment by Gradle Forums [ 01/Aug/13 ]

I had to add all those dependencies otherwise compilation always failed on missing classes.

We are using flatDir for depencencies and there are no poms. I thought it was necessary.

Caused by: java.lang.NoClassDefFoundError: scala/Option
at org.apache.tools.ant.ComponentHelper.checkTaskClass(ComponentHelper.java:376)
at org.apache.tools.ant.ComponentHelper.addTaskDefinition(ComponentHelper.java:341)
at org.apache.tools.ant.Project.addTaskDefinition(Project.java:971)
at org.apache.tools.ant.Project$addTaskDefinition.call(Unknown Source)
at org.apache.tools.ant.Project$addTaskDefinition.call(Unknown Source)
at org.gradle.api.internal.project.AntBuilderDelegate$_taskdef_closure1_closure2.doCall(DefaultIsolatedAntBuilder.groovy:139)
at org.gradle.api.internal.project.AntBuilderDelegate$_taskdef_closure1.doCall(DefaultIsolatedAntBuilder.groovy:138)
at org.gradle.api.internal.project.AntBuilderDelegate.taskdef(DefaultIsolatedAntBuilder.groovy:136)
at org.gradle.api.internal.tasks.scala.AntScalaCompiler$_execute_closure1.doCall(AntScalaCompiler.groovy:62)
at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:58)
at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:133)
at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:94)
at org.gradle.util.ConfigureUtil$configure.call(Unknown Source)
at org.gradle.api.internal.project.DefaultIsolatedAntBuilder.execute(DefaultIsolatedAntBuilder.groovy:112)
at org.gradle.api.internal.project.IsolatedAntBuilder$execute.call(Unknown Source)
at org.gradle.api.internal.tasks.scala.AntScalaCompiler.execute(AntScalaCompiler.groovy:61)
at org.gradle.api.internal.tasks.scala.AntScalaCompiler.execute(AntScalaCompiler.groovy)
at org.gradle.api.internal.tasks.scala.DefaultScalaJavaJointCompiler.execute(DefaultScalaJavaJointCompiler.java:35)
at org.gradle.api.internal.tasks.scala.DefaultScalaJavaJointCompiler.execute(DefaultScalaJavaJointCompiler.java:25)
at org.gradle.api.internal.tasks.scala.DelegatingScalaCompiler.execute(DelegatingScalaCompiler.java:31)
at org.gradle.api.internal.tasks.scala.DelegatingScalaCompiler.execute(DelegatingScalaCompiler.java:22)
at org.gradle.api.internal.tasks.compile.IncrementalJavaCompilerSupport.execute(IncrementalJavaCompilerSupport.java:33)
at org.gradle.api.internal.tasks.compile.IncrementalJavaCompilerSupport.execute(IncrementalJavaCompilerSupport.java:24)
at org.gradle.api.tasks.scala.ScalaCompile.compile(ScalaCompile.java:133)
at org.gradle.api.internal.BeanDynamicObject$MetaClassAdapter.invokeMethod(BeanDynamicObject.java:216)
at org.gradle.api.internal.BeanDynamicObject.invokeMethod(BeanDynamicObject.java:122)
at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:147)
at org.gradle.api.tasks.scala.ScalaCompile_Decorated.invokeMethod(Unknown Source)
at org.gradle.util.ReflectionUtil.invoke(ReflectionUtil.groovy:23)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:217)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:210)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:199)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:526)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:509)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
... 88 more
Caused by: java.lang.ClassNotFoundException: scala.Option
... 124 more

Comment by Gradle Forums [ 01/Aug/13 ]

Oh I see, you are using a `flatDir` repository. I'm afraid that automatic configuration of `ScalaCompile.scalaClasspath` won't work in this case. This is because the Scala plugin cannot reliably tell the transitive dependencies of a particular `scala-compiler` version and hence relies on transitive dependency solution to bring them in (which won't happen with a `flatDir` repository). Hence you'll have to set `scalaClasspath` yourself. Something like:

tasks.withType(ScalaCompile) {
scalaClasspath = files("lib/scala-compiler.jar", "lib/scala-reflect.jar", "lib/scala-library.jar")

Comment by Gradle Forums [ 01/Aug/13 ]

You shouldn't have to add `scala-compiler` to the compile class path, unless you are using the compiler at runtime. `@jar` shouldn't be necessary, but with a `flatDir` repo it won't make a difference.

Comment by Gradle Forums [ 01/Aug/13 ]

Yes, this is what I did in the last scenario, but idea project is still misconfigured. So if I get that right, there are two options:

1. don't use flatDir for this particular module with scala
2. modify idea project myself

Any other option?

Thank you.

Comment by Gradle Forums [ 01/Aug/13 ]

It's the same problem (transitive dependencies are missing). I'm not aware of another option, sorry. What you can try is to just generate the missing bits of information (Jars for `scala-compiler` liblary in .ipr).

Comment by Gradle Forums [ 01/Aug/13 ]

Ok, thank you for your help. I appreciate it.

Comment by Benjamin Muschko [ 15/Nov/16 ]

As announced on the Gradle blog we are planning to completely migrate issues from JIRA to GitHub.

We intend to prioritize issues that are actionable and impactful while working more closely with the community. Many of our JIRA issues are inactionable or irrelevant. We would like to request your help to ensure we can appropriately prioritize JIRA issues you’ve contributed to.

Please confirm that you still advocate for your JIRA issue before December 10th, 2016 by:

  • Checking that your issues contain requisite context, impact, behaviors, and examples as described in our published guidelines.
  • Leave a comment on the JIRA issue or open a new GitHub issue confirming that the above is complete.

We look forward to collaborating with you more closely on GitHub. Thank you for your contribution to Gradle!

Comment by Benjamin Muschko [ 10/Feb/17 ]

Thanks again for reporting this issue. We haven't heard back from you after our inquiry from November 15th. We are closing this issue now. Please create an issue on GitHub if you still feel passionate about getting it resolved.

Generated at Wed Jun 30 12:33:17 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.