Question

I have a gradle project that has a scala subproject, say scalamodule. I want to be able to run the scala subproject as an application (this is part of the build/release process but it's irrelevant right now). Now if I use the Gradle application plugin and then run gradle :scalamodule:run the command that gets executed is something similar to this:

java -cp /home/giovanni/Projects/someproject/classes/main:/home/giovanni/.gradle/caches/modules-2/files-2.1/com.wordnik/swagger-codegen_2.10/2.0.11/77ee00b1d13b23c4cb24cb43f8bb23b2ad9a492b/swagger-codegen_2.10-2.0.11.jar:/home/giovanni/.gradle/caches/modules-2/files-2.1/org.json4s/json4s-jackson_2.10/3.2.5/8d8839d9ea00caa5aab522c53f3bacbd7189cd7c/json4s-jackson_2.10-3.2.5.jar:/home/giovanni/.gradle/caches/modules-2/files-2.1/io.backchat.inflector/scala-inflector_2.10/1.3.5/7a6c4ca65263cfae1a841332df88f1f526d337b5/scala-inflector_2.10-1.3.5.jar:/home/giovanni/.gradle/caches/modules-2/files-2.1/commons-io/commons-io/2.3/cd8d6ffc833cc63c30d712a180f4663d8f55799b/commons-io-2.3.jar:/home/giovanni/.gradle/caches/modules-2/files-2.1/org.rogach/scallop_2.10/0.9.4/f262bb88c9f981413d19b295c4aa6e050da0b202/scallop_2.10-0.9.4.jar:/home/giovanni/.gradle/caches/modules-2/files-2.1/org.fusesource.scalate/scalate-core_2.10/1.6.1/202cab825c15fabf941ecbdfa49973c691462213/scalate-core_2.10-1.6.1.jar:/home/giovanni/.gradle/caches/modules-2/files-2.1/org.json4s/json4s-core_2.10/3.2.5/715bc4e4502a60baa9de6098f17143168e93c49f/json4s-core_2.10-3.2.5.jar:/home/giovanni/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-databind/2.2.2/3c8f6018eaa72d43b261181e801e6f8676c16ef6/jackson-databind-2.2.2.jar:/home/giovanni/.gradle/caches/modules-2/files-2.1/org.scala-lang/scala-reflect/2.10.1/2c96f085955741faeb4f8da709e88d6feb91194e/scala-reflect-2.10.1.jar:/home/giovanni/.gradle/caches/modules-2/files-2.1/org.fusesource.scalate/scalate-util_2.10/1.6.1/1f566e429a343310858ce261565e25e9376587d0/scalate-util_2.10-1.6.1.jar:/home/giovanni/.gradle/caches/modules-2/files-2.1/org.slf4j/slf4j-api/1.6.1/6f3b8a24bf970f17289b234284c94f43eb42f0e4/slf4j-api-1.6.1.jar:/home/giovanni/.gradle/caches/modules-2/files-2.1/org.scala-lang/scala-compiler/2.10.0/fec8066cd2b4f8dc7ff7ba7a8e0a792939d9f9a/scala-compiler-2.10.0.jar:/home/giovanni/.gradle/caches/modules-2/files-2.1/org.json4s/json4s-ast_2.10/3.2.5/f5b836a6c06e47d4dbf65f030bd9369aba07d774/json4s-ast_2.10-3.2.5.jar:/home/giovanni/.gradle/caches/modules-2/files-2.1/com.thoughtworks.paranamer/paranamer/2.5.6/87947002ff07ea3ba6110320f64cf021f16ddf49/paranamer-2.5.6.jar:/home/giovanni/.gradle/caches/modules-2/files-2.1/org.scala-lang/scalap/2.10.0/ab42ae21d1fd7311b367fe3d7f33343f2e4bff6b/scalap-2.10.0.jar:/home/giovanni/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-annotations/2.2.2/285cb9c666f0f0f3dd8a1be04e1f457eb7b15113/jackson-annotations-2.2.2.jar:/home/giovanni/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-core/2.2.2/d20be6a5ddd6f8cfd36ebf6dea329873a1c41f1b/jackson-core-2.2.2.jar:/home/giovanni/.gradle/caches/modules-2/files-2.1/org.mockito/mockito-all/1.9.0/d13863fbd7c0bc32845c9d8a261d03b61bf28194/mockito-all-1.9.0.jar:/home/giovanni/.gradle/caches/modules-2/files-2.1/org.scala-lang/scala-library/2.10.1/ed3e1a6b0615dea666a7eaf753b03030f3f889/scala-library-2.10.1.jar com.mypack.MyClass

For some inesplicable reason the scalate library, one of my dependencies, throws the following exception when run using the java command:

Exception in thread "main" org.fusesource.scalate.TemplateException: scala.reflect.internal.TreeInfo.firstArgument(Lscala/reflect/internal/Trees$Tree;)Lscala/reflect/internal/Trees$Tree;
  at org.fusesource.scalate.TemplateEngine.compileAndLoad(TemplateEngine.scala:732)
  at org.fusesource.scalate.TemplateEngine.compile(TemplateEngine.scala:346)
...
Caused by: java.lang.NoSuchMethodError: scala.reflect.internal.TreeInfo.firstArgument(Lscala/reflect/internal/Trees$Tree;)Lscala/reflect/internal/Trees$Tree;
  at scala.tools.nsc.typechecker.Typers$Typer.parentTypes(Typers.scala:1550)
  at scala.tools.nsc.typechecker.Namers$Namer.templateSig(Namers.scala:861)
  at scala.tools.nsc.typechecker.Namers$Namer.getSig$1(Namers.scala:1300)
  at scala.tools.nsc.typechecker.Namers$Namer.typeSig(Namers.scala:1347)
...

However if I simply replace java with scala the error magically goes away.

Besides the oddity of this fact, I am trying to implement a workaround so that the command that gets executed is scala instead of java but I can't figure out how to do so.

Anybody?

Was it helpful?

Solution

It turns out the scala-reflect library was not the problem. The scala-compiler was. The correct version to use should have been 2.10.1 and it was 2.10.0 instead. I am not sure where that library came from. Will dig into that.

EDIT: I should add that I figured it out by having Gradle fail on dependency version conflicts.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top