0

I have a scala file located at src/main/scala/my.cool.package.name/MyTestClass that has an import for scala.reflect.runtime.universe._. Maven resolves this dependency fine, and the code compiles. The import is heavily used throughout the code, so I know the dependency actually exists and Maven is using it.

The project-name.iml file that IDEA generates has the reference to scala-reflect, but it's putting it in the TEST scope:

<orderEntry type="library" scope="TEST" name="Maven: org.scala-lang:scala-reflect:2.11.8" level="project" />

Because it's in TEST, and the source file isn't, the source file generates tons of warnings & errors in IDEA. If I manually remove scope="TEST" from that line, IDEA resolves the dependency perfectly fine. The problem is that this file is auto-generated, so this change gets removed pretty often.

So, what is causing scala-reflect to be brought in as TEST? I'm not explicitly referencing reflect anywhere in my pom.xml file, so if it's come from Maven, I'm not sure how. Is there a way to force that line to be generated the way I want?

Max
  • 849
  • 9
  • 24
  • Show your pom.xml. If you add ` org.scala-lang scala-reflect 2.12.4 compile ` does this change anything? What dependency brings scala-reflect you can see using https://stackoverflow.com/questions/6796893/view-a-dependency-tree-in-maven – Dmytro Mitin Nov 13 '17 at 18:04
  • 1
    Adding that dependency seems to have resolved my issues. If you post that as an answer I will accept it. Thanks! – Max Nov 13 '17 at 20:05
  • https://stackoverflow.com/a/47272705/5249621 – Dmytro Mitin Nov 13 '17 at 20:08

1 Answers1

2

Try to add

<dependency> 
  <groupId>org.scala-lang</groupId> 
  <artifactId>scala-reflect</artifactId> 
  <version>2.12.4<!--your version of Scala--></version> 
  <scope>compile<!--runtime--></scope> 
</dependency>

to pom.xml.

Dmytro Mitin
  • 48,194
  • 3
  • 28
  • 66