4
votes

I've got a Spring Boot project building through Gradle that recently saw the addition of some Gatling tests. The Gatlings stuff, which needs Scala support, is all down in src/test/scala. The build.gradle file got a new testCompile dependency to support it and, from a gradle perspective, all is well...

build.gradle

apply plugin: 'scala'
...
dependencies {
  ...
  testCompile "org.scala-lang:scala-library:2.11.1"
  testCompile "io.gatling.highcharts:gatling-charts-highcharts:2.2.5"
  ...
}

The gradle docs suggest that testCompile is all we need here: https://docs.gradle.org/current/userguide/scala_plugin.html

IntelliJ is unhappy with this configuration insisting

Warning:<i><b>root project 'tenderfoot': Unable to build Scala project configuration</b>
Details: org.gradle.api.GradleException: Cannot infer Scala class path because no Scala library Jar was found. Does root project 'tenderfoot' declare dependency to scala-library? Searched classpath: configuration ':compileClasspath'.</i>

If I lift the dependency up from testCompile to compile, the intellij warning goes away, but now my spring boot uber jar thing is unnecessarily bloated.

What's the way out? How do I get IntelliJ to stop Warning on this?

Is this actually an IntelliJ bug?

1
Simple dude change : testCompile "org.scala-lang:scala-library:2.11.1" to compile "org.scala-lang:scala-library:2.11.1"Aravinth
@Aravinth yeah...I know. Now may already bloated Spring Boot JAR is further huge due to IntelliJ bug. Qwality!Bob Kuhar
Okay then close this oneAravinth
If you're using scala, then it should be in your uber jar. Perhaps you could manage with a non-uber jar instead though.Danny Varod

1 Answers

1
votes

I ran into this problem also (having to set the dependency manually from IntelliJ).

I "fixed" it by setting the dependency as compileOnly as opposed to compile, this scope does not include the JAR in the final distribution.

The code I use is (please note that my dependency includes Scala as a transitive dependency):

    compileOnly("io.gatling.highcharts:gatling-charts-highcharts:$gatlingVersion")